2015-09-20 128 views
0

这里是我的脚本:无法获得ControlGet工作

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 
    } 
} 

我不能得到它的工作! 我想让它点击X Y pos,在一个不可见/没有移动鼠标的程序中。

我可以使用点击,但我不得不打开程序,它会移动鼠标到每次点击。 http://www.autohotkey.com/board/topic/35742-postmessage-click-useful-hwnd-clicker/

我不确定如何做到这一点:从

PostClick功能。

编辑:

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:

在活动窗口:1223,395 屏幕:1136,398

回答

1
  1. PostClick(%Output%, 1170, 305, 10, 50)是错误的,因为这是一个表达式(这是一个功能呼叫,而不是一个命令),所以变量Output不需要%

  2. ahk_id TV_REMOTEDESKTOP_CLASS1是错误的,则控制在不ahk_id指定并在不同的位置,请参阅文档ControlGet

  3. 默认情况下,使用last found window,因此您需要指定要查找的窗口,例如使用ahk_class TV_CClientWindowClass

  4. 另请注意,根据文档,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) 
+0

您好。我编辑了我的帖子,并添加了一些。 – prk

+0

我如何获得顶角坐标等。 – prk

+0

可能是控制大声笑。因为在“窗口标题和类”下,ahk_class是TV_CClientWindowClass - ClassNN是REMOTEDESKTOP thingy。 – prk