I have this code to send mouse actions to an inactive window, but I don't know why it's not working, and it doesn't give any error. Include part is with <> which I removed them. In this example I want to draw a line in paint. I also need a dll or au3 file for imagesearch in minimized windows. I searched whole net, but couldn't find one that works. I appreciate your help.
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
Global $wHandle = "Untitled - Paint"
This isn't a handle. It's just a string.
Replace it with this:
Global $wHandle = ControlGetHandle("Untitled - Paint", "",[CLASS:Afx:00007FF7B1BD0000:8; INSTANCE:1]")
You can use Au3Info.exe to get the necessary information to do this for other programs.