curtis6540 Posted March 8, 2011 Posted March 8, 2011 Hello, I'm trying to get a script that will click in a window even when its minimized. This is the script I have and it works, but now I would like to modify it to use handles rather than the title name. I want to do this because I plan on running multiple instances of the same program with the same window name. I used a different script and found the handle to be 0x00000000002005B8. My question is how would I use this number in the script. I should mention I have no knowledge of programming, I pieced together this script from what I found on the web. expandcollapse popupAutoItSetOption("MouseCoordMode", 0) ;=============================================================================== ; ; Function Name: _MouseClickPlus() ; Version added: 0.1 ; Description: Sends a click to window, not entirely accurate, but works ; minimized. ; Parameter(s): $Window = Title of the window to send click to ; $Button = "left" or "right" mouse button ; $X = X coordinate ; $Y = Y coordinate ; $Clicks = Number of clicks to send ; Remarks: You MUST be in "MouseCoordMode" 0 to use this without bugs. ; Author(s): Insolence <insolence_9@yahoo.com> ; ;=============================================================================== Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1) 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 If $X = "" OR $Y = "" Then $MouseCoord = MouseGetPos() $X = $MouseCoord[0] $Y = $MouseCoord[1] EndIf For $i = 1 to $Clicks DllCall("user32.dll", "int", "SendMessage", _ "hwnd", WinGetHandle( $Window ), _ "int", $WM_MOUSEMOVE, _ "int", 0, _ "long", _MakeLong($X, $Y)) DllCall("user32.dll", "int", "SendMessage", _ "hwnd", WinGetHandle( $Window ), _ "int", $ButtonDown, _ "int", $Button, _ "long", _MakeLong($X, $Y)) DllCall("user32.dll", "int", "SendMessage", _ "hwnd", WinGetHandle( $Window ), _ "int", $ButtonUp, _ "int", $Button, _ "long", _MakeLong($X, $Y)) Next EndFunc Func _MakeLong($LoWord,$HiWord) Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF)) EndFunc $WinTitle ='TITLE' While 1 If WinExists($WinTitle) Then _MouseClickPlus( "TITLE", "left", "200", "200" ) $rndnumber = random(142, 364) sleep($rndnumber) _MouseClickPlus( "TITLE", "right", "200", "200" ) $rndnumber = random(140, 364) sleep($rndnumber) Else MsgBox(0, "No Program Running!!", "Can't find TITLE Window!"&@CRLF&"Launch the program.", "", "") Exit EndIf WEnd
kylomas Posted March 8, 2011 Posted March 8, 2011 curtis6540, Reference this thread -> kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
curtis6540 Posted March 8, 2011 Author Posted March 8, 2011 Thank you for the reply, it has helped me figure out what to do.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now