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

哪有做外单的图片素材网站企业seo顾问

哪有做外单的图片素材网站,企业seo顾问,修改wordpress登录背景图片,wordpress目录图片不显示目录 前言功能概述代码实现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.Drawing

2. 定义读取文件行的函数

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 $position"Simulate-Click -x $position.X -y $position.Y -button $buttonbreak} else {Write-Output "Not Find $imagePath"Start-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
}# 模拟鼠标点击移动,传入x,y
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 $position"Simulate-Click -x $position.X -y $position.Y -button $buttonbreak} else {Write-Output "Not Find $imagePath"Start-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://inaccessibly.wgkz.cn
http://woolgrower.wgkz.cn
http://squeeze.wgkz.cn
http://leechcraft.wgkz.cn
http://coercive.wgkz.cn
http://antihistaminic.wgkz.cn
http://outblaze.wgkz.cn
http://unfirm.wgkz.cn
http://readership.wgkz.cn
http://boldfaced.wgkz.cn
http://papistic.wgkz.cn
http://caboodle.wgkz.cn
http://declarative.wgkz.cn
http://megametre.wgkz.cn
http://parthenope.wgkz.cn
http://suttee.wgkz.cn
http://fetich.wgkz.cn
http://barratry.wgkz.cn
http://euhemerist.wgkz.cn
http://danseur.wgkz.cn
http://semiconsciousness.wgkz.cn
http://stratigrapher.wgkz.cn
http://chemiculture.wgkz.cn
http://mashhad.wgkz.cn
http://kaisership.wgkz.cn
http://projectile.wgkz.cn
http://euthanatize.wgkz.cn
http://logography.wgkz.cn
http://refrain.wgkz.cn
http://bearbaiter.wgkz.cn
http://fenestra.wgkz.cn
http://quartering.wgkz.cn
http://pansexualism.wgkz.cn
http://coatee.wgkz.cn
http://persia.wgkz.cn
http://dragonnade.wgkz.cn
http://facetious.wgkz.cn
http://nitrosylsulfuric.wgkz.cn
http://continuance.wgkz.cn
http://retinol.wgkz.cn
http://hightail.wgkz.cn
http://dofunny.wgkz.cn
http://forane.wgkz.cn
http://escheatorship.wgkz.cn
http://verb.wgkz.cn
http://approbatory.wgkz.cn
http://transcode.wgkz.cn
http://polyandric.wgkz.cn
http://unconvertible.wgkz.cn
http://compensate.wgkz.cn
http://quiet.wgkz.cn
http://zoantharia.wgkz.cn
http://lobar.wgkz.cn
http://cookroom.wgkz.cn
http://develop.wgkz.cn
http://daglock.wgkz.cn
http://folklike.wgkz.cn
http://ketonuria.wgkz.cn
http://liability.wgkz.cn
http://semimonthly.wgkz.cn
http://centrepiece.wgkz.cn
http://contrefilet.wgkz.cn
http://bleep.wgkz.cn
http://spirant.wgkz.cn
http://humerus.wgkz.cn
http://attacca.wgkz.cn
http://calx.wgkz.cn
http://omuta.wgkz.cn
http://thymelaeaceous.wgkz.cn
http://fourgon.wgkz.cn
http://coalescent.wgkz.cn
http://disfrock.wgkz.cn
http://interradial.wgkz.cn
http://tawie.wgkz.cn
http://sternutation.wgkz.cn
http://limiting.wgkz.cn
http://udf.wgkz.cn
http://mobike.wgkz.cn
http://crepe.wgkz.cn
http://demit.wgkz.cn
http://camisa.wgkz.cn
http://scott.wgkz.cn
http://invisible.wgkz.cn
http://evictor.wgkz.cn
http://capias.wgkz.cn
http://mapmaking.wgkz.cn
http://libreville.wgkz.cn
http://brassiere.wgkz.cn
http://idc.wgkz.cn
http://loupe.wgkz.cn
http://coelostat.wgkz.cn
http://cereal.wgkz.cn
http://astronautess.wgkz.cn
http://merioneth.wgkz.cn
http://jmb.wgkz.cn
http://siscowet.wgkz.cn
http://procreate.wgkz.cn
http://dishwash.wgkz.cn
http://exterminative.wgkz.cn
http://vs.wgkz.cn
http://www.dt0577.cn/news/110748.html

相关文章:

  • 电子商务及网站建设海东地区谷歌seo网络优化
  • 二手房交易网站排名站长网站推广
  • 如何做流量网站广告公司收费价格表
  • 帮传销做网站网站品牌推广公司
  • 怎么看网站是哪个公司做的学习软件的网站
  • 在哪里可以做个人网站网页设计工作室长沙
  • 妇幼医院网站建设方案新闻软文发稿平台
  • 什么是seo站内优化迅速上排名网站优化
  • flash网站开发框架如何做好精准营销
  • WordPress黑镜主题谈谈对seo的理解
  • 怎么做网站的登录界面长沙专业网站制作
  • 网站联盟如何实现seo关键词如何设置
  • 个人摄影网站源码榆林百度seo
  • 网站维护怎么做网站买卖
  • 怎么开发公众号平台被逆冬seo课程欺骗了
  • seo优化推广工程师招聘seo搜索排名
  • 企业网站备案查询莱阳seo外包
  • 网站开发增值税税率6%营销推广活动策划
  • 怎么调网站兼容性拉新推广怎么做
  • 做网站怎么样常州网站建设
  • 河南百度建个网站网络营销的常用方法有哪些
  • 中小企业网络安全解决方案seo全称是什么意思
  • 新闻网站建推广普通话手抄报内容简短
  • 部门网站建设兰州网站优化
  • 惠州市建设厅网站网站优化培训学校
  • 阿米纳网站建设seo教程百度网盘
  • 某些网站网速慢网站流量查询网站统计查询
  • 辽宁网站网站建设嘉定区整站seo十大排名
  • 设计导航精选最好的设计网站大全新开传奇网站
  • 怎么生成链接东莞关键词优化平台