Kray Posted August 21, 2013 Share Posted August 21, 2013 (edited) expandcollapse popup;=============================================================================== ; ; 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 Hi, my name is Kray and I am new to these forums and to AutoIt programming. I'm trying to understand utilize the above user provided function that I found through Google. I understand and get the gist of what its supposed to do, but what do the 0x001 numbers on the Local variables mean? Also this function came with the end function of MakeLong. Is that to simulate mouse dragging? Finally, how do you call this function? I used the help file as a reference and called the func before I included it at the bottom like so: AutoItSetOption("MouseCoordMode", 2) Call ( "_MouseClickPlus" ["homefrs-iphone.local - TightVNC Viewer"], ["left"], ["198" & "236"], [1])) That didn't work so I tried calling it this way: Call ( "_MouseClickPlus" [$Window = "homefrs-iphone.local - TightVNC Viewer"], [$Button = "left"], [$X = "198" & $Y = "236"])) Still didn't work. Any help would be greatly appreciated. I looked in the FAQs and did not see anything pertaining to this. Edited August 21, 2013 by Kray Link to comment Share on other sites More sharing options...
kylomas Posted August 21, 2013 Share Posted August 21, 2013 (edited) Hi Kray - Welcome to AutoIT. but what do the 0x001 numbers on the Local variables mean This just assigns a value to a variable came with the end function of MakeLong. Is that to simulate mouse dragging? No, this is used to format values for parameters to DLLCALL's for "SendMessage". Finally, how do you call this function? Like "_MouseClickPlus('my window')" Also, read the header of the function. It says that you must use "MouseCoordMode" 0 kylomas edit: example of calling a function ; *** Start added by AutoIt3Wrapper *** #include <GUIConstantsEx.au3> ; *** End added by AutoIt3Wrapper *** #AutoIt3Wrapper_Add_Constants=n local $gui010 = guicreate('test',200,100) local $btn010 = guictrlcreatebutton('Click Me!!',50,50,100,20) guisetstate() while 1 switch guigetmsg() case $gui_event_close Exit case $btn010 _MyFunction() EndSwitch WEnd func _MyFunction() ConsoleWrite('I just got called' & @LF) endfunc Edited August 21, 2013 by 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 Link to comment Share on other sites More sharing options...
Kray Posted August 21, 2013 Author Share Posted August 21, 2013 (edited) Thank you for the warm welcome.I get an error on Line 25 that says: Call"_MouseClickPlus('TightVNC Viewer'),'left','198','236','1')" ^ERROR Error: Error parsing function call.I got it to work, but not really. Edited August 21, 2013 by Kray Link to comment Share on other sites More sharing options...
NewPlaza Posted August 21, 2013 Share Posted August 21, 2013 Try this Call( _MouseClickPlus('TightVNC Viewer','left','198','236','1')) or this _MouseClickPlus('TightVNC Viewer','left','198','236','1') Link to comment Share on other sites More sharing options...
Kray Posted August 21, 2013 Author Share Posted August 21, 2013 (edited) I got it. However, the function does not work. I can't understand why. I'm looking at different threads to see if I can find more information. I changed the MouseCoordMode to 0 and it still doesn't work. Edited August 21, 2013 by Kray Link to comment Share on other sites More sharing options...
kylomas Posted August 21, 2013 Share Posted August 21, 2013 (edited) Kray, Perhaps you should find another way to do this. See >this post. kylomas Edited August 21, 2013 by 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 Link to comment Share on other sites More sharing options...
Kray Posted August 21, 2013 Author Share Posted August 21, 2013 I have the Control Handle. Can I send a click by that? If so how? Link to comment Share on other sites More sharing options...
Solution kylomas Posted August 21, 2013 Solution Share Posted August 21, 2013 I have the Control Handle. Can I send a click by that? If so how? Start reading the Help file. Particularly "controlclick"... 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 Link to comment Share on other sites More sharing options...
Kray Posted August 21, 2013 Author Share Posted August 21, 2013 Thank you all for your help. I will take your advice and read the help file. Link to comment Share on other sites More sharing options...
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