Autohotkey ControlSend不发送到非最上面的窗口
是否可以将ControlSend/click设置为后台窗口? 这段代码通过id/handler查找窗口,但仅当窗口是最上面的时才发送click/keystroke。如果窗口不是最上面的,ControlSend将跳过其操作。ControlClick强制将窗口置于顶部,然后单击Autohotkey ControlSend不发送到非最上面的窗口,autohotkey,Autohotkey,是否可以将ControlSend/click设置为后台窗口? 这段代码通过id/handler查找窗口,但仅当窗口是最上面的时才发送click/keystroke。如果窗口不是最上面的,ControlSend将跳过其操作。ControlClick强制将窗口置于顶部,然后单击 #Singleinstance DetectHiddenWindows, On #SingleInstance Force #MaxThreadsPerHotkey, 2 SendMode Input ; Recommen
#Singleinstance
DetectHiddenWindows, On
#SingleInstance Force
#MaxThreadsPerHotkey, 2
SendMode Input ; Recommended for new scripts
SetControlDelay -1
PostClick(x,y,win="A") {
lParam := x & 0xFFFF | (y & 0xFFFF) << 16
PostMessage, 0x201, , %lParam%, , %win% ;WM_LBUTTONDOWN
PostMessage, 0x202, , %lParam%, , %win% ;WM_LBUTTONUP
}
RunAsAdmin() {
Loop, %0% {
param := %A_Index% ; Fetch the contents of the variable whose name is contained in A_Index.
params .= A_Space . param
}
ShellExecute := A_IsUnicode ? "shell32\ShellExecute":"shell32\ShellExecuteA"
if not A_IsAdmin
{
If A_IsCompiled
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_ScriptFullPath, str, params , str, A_WorkingDir, int, 1)
Else
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_AhkPath, str, """" . A_ScriptFullPath . """" . A_Space . params, str, A_WorkingDir, int, 1)
ExitApp
}
}
RunAsAdmin()
F1::
Loop
{
; http://particle-clicker.web.cern.ch/particle-clicker/
WinGet, WinID, ID, Particle Clicker - Google Chrome
; Send keystrokes only if tab active and topmost, suspend if focus lost, continue when gain focue
; ControlSend, ahk_parent, {Space}, ahk_id %WinID%
; send clicks only if tab not mininised, if tab on background - force bring it to front
; ControlClick, x799 y449, ahk_id %WinID%
; same as above
; ControlClick, x799 y449, ahk_id %WinID%,,,,NA
; same as above
; Controlclick x799 y449,ahk_id %WinID%,,Left,1,NA
; same as above
PostClick(799,449,"Particle Clicker - Google Chrome")
sleep 1000
}
return
F12::ExitApp
#单实例
DetectHiddenWindows,在
#单实例力
#MaxThreadsPerHotkey,2
发送模式输入;推荐用于新脚本
SetControlDelay-1
后点击(x,y,win=“A”){
lParam:=x&0xFFFF |(y&0xFFFF)如果没有任何帮助,请尝试在ControlClick
之前和之后组合WinSet,Bottom
和WinShow
。如果没有任何帮助,请尝试在ControlClick
之前和之后组合WinSet,Bottom
和WinShow
。