当前位置: 首页 > news >正文

如何建设学校网站做网站在哪里添加关键词

如何建设学校网站,做网站在哪里添加关键词,品牌建设不足的原因,郑州微信网站制作目录 前言功能概述代码实现1. 引入必要的程序集2. 定义读取文件行的函数3. 定义加载图片的函数4. 定义查找小图像在大图像中的位置的函数5. 定义截取全屏的函数6. 定义模拟鼠标点击的函数7. 定义主函数 配置文件示例运行脚本结语全部代码提示打包exe 下载地址 前言 在日常工作… 目录 前言功能概述代码实现1. 引入必要的程序集2. 定义读取文件行的函数3. 定义加载图片的函数4. 定义查找小图像在大图像中的位置的函数5. 定义截取全屏的函数6. 定义模拟鼠标点击的函数7. 定义主函数 配置文件示例运行脚本结语全部代码提示打包exe 下载地址 前言 在日常工作中我们有时需要进行一些自动化操作比如在屏幕上找到特定图像并执行鼠标点击操作。本文将介绍如何使用 PowerShell 实现这一功能。 功能概述 本文提供的脚本包括以下功能 读取配置文件获取需要操作的图像路径、鼠标按键类型以及延迟时间。 截取屏幕并寻找特定图像的位置。 在找到图像后模拟鼠标点击。 根据配置文件中的延迟时间执行下一次操作。 代码实现 1. 引入必要的程序集 Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing2. 定义读取文件行的函数 function Read-FileLines {param ([string]$filePath)return Get-Content -Path $filePath }3. 定义加载图片的函数 function Load-Image {param ([string]$imagePath)return [System.Drawing.Image]::FromFile($imagePath) }4. 定义查找小图像在大图像中的位置的函数 function Find-ImagePosition {param ([System.Drawing.Bitmap]$bigImage,[System.Drawing.Bitmap]$smallImage)# 查找逻辑...return $null }5. 定义截取全屏的函数 function Capture-Screen {$screenWidth [System.Windows.Forms.SystemInformation]::VirtualScreen.Width$screenHeight [System.Windows.Forms.SystemInformation]::VirtualScreen.Height$bitmap New-Object System.Drawing.Bitmap($screenWidth, $screenHeight)$graphics [System.Drawing.Graphics]::FromImage($bitmap)$graphics.CopyFromScreen(0, 0, 0, 0, [System.Drawing.Size]::new($screenWidth, $screenHeight))$graphics.Dispose()return $bitmap }6. 定义模拟鼠标点击的函数 Add-Type using System; using System.Runtime.InteropServices;public class User32 {[DllImport(user32.dll, CharSet CharSet.Auto, CallingConvention CallingConvention.StdCall)]public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);public const int MOUSEEVENTF_MOVE 0x0001;public const int MOUSEEVENTF_LEFTDOWN 0x0002;public const int MOUSEEVENTF_LEFTUP 0x0004;public const int MOUSEEVENTF_RIGHTDOWN 0x0008;public const int MOUSEEVENTF_RIGHTUP 0x0010;public const int MOUSEEVENTF_ABSOLUTE 0x8000; }function Simulate-Click {param ([int]$x,[int]$y,[int]$button)[System.Windows.Forms.Cursor]::Position [System.Drawing.Point]::new($x, $y)switch ($button) {1 { [User32]::mouse_event([User32]::MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)[User32]::mouse_event([User32]::MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)}2 {[User32]::mouse_event([User32]::MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)[User32]::mouse_event([User32]::MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)}} }7. 定义主函数 function Run {param ([string]$configPath)$configLines Read-FileLines -filePath $configPathwhile(1){foreach ($line in $configLines) {$parts $line -split $imagePath $parts[0]$button [int]$parts[1]$delay [int]$parts[2]$smallImage Load-Image -imagePath $imagePathwhile(1){$bigImage Capture-Screen$position Find-ImagePosition -bigImage $bigImage -smallImage $smallImageif ($position -ne $null) {Write-Output Click Position $positionSimulate-Click -x $position.X -y $position.Y -button $buttonbreak} else {Write-Output Not Find $imagePathStart-Sleep -Milliseconds 500}}Start-Sleep -Seconds $delayWrite-Output Time-Sleep $delay}} } Run -configPath ./conf.dd配置文件示例 image1.png 1 5 image2.png 2 3配置文件中每一行代表一组操作依次为图像路径、鼠标按键1为左键2为右键和延迟时间秒。 运行脚本 # 如果遇到执行权限问题请运行以下命令解除限制 Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process# 执行脚本 Run -configPath ./conf.dd结语 通过以上脚本我们可以实现自动化图像识别与鼠标点击操作大大提高了工作效率。希望本文对您有所帮助。如果您有任何问题或建议欢迎留言讨论。 全部代码 Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing# 读取指定位置的文件返回按行分割的string列表 function Read-FileLines {param ([string]$filePath)return Get-Content -Path $filePath }# 读取指定位置的图片返回图片的指针 function Load-Image {param ([string]$imagePath)return [System.Drawing.Image]::FromFile($imagePath) }# 查找小图片在大图片中的位置返回小图片在大图片中的位置中心点 function Find-ImagePosition {param ([System.Drawing.Bitmap]$bigImage,[System.Drawing.Bitmap]$smallImage)$bigData $bigImage.LockBits([System.Drawing.Rectangle]::FromLTRB(0, 0, $bigImage.Width, $bigImage.Height), [System.Drawing.Imaging.ImageLockMode]::ReadOnly, $bigImage.PixelFormat)$smallData $smallImage.LockBits([System.Drawing.Rectangle]::FromLTRB(0, 0, $smallImage.Width, $smallImage.Height), [System.Drawing.Imaging.ImageLockMode]::ReadOnly, $smallImage.PixelFormat)try {for ($x 0; $x -le $bigData.Width - $smallData.Width; $x) {for ($y 0; $y -le $bigData.Height - $smallData.Height; $y) {$found $truefor ($i 0; $i -lt $smallData.Width; $i) {for ($j 0; $j -lt $smallData.Height; $j) {$bigColor [System.Drawing.Color]::FromArgb([System.Runtime.InteropServices.Marshal]::ReadInt32($bigData.Scan0, (($y $j) * $bigData.Stride) ($x $i) * 4))$smallColor [System.Drawing.Color]::FromArgb([System.Runtime.InteropServices.Marshal]::ReadInt32($smallData.Scan0, ($j * $smallData.Stride) $i * 4))if ($bigColor.ToArgb() -ne $smallColor.ToArgb()) {$found $falsebreak}}if (-not $found) { break }}if ($found) {return [System.Drawing.Point]::new($x [math]::Round($smallData.Width / 2), $y [math]::Round($smallData.Height / 2))}}}} finally {$bigImage.UnlockBits($bigData)$smallImage.UnlockBits($smallData)}return $null }# 截取全屏返回指针 function Capture-Screen {$screenWidth [System.Windows.Forms.SystemInformation]::VirtualScreen.Width$screenHeight [System.Windows.Forms.SystemInformation]::VirtualScreen.Height$bitmap New-Object System.Drawing.Bitmap($screenWidth, $screenHeight)$graphics [System.Drawing.Graphics]::FromImage($bitmap)$graphics.CopyFromScreen(0, 0, 0, 0, [System.Drawing.Size]::new($screenWidth, $screenHeight))$graphics.Dispose()return $bitmap }# 模拟鼠标点击移动传入xy Add-Type using System; using System.Runtime.InteropServices;public class User32 {[DllImport(user32.dll, CharSet CharSet.Auto, CallingConvention CallingConvention.StdCall)]public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);public const int MOUSEEVENTF_MOVE 0x0001;public const int MOUSEEVENTF_LEFTDOWN 0x0002;public const int MOUSEEVENTF_LEFTUP 0x0004;public const int MOUSEEVENTF_RIGHTDOWN 0x0008;public const int MOUSEEVENTF_RIGHTUP 0x0010;public const int MOUSEEVENTF_ABSOLUTE 0x8000; } function Simulate-Click {param ([int]$x,[int]$y,[int]$button)[System.Windows.Forms.Cursor]::Position [System.Drawing.Point]::new($x, $y)switch ($button) {1 { # 左键[User32]::mouse_event([User32]::MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)[User32]::mouse_event([User32]::MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)}2 { # 右键[User32]::mouse_event([User32]::MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)[User32]::mouse_event([User32]::MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)}} }# 主函数 function Run {param ([string]$configPath)$configLines Read-FileLines -filePath $configPathwhile(1){foreach ($line in $configLines) {$parts $line -split $imagePath $parts[0]$button [int]$parts[1]$delay [int]$parts[2]$smallImage Load-Image -imagePath $imagePathwhile(1){$bigImage Capture-Screen$position Find-ImagePosition -bigImage $bigImage -smallImage $smallImageif ($position -ne $null) {Write-Output Click Position $positionSimulate-Click -x $position.X -y $position.Y -button $buttonbreak} else {Write-Output Not Find $imagePathStart-Sleep -Milliseconds 500}}Start-Sleep -Seconds $delayWrite-Output Time-Sleep $delay}}}Run -configPath ”./conf.dd“ # Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process # 示例使用 提示 打包exe Install-Module -Name ps2exe -Scope CurrentUser Invoke-ps2exe -InputFile .\run.ps1 -OutputFile .\run.exe下载地址 传送门
http://www.hkea.cn/news/14480103/

相关文章:

  • 免费域名申请网站大全推荐住房和成乡建设部网站
  • 手机网站 jquery 特效青岛栈桥门票多少钱一张
  • 社交网站解决方案怎么做自己的网站
  • 如何在720云网站做全景视频百度小说风云榜今天
  • 怎样给公司产品做网站台州网站设计外包
  • 南昌做网站设计自助建设网站
  • 公司建立自己的网站吗保山专业的网站建设
  • 网站设计实验保险网站建设方案
  • 兼职做平面模特网站服装市场调网站建设的目的
  • 没公司怎么做网站手机网站建设wap
  • 设计网站免费素材企业大型网站建设要多少钱
  • 辽阳高端网站建设公司创业网站建设
  • centos做网站服务器吗深圳建设工程交易中心宝安中心
  • 简述网站建设流程中的各个步骤银徽seo
  • 江苏省建设工程交易中心网站微信公众号开通流程
  • php怎么做网站教程flash网页制作
  • 安卓系统上怎样做网站前端开发dsicuz做的网站
  • 阿里云备案多个网站吗阜阳市住房和城乡建设部网站
  • 格尔木市住房和城乡建设局网站wordpress 后台速度慢
  • 做网站 看什么书北京云无限优化
  • 律师做网站推广有用吗建设网站财务分析
  • 我要找人做网站的主页微信app官网下载
  • 利用虚拟主机建设网站的实验报告企业网站html
  • 北京seo公司网站建设网站用户名是什么意思
  • 购物优惠券网站怎么做福建省建设厅考试网站
  • 古楼角网站建设node.js下载wordpress
  • 成都百度网站制作六安住房和城乡建设部网站
  • 怎么样让网站正常解析计算机网站开发背景
  • 企业建站系统下载福建建设监理网站
  • 浙江省建设注册管理中心网站首页wordpress 插件推荐