MuffettsMan Posted January 18, 2008 Posted January 18, 2008 Is it simply not possiible to ControlClick mouseclicks to windows that don't have any control info (per the win info tool) i guess i should count my blessings because for some amazing reason ControlSend works just fine however i can't get ControlClick to work using the same logic...so the real question is if its possible to ControlSend does that mean click should be possible as well or is using controlclick more touchy?Win Info tool ouput is as follows:>>>> Window <<<<Title: World of WarcraftClass: GxWindowClassD3dPosition: 0, 0Size: 1280, 800Style: 0x94000000ExStyle: 0x00040000Handle: 0x002607DA>>>> Control <<<<Class: Instance: ClassnameNN: ID: Text: Position: Size: ControlClick Coords: Style: ExStyle: Handle: 0x0001008Amost alarming there is not controlclick cords noted when moving within the window... however it does work perfectly with controlsend.... using logic like:$WoWClient2 = WinList ("World of Warcraft") ControlSend ($WoWClient2[1][1],"","","{w Down}")i guess i just don't want to give up hope on controlclick going back to manually clicking on each window would be so.... crude Don't let that status fool you, I am no advanced memeber!
nairada Posted January 18, 2008 Posted January 18, 2008 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 Have you seen/tried this before?
MuffettsMan Posted January 18, 2008 Author Posted January 18, 2008 thanks nairada looks promising - i can't use just window title alone because there are 4 windows with the exact same name that i'm trying to send to... though from my limited exp it seems that you often can use the HWND instead of the title and that would be unique enough. got a 2yr old crawling all over me atm so can't test but it at least gives me more hope! thanks again. Don't let that status fool you, I am no advanced memeber!
MuffettsMan Posted January 19, 2008 Author Posted January 19, 2008 something like this? if so no dice expandcollapse popup#include <Array.au3> Global $WoWClient2[3][3] ; Sets the way coords are used in the mouse functions, ; either absolute coords or coords relative to the current active window: ; 0 = relative coords to the active window Opt("MouseCoordMode", 0) ;1=absolute, 0=relative, 2=client Run("C:\Program Files\WoW\Wow.exe") sleep(10000) dim $Clicks dim $X dim $Y dim $Window dim $Button $WoWClient2 = WinList ("World of Warcraft") $Window = "World of Warcraft" $Button = "left" $X = "650" $Y = "560" $Clicks = 1 ; 650 , 560 ControlSend ($WoWClient2[1][1],"","","ds9872") _MouseClickPlus($Window, $Button, $X, $Y, $Clicks) ;=============================================================================== ; ; 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, $X, $Y, $Clicks) 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 Don't let that status fool you, I am no advanced memeber!
brad3260 Posted March 21, 2014 Posted March 21, 2014 any idea how to make this work with a Windows 8 app?
BrewManNH Posted March 22, 2014 Posted March 22, 2014 (edited) any idea how to make this work with a Windows 8 app? I doubt that after 6 years anyone in this thread would be able to answer that. Not to mention, Windows 8 wasn't even being developed that long ago. Edited March 22, 2014 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
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