在最小化窗口中自动发送SendMessage和Imagesearch

时间:2016-11-06 04:10:12

标签: autoit

我有这个代码将鼠标操作发送到非活动窗口,但我不知道它为什么不起作用,并且它没有给出任何错误。包含部分是<>我删除了它们。在这个例子中,我想在绘画中画一条线。 我还需要一个dll或au3文件,用于最小化窗口中的图像搜索。我搜索了整个网,但找不到有效的网。 感谢您的帮助。

include SendMessage.au3    
Include WinAPI.au3    
Global $wHandle = "Untitled - Paint"    
ControlClickDrag($wHandle,"left",300,300,100,80)    
Func ControlClickDrag($wHandle, $Button="left", $X1="", $Y1="", $X2="", $Y2="")
    Local $MK_LBUTTON = 0x0001    
Local $WM_LBUTTONDOWN = 0x0201    
Local $WM_LBUTTONUP = 0x0202    
Local $MK_RBUTTON = 0x0002    
Local $WM_RBUTTONDOWN = 0x0204    
Local $WM_RBUTTONUP = 0x0205    
Local $WM_MOUSEMOVE = 0x0200    
Local $i = 0    
Select    
Case $Button = "left"    
$Button = $MK_LBUTTON    
$ButtonDown = $WM_LBUTTONDOWN    
$ButtonUp = $WM_LBUTTONUP    
Case $Button = "right"    
$Button = $MK_RBUTTON    
$ButtonDown = $WM_RBUTTONDOWN    
$ButtonUp = $WM_RBUTTONUP    
EndSelect    
DllCall("user32.dll", "int", "SendMessage", "hwnd", $wHandle, "int", $ButtonDown, "int", $Button, "long", _MakeLong($X1, $Y1))    
DllCall("user32.dll", "int", "SendMessage", "hwnd", $wHandle, "int", $ButtonUp, "int", $Button, "long", _MakeLong($X2, $Y2))    
EndFunc    
Func _MakeLong($LoWord,$HiWord)    
Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))    
EndFunc

1 个答案:

答案 0 :(得分:0)

全球$ wHandle =“Untitled - Paint”

这不是一个句柄。这只是一个字符串。

替换为:

Global $wHandle =   ControlGetHandle("Untitled - Paint", "",[CLASS:Afx:00007FF7B1BD0000:8; INSTANCE:1]")

您可以使用Au3Info.exe获取为其他程序执行此操作所需的信息。