power shell 操作键盘鼠标
2017-03-01 14:41
357 查看
# 操作键盘 $wshell = New-Object -ComObject wscript.shell # 操作鼠标 function Click-MouseButton { param([string]$Button, [switch]$help) $HelpInfo = @' Function : Click-MouseButton By : John Bartels Date : 12/16/2012 Purpose : Clicks the Specified Mouse Button Usage : Click-MouseButton [-Help][-Button x] where -Help displays this help -Button specify the Button You Wish to Click {left, middle, right} '@ if ($help -or (!$Button)) { write-host $HelpInfo return } else { $signature=@' [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); '@ $SendMouseClick = Add-Type -memberDefinition $signature -name "Win32MouseEventNew" -namespace Win32Functions -passThru if($Button -eq "left") { $SendMouseClick::mouse_event(0x00000002, 0, 0, 0, 0); $SendMouseClick::mouse_event(0x00000004, 0, 0, 0, 0); } if($Button -eq "right") { $SendMouseClick::mouse_event(0x00000008, 0, 0, 0, 0); $SendMouseClick::mouse_event(0x00000010, 0, 0, 0, 0); } if($Button -eq "middle") { $SendMouseClick::mouse_event(0x00000020, 0, 0, 0, 0); $SendMouseClick::mouse_event(0x00000040, 0, 0, 0, 0); } } } # 创建窗口 Add-Type -AssemblyName System.Windows.Forms $form = New-Object system.Windows.Forms.Form # 显示对话框 $form.Text = "开始" $form.ShowDialog() # 休息5秒 Start-Sleep -Seconds 5 # 循环 for($index = 0;$index -le 100;$index++){ echo $index $wshell.SendKeys("{END}") Start-Sleep -Milliseconds 150 Click-MouseButton "left" } # 提示结束 $form.Text = "结束" $form.ShowDialog()
相关文章推荐
- 无鼠标单键盘操作电脑
- 用键盘模拟鼠标操作
- Mgestyk:再见,键鼠!不用鼠标和键盘 用手在空中操作电脑!技术前沿
- 判断设定的时间内 有无鼠标或键盘操作
- 实现鼠标和键盘操作的类
- 【原创】用MASM32写的记录和回放 键盘+鼠标 操作程序
- .net中模拟键盘和鼠标操作
- vc模拟鼠标键盘操作实用类
- 纯键盘操作,脱离鼠标
- 电脑高手可以不用鼠标的只用全键盘操作
- 模拟鼠标键盘操作,含硬件模拟技术。
- 键盘模拟鼠标(实现用键盘操作鼠标光标)(示例代码下载)
- 屏蔽键盘和鼠标的一些操作
- vc模拟鼠标键盘操作实用类
- 背熟以下文章,就能脱离鼠标,光用键盘操作了
- c#模拟鼠标键盘操作
- 转载:键盘模拟鼠标(实现用键盘操作鼠标光标)(示例代码下载)
- Control Study -> 键盘模拟鼠标(实现用键盘操作鼠标光标)(示例代码下载)
- 模拟键盘鼠标操作——IoAccessMap介绍
- .net中模拟键盘和鼠标操作