tjyorkshire Posted August 22, 2008 Share Posted August 22, 2008 (edited) hey, im new here and to autoit coding. Im not a complete noob , i have had some previous experience with languages such as python. Currently, i am trying to write a movement control system for the MMORPG game rappelz. Basically, you are only able to move via mouse click on screen - you can't use keyboard keys. What i am trying to acheive is mouse click that are triggered by keyboard events. So far i have had some success in getting a keyboard press to trigger a mouse click on screen. However, due to hackshield (i think) that rappelz uses as an anti-hack measure i am finding it difficult to emulate mouse operations on screen. I cant use mouseclick, controlclick, mousedown, mouseup etc. I am currently only able to make a single click on screen using the MouseClickPlus function: 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 This works well for a single click on screen. However, i now need to do click and drag operations on screen. I was wondering, if anyone with more experience in DLL calls etc could help me to modyify this code in order to produce a mouse click and drag operation. I have done multiple searches and have not been able to find anything useful yet. Your help is greatly appreciated. Edited August 22, 2008 by tjyorkshire Link to comment Share on other sites More sharing options...
tjyorkshire Posted August 23, 2008 Author Share Posted August 23, 2008 no one has any ideas then? ill just have to fiddle around and hope i come up with something then Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 24, 2008 Moderators Share Posted August 24, 2008 no one has any ideas then?ill just have to fiddle around and hope i come up with something then You'll need to do another $WM_MOUSEMOVE after the BUTTONDOWN and before the BUTTONUP for the coords you want to drag to. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
tjyorkshire Posted August 24, 2008 Author Share Posted August 24, 2008 (edited) something like: 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", $WM_MOUSEMOVE, "int", 0, "long", _MakeLong($X, $Y)) DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($Window), "int", $ButtonUp, "int", $Button, "long", _MakeLong($X, $Y)) im trying it, it seems to be doing the right type of thing, however it seems to be affected by where the real mouse is positioned on screen. Its like both the emulated mouse and the real mouse are conflicting. Although i seem to be making a work-around using: DllCall("user32.dll", "int", "SetCursorPos", "int", $X, "int", $Y) It's all a bit cumbersome but i seem to be getting it working. Thanks Edited August 24, 2008 by tjyorkshire Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 24, 2008 Moderators Share Posted August 24, 2008 You need an $XStart, $YStart, and an XEnd and $YEnd for parameters. All you have is X (Start) and Y (Start), so you keep clicking the same spot over and over.expandcollapse popupFunc _MouseClickDragPlus($Window, $Button = "left", $X = 0, $Y = 0, $i_x_end = 0, $i_y_end = 0, $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 = 0 OR $Y = 0 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", $WM_MOUSEMOVE, "int", 0, "long", _MakeLong($i_x_end, $i_y_end)) DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($Window), "int", $ButtonUp, "int", $Button, "long", _MakeLong($X, $Y)) Next EndFuncSomething like that (Mind you, I've no idea if it will work)... I probably would have used PostMessage() for this function myself. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
oMBRa Posted August 24, 2008 Share Posted August 24, 2008 that script dont works for me at all I dunno what i wrong Link to comment Share on other sites More sharing options...
tjyorkshire Posted August 24, 2008 Author Share Posted August 24, 2008 You need an $XStart, $YStart, and an XEnd and $YEnd for parameters. All you have is X (Start) and Y (Start), so you keep clicking the same spot over and over. CODE: AutoIt Func _MouseClickDragPlus($Window, $Button = "left", $X = 0, $Y = 0, $i_x_end = 0, $i_y_end = 0, $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 = 0 OR $Y = 0 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", $WM_MOUSEMOVE, "int", 0, "long", _MakeLong($i_x_end, $i_y_end)) DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($Window), "int", $ButtonUp, "int", $Button, "long", _MakeLong($X, $Y)) Next EndFunc Something like that (Mind you, I've no idea if it will work)... I probably would have used PostMessage() for this function myself. yes, sorry, i didnt make it clear in my post - am am using a script similar to the one you have provided. It still seems as though the real mouse is interfering. It's strange seeing as i have never seen this SendMessage function used to control the mouse like this before. I would have normally done this via SendInput or one of the built in autoit functions, but this seems the only way to do it without HackShield blocking it. Link to comment Share on other sites More sharing options...
thang8843126 Posted December 12, 2013 Share Posted December 12, 2013 how to use your program? If I want to click 902, 402 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 12, 2013 Moderators Share Posted December 12, 2013 thang8843126,Welcome to the AutoIt forum. But did you notice that the last post in this thread dates from over 5 years ago? Please do not necro-post like this again - just start a new thread and add a link if you feel it is really necessary to do so. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts