LeXarT Posted October 2, 2009 Share Posted October 2, 2009 I have searched these forums for a view days now and the only example i can find doesn't work or need some tweaking. Basically i need a function/example on how to send a "mouseDown" and a "mouseUp" function call to a window that doesn't have focus(or even minimized)? I want to send mouse events to a specific window while i use my mouse on different tasks....Is that possible? It seems this function should work, but it doesn't(atleast for me it does nothing): expandcollapse popup;=============================================================================== ; ; Function Name: _MouseClickPlus() ; Version added: 0.1 ; Description: Sends a click to window ; 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) MsgBox(1, "", "112333") 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 ;==>_MouseClickPlus Func _MakeLong($LoWord, $HiWord) Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF)) EndFunc ;==>_MakeLong Regards, Lexart. Take it from this Quadriplegic, life is beautiful. Don't know what a quadriplegic is? Check out my short bio.Starting an online business. Link to comment Share on other sites More sharing options...
Yashied Posted October 2, 2009 Share Posted October 2, 2009 As I understand it, this function is written mainly for games where everything happens in its own window (with no controls). For the next example it should work. Try it.#Include <WinAPI.au3> Global Const $WM_LBUTTONDOWN = 0x0201 GUICreate('MyGUI', 400, 400) GUIRegisterMsg($WM_LBUTTONDOWN, 'WM_LBUTTONDOWN') GUISetState() Do Until GUIGetMsg() = -3 Func WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) Local $hDC = _WinAPI_GetDC($hWnd) For $i = -3 To 3 For $j = -3 To 3 DllCall('gdi32.dll', 'int', 'SetPixelV', 'hwnd', $hDC, 'int', _WinAPI_LoWord($lParam) + $i, 'int', _WinAPI_HiWord($lParam) + $j, 'dword', 0x0000FF) Next Next _WinAPI_ReleaseDC($hWnd, $hDC) Return 0 EndFunc ;==>WM_LBUTTONDOWNBut for the MS Paint (for example) that will not work. Here you should replaceWinGetHandle($Window)toControlGetHandle(WinGetHandle($Window), '', '[CLASS:Afx:1000000:8;INSTANCE:1]')Meaning understood? My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
LeXarT Posted October 2, 2009 Author Share Posted October 2, 2009 Thank you Yashied for the try....still doesn't help Take it from this Quadriplegic, life is beautiful. Don't know what a quadriplegic is? Check out my short bio.Starting an online business. Link to comment Share on other sites More sharing options...
Yashied Posted October 2, 2009 Share Posted October 2, 2009 Thank you Yashied for the try....still doesn't helpIn which window you want to click? Post screenshot of it. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
LeXarT Posted October 2, 2009 Author Share Posted October 2, 2009 In which window you want to click? Post screenshot of it.Actually it is for a game....I'm trying to automate walking in the game by holding the middle-mouse button and panning left or right. While that is taking place i want the mouse free to let me do other tasks. I need some sort of way of sending mouse calls to an inactive window in the same way as you can send keys to it(like Autohotkey).regards. Take it from this Quadriplegic, life is beautiful. Don't know what a quadriplegic is? Check out my short bio.Starting an online business. 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