Zohar Posted January 28, 2009 Share Posted January 28, 2009 (edited) HelloI have a certain window that I would like to Click in some location, but without activating the window for it.The Documentations says that I should use ControlClick instead of MouseClick,however there is a problem:This window for some reason, appears not to have any controls on it.or atleast that's what AutoIt Window Info tool shows.So there's no control on that form that I can specify,however I do know the exact (X,Y) location within that form that I would like to click.What can I do?I attached a screenshots of what AutoIt's Window Info tool shows regarding that form. Edited March 2, 2009 by Zohar Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 28, 2009 Share Posted January 28, 2009 Hello I have a certain window that I would like to Click in some location, but without activating the window for it. The Documentations says that I should use ControlClick instead of MouseClick, however there is a problem: This window for some reason, appears not to have any controls on it. or atleast that's what AutoIt Window Info tool shows. So there's no control on that form that I can specify, however I do know the exact (X,Y) location within that form that I would like to click. What can I do? I attached a screenshots of what AutoIt's Window Info tool shows regarding that form. I believe ControlClick() can be used without identifying the control. The X/Y coordinates become window client area relative. Something like this: $hWin = WinGetHandle("[CLASS:#32770; TITLE:Magic Tune Premium]") ControlClick($hWin, "", "", "Left", 1, 123, 234) Don't have time to test right now and make sure. Post your results if you try it. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Zohar Posted January 28, 2009 Author Share Posted January 28, 2009 Hi PsaltyDS I tried that, leaving the ControlID empty, and it did not do anything. I tried supplying "", and even 0. both did not help. (and I supplied a window relative X,Y point) here it is: ControlClick($hWin,"","","left",1,203,283) isn't there some trick? maybe faking a Windows Message somehow? Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 28, 2009 Share Posted January 28, 2009 Hi PsaltyDSI tried that, leaving the ControlID empty, and it did not do anything.I tried supplying "", and even 0.both did not help.(and I supplied a window relative X,Y point)here it is:ControlClick($hWin,"","","left",1,203,283)isn't there some trick?maybe faking a Windows Message somehow?That's exactly whay ControlClick() does, but you have to specify where to send that message. Is that handle shown in your screenshot different from the window's handle? There is a DLL call to WindowFromPoint (search for SmOke_N posts on it) that can get the handle to a control, but only if visible on the screen I think. If you can get that control handle by position or any other trick then you are set. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Zohar Posted January 28, 2009 Author Share Posted January 28, 2009 That's exactly whay ControlClick() does, but you have to specify where to send that message.I can only specify a Window Handle, not a cOntrol Handle, since there's no Control Is that handle shown in your screenshot different from the window's handle? There is a DLL call to WindowFromPoint (search for SmOke_N posts on it) that can get the handle to a control, but only if visible on the screen I think. If you can get that control handle by position or any other trick then you are set. The Handle that you see in the screenshot, is aparantly a small bug in the Window Info tool: when the Window Info tool is pointing on a window [that appears to be] with no controls, it doesnot clear the Control Handle from last control. so what you actually see there is a handle to IE's control:)) I can only get a Window Handle. And would really like to send a LeftClick to that window, without having to Activate it first:) Link to comment Share on other sites More sharing options...
Zohar Posted January 28, 2009 Author Share Posted January 28, 2009 (edited) OK I Found a Solution.The Solution I found is not using MouseClick since MouseClick requires the Window to be above other windows,and it also isn't using ControlClick since ControlClick requires a ControlID, which is kinna hard to supply when the window doesn't show any controls.The solution, as I estimated would be to use SendMessage().and apparantly a guy named Insolence wrote a function for that, called MouseClickPlus.and It, finally, enables you to CLICK an inactive window, even when the window has no controls. CODE;===============================================================================;; 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) 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)) NextEndFuncFunc _MakeLong($LoWord,$HiWord) Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))EndFuncMake sure to supply X,Y that are relative to the Window(and not absolute screen coordinates). Edited January 28, 2009 by Zohar Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 28, 2009 Share Posted January 28, 2009 OK I Found a Solution. The Solution I found is not using MouseClick since MouseClick requires the Window to be above other windows, and it also isn't using ControlClick since ControlClick requires a ControlID, which is kinna hard to supply when the window doesn't show any controls. The solution, as I estimated would be to use SendMessage(). and apparantly a guy named Insolence wrote a function for that, called MouseClickPlus. and It, finally, enables you to CLICK an inactive window, even when the window has no controls. CODE;=============================================================================== ; ; 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) 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 Make sure to supply X,Y that are relative to the Window(and not absolute screen coordinates). Well, that's exactly the behavior I expected from ControlClick() with no ControlID. Glad you found a solution. aeronLong 1 Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Storm Posted February 1, 2009 Share Posted February 1, 2009 ControlClick() with no ControlID just doesent work with most games.Anyway, I tried this and I cannot get it to work.I tried on Ragnarok Online. And I tried on MsPain.But nothing happens. I tried to modify it a bit thinking maybe I wasent using it properly, but again no result.Can you please help me with this?http://www.autoitscript.com/forum/index.php?showtopic=88427 Link to comment Share on other sites More sharing options...
AzKay Posted February 1, 2009 Share Posted February 1, 2009 ControlClick() with no ControlID just doesent work with most games.Anyway, I tried this and I cannot get it to work.I tried on Ragnarok Online. And I tried on MsPain.But nothing happens. I tried to modify it a bit thinking maybe I wasent using it properly, but again no result.Can you please help me with this?http://www.autoitscript.com/forum/index.php?showtopic=88427Ive yet to get any of them working in RO ;3 # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
Storm Posted February 2, 2009 Share Posted February 2, 2009 I play on a private server. So there is no game guard. Normal autoit bots I made work just fine in XP at least, they dont work in Vista. But the command ControlClickPlus wont work for me. Not just RO, it wont work on MsPaint as well. If it just worked outside the game, I would just assume that the scrip doesn't work with that game and move on to find a workaround or ditch the idea. But the thing is the scrip doesn't work at all.So I would really appreciate it if someone who has got this working can give me an example so I can try to go from there. Link to comment Share on other sites More sharing options...
Jinchuuriki Posted February 2, 2009 Share Posted February 2, 2009 Hi, i made mouseclickplus work before but now i have vista and it doesn't work '-' anyway here is the code i used with cabal =D verry good xtrap didnt get it so if anyone can get it to work again just tell me! im trying to contact Insolence expandcollapse popupSleep(3000) For $i = 0 To 10 Step 1 _MouseClickPlus("Cabal", "left", 232, 117) Sleep(1000) Next ;=============================================================================== ; ; 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 Link to comment Share on other sites More sharing options...
AzKay Posted February 2, 2009 Share Posted February 2, 2009 I play on a private server. So there is no game guard.Normal autoit bots I made work just fine in XP at least, they dont work in Vista. But the command ControlClickPlus wont work for me. Not just RO, it wont work on MsPaint as well.If it just worked outside the game, I would just assume that the scrip doesn't work with that game and move on to find a workaround or ditch the idea. But the thing is the scrip doesn't work at all.So I would really appreciate it if someone who has got this working can give me an example so I can try to go from there.I was refering to RebirthRO. # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
ElijaH Posted May 7, 2009 Share Posted May 7, 2009 I have somehow the same problem i have this script im working on. this scripts function is to toggle a key on the virtual keyboard im using. i just want it to click the virtual keyboard keys. can someone help me? here's my script hope you can find what is wrong and make a suggestion. thank you ______________________________________________ While $UnPaused WinActivate("On-Screen Keyboard") WinActive ("On-Screen Keyboard") ControlClick( "On-Screen Keyboard", "@", "N19" ) ControlClick( "On-Screen Keyboard", "#", "N20" ) ControlClick( "On-Screen Keyboard", "$", "N21" ) ControlClick( "On-Screen Keyboard", "%", "N22" ) ControlClick( "On-Screen Keyboard", "^", "N23" ) ControlClick( "On-Screen Keyboard", "&", "N24" ) ControlClick( "On-Screen Keyboard", "*", "N25" ) WEnd EndFunc ________________________________________________ hoping for your soon replies Link to comment Share on other sites More sharing options...
BigDod Posted May 7, 2009 Share Posted May 7, 2009 Tagging on to someone elses topic is not the way to get help especially when they have marked it as solved. You should stick to your own topic and wait to see if anyone is willing to help. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother 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