无法让 ControlGet 工作
Can't get ControlGet to work
这是我的脚本:
ControlGet, Output, Hwnd,,, ahk_id TV_REMOTEDESKTOP_CLASS1
MsgBox %Output%
PostClick(%Output%, 1170, 305, 10, 50)
PostClick(hwnd, X, Y, Count, Delay)
{
p := y << 16 | (x & 0xffff)
Loop, %Count% {
PostMessage, 0x201, 1, p, , ahk_id %hwnd%
If (Delay)
Sleep Delay
PostMessage, 0x202, 0, p, , ahk_id %hwnd%
If (Delay)
Sleep Delay
}
}
而且我无法让它工作!
我想让它在不 visible/without 移动鼠标的程序中点击 X Y 位置。
我可以使用 Click,但我必须打开该程序,并且它会在每次单击时移动鼠标。
PostClick 函数来自:http://www.autohotkey.com/board/topic/35742-postmessage-click-useful-hwnd-clicker/
我不确定该怎么做。
编辑:
ControlGet, chwnd, Hwnd,,, ahk_id TV_REMOTEDESKTOP_CLASS1
PostClick(chwnd, 1223, 395, 10, 50)
PostClick(hwnd, X, Y, Count, Delay)
{
p := y << 16 | (x & 0xffff)
Loop, %Count% {
PostMessage, 0x201, 1, p, , ahk_id %hwnd%
If (Delay)
Sleep Delay
PostMessage, 0x202, 0, p, , ahk_id %hwnd%
If (Delay)
Sleep Delay
}
}
是我的新代码。 (试过别人的剧本)
我的鼠标位置根据au3_spy:
活动中 Window:1223、395
屏幕上:1136、398
PostClick(%Output%, 1170, 305, 10, 50)
是错误的,因为这是一个表达式(它是一个函数调用,而不是命令)所以变量 Output
不需要 %
。
ahk_id TV_REMOTEDESKTOP_CLASS1
是错误的,指定的控件没有 ahk_id
并且在不同的位置,请参阅 ControlGet.
[ 的文档=37=]
默认使用 last found window,因此您需要指定要查找的 window,例如使用 ahk_class TV_CClientWindowClass
.
另请注意,根据文档,WM_LBUTTONDOWN 的 (0x201) 坐标是相对于接收消息的控件而言的。要计算相对坐标,请用单击点的绝对坐标减去 TV_REMOTEDESKTOP_CLASS1
控件的左上角坐标。例如,如果左上角是 (500,100),则 (1170,305) 将变为 (670,205)。
假设 (1170, 305) 坐标已经是相对的,正确的代码是:
DetectHiddenWindows, On
ControlGet, output, Hwnd, , TV_REMOTEDESKTOP_CLASS1, ahk_class TV_CClientWindowClass, TV_CClientToolBar
PostClick(output, 1170, 305, 10, 50)
这是我的脚本:
ControlGet, Output, Hwnd,,, ahk_id TV_REMOTEDESKTOP_CLASS1
MsgBox %Output%
PostClick(%Output%, 1170, 305, 10, 50)
PostClick(hwnd, X, Y, Count, Delay)
{
p := y << 16 | (x & 0xffff)
Loop, %Count% {
PostMessage, 0x201, 1, p, , ahk_id %hwnd%
If (Delay)
Sleep Delay
PostMessage, 0x202, 0, p, , ahk_id %hwnd%
If (Delay)
Sleep Delay
}
}
而且我无法让它工作! 我想让它在不 visible/without 移动鼠标的程序中点击 X Y 位置。
我可以使用 Click,但我必须打开该程序,并且它会在每次单击时移动鼠标。
PostClick 函数来自:http://www.autohotkey.com/board/topic/35742-postmessage-click-useful-hwnd-clicker/
我不确定该怎么做。
编辑:
ControlGet, chwnd, Hwnd,,, ahk_id TV_REMOTEDESKTOP_CLASS1
PostClick(chwnd, 1223, 395, 10, 50)
PostClick(hwnd, X, Y, Count, Delay)
{
p := y << 16 | (x & 0xffff)
Loop, %Count% {
PostMessage, 0x201, 1, p, , ahk_id %hwnd%
If (Delay)
Sleep Delay
PostMessage, 0x202, 0, p, , ahk_id %hwnd%
If (Delay)
Sleep Delay
}
}
是我的新代码。 (试过别人的剧本) 我的鼠标位置根据au3_spy:
活动中 Window:1223、395 屏幕上:1136、398
PostClick(%Output%, 1170, 305, 10, 50)
是错误的,因为这是一个表达式(它是一个函数调用,而不是命令)所以变量Output
不需要%
。
[ 的文档=37=]ahk_id TV_REMOTEDESKTOP_CLASS1
是错误的,指定的控件没有ahk_id
并且在不同的位置,请参阅 ControlGet.默认使用 last found window,因此您需要指定要查找的 window,例如使用
ahk_class TV_CClientWindowClass
.另请注意,根据文档,WM_LBUTTONDOWN 的 (0x201) 坐标是相对于接收消息的控件而言的。要计算相对坐标,请用单击点的绝对坐标减去
TV_REMOTEDESKTOP_CLASS1
控件的左上角坐标。例如,如果左上角是 (500,100),则 (1170,305) 将变为 (670,205)。
假设 (1170, 305) 坐标已经是相对的,正确的代码是:
DetectHiddenWindows, On
ControlGet, output, Hwnd, , TV_REMOTEDESKTOP_CLASS1, ahk_class TV_CClientWindowClass, TV_CClientToolBar
PostClick(output, 1170, 305, 10, 50)