如何将鼠标指针移动到屏幕中央并单击鼠标左键?

How to move the mouse pointer to the center of the screen and apply left click?

我有一个 Kiosk,在启动时带有 Google Chrome 浏览器 运行。但是当它启动时它不起作用,除非在中心生成左键单击(因为 Google Chrome 错误)。我试过跟随但它不起作用。

如何判断转到屏幕中央并单击左键(而不是右键单击)。

Set WshShell = wscript.createobject("Wscript.Shell") 
WshShell.SendKeys("+{F10}")

编辑:runme.bat

timeout 10 > nul
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --kiosk

编辑:centerme.vbs(失败)

set a = createobject("wscript.shell")
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long

Private Sub someSub()
  dim someX as Long, someY as Long
  someX = 400
  someY = 400
  SetCursorPos someX, someY
End Sub

wscript.quit

如果你这样尝试呢?

Option Explicit
Dim ws
set ws = CreateObject("wscript.shell")
wscript.sleep 10000
ws.run "chrome.exe --kiosk"

VBScript 不允许移动鼠标光标或应用鼠标单击。您发布的 "VBScript" 代码是 VB/VBA 代码,在 VBScript 中不起作用。你需要像 AutoIt 这样的东西来完成你想要做的事情。

我昨天遇到了这个 "left-click" 问题。 解决办法是启用Windows "Mouse Keys" 功能,这样你不仅可以移动鼠标光标,还可以左键单击:

set WshShell = WScript.CreateObject("WScript.Shell")

'启用鼠标键

WshShell.SendKeys "{%}{+}{NUMLOCK}"
WScript.Sleep 500

'确认启用

WshShell.SendKeys "{ENTER}"
WScript.Sleep 500

'左键单击 Windows 10

WshShell.SendKeys "{\}"

'左键单击 Windows 7

WshShell.SendKeys "{Pad5}" (might also be just, "{5}" )