Streaky77 Posted November 18, 2010 Share Posted November 18, 2010 Hi all :-) I can't send a left mouse click into a control (i've tried with white board of paint, and try to draw a Dot on screen) Opt("WinTitleMatchMode", 4) WinWait("Sans titre - Paint","UIRibbonDockTop") ControlClick("Sans titre - Paint","UIRibbonDockTop","Afx:d0000:81", "", "", 100, 100) Thanks a lot Link to comment Share on other sites More sharing options...
wakillon Posted November 18, 2010 Share Posted November 18, 2010 Hi all :-) I can't send a left mouse click into a control (i've tried with white board of paint, and try to draw a Dot on screen) Opt("WinTitleMatchMode", 4) WinWait("Sans titre - Paint","UIRibbonDockTop") ControlClick("Sans titre - Paint","UIRibbonDockTop","Afx:d0000:81", "", "", 100, 100) Thanks a lot Try to activate the window before with winactivate, see the helpfile AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Streaky77 Posted November 18, 2010 Author Share Posted November 18, 2010 Doesn't work Opt("WinTitleMatchMode", 4) WinWait("Sans titre - Paint","UIRibbonDockTop") WinActivate("Sans titre - Paint","UIRibbonDockTop") ControlClick("Sans titre - Paint","UIRibbonDockTop","Afx:d0000:81", "", "", 100, 100) Link to comment Share on other sites More sharing options...
wakillon Posted November 18, 2010 Share Posted November 18, 2010 you get your controlId by autoit window info ? what's type of control ? AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Tvern Posted November 18, 2010 Share Posted November 18, 2010 (edited) Take A look at this page.You need to specify what you are sending to identify the control. Is it a class, text, name etc.Also you seem to be using the CLASSNN, but I'm not sure that works when the classname ends with a number.Try something like this:Opt("WinTitleMatchMode", 4) Global $sAppIdentifyer = "[CLASS:MSPaintApp]" ;I think this is more consistent than the name. Global $sControlIdentifyer = "[CLASS:Afx:00000000FF6B0000:8; INSTANCE:1]" ;my control Class seems to be different from yours Global $hWnd = WinWait($sAppIdentifyer,"") ;use the handle once a matching window is found. WinActivate($hWnd) Sleep(1000) ControlClick($hWnd,"",$sControlIdentifyer, "left", "1", 100, 100)Edit: forgot to remane a variable consistently Edited November 18, 2010 by Tvern Link to comment Share on other sites More sharing options...
Bert Posted November 18, 2010 Share Posted November 18, 2010 Use the AutoIt Window Info tool and post it's results here so we can see what you are dealing with. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Streaky77 Posted November 18, 2010 Author Share Posted November 18, 2010 Take A look at this page. You need to specify what you are sending to identify the control. Is it a class, text, name etc. Also you seem to be using the CLASSNN, but I'm not sure that works when the classname ends with a number. Try something like this: Opt("WinTitleMatchMode", 4) Global $sAppIdentifyer = "[CLASS:MSPaintApp]" ;I think this is more consistent than the name. Global $sControlIdentifyer = "[CLASS:Afx:00000000FF6B0000:8; INSTANCE:1]" ;my control Class seems to be different from yours Global $hWnd = WinWait($sAppIdentifyer,"") ;use the handle once a matching window is found. WinActivate($hWnd) Sleep(1000) ControlClick($hWnd,"",$sControlIdentifyer, "left", "1", 100, 100) Edit: forgot to remane a variable consistently Thanks a lot. It perfectly works (with my control identifier) :-) Link to comment Share on other sites More sharing options...
Streaky77 Posted November 18, 2010 Author Share Posted November 18, 2010 Hum, just one question about class. Is it possible to create an autoIt program wich contain a common "Control identifier" ? I mean, anyway the CLASS:Afx014 or CLASS:Afx024, the program will work. maybe a method exist to get the control CLASS :/ Link to comment Share on other sites More sharing options...
Tvern Posted November 18, 2010 Share Posted November 18, 2010 Well you'll need something to identify the control you want to use with. A name, class, text, hidden text, instance, size, position etc. So find out what makes your control unique. (could be a combination of all of the above.) And try to write something to identify it's unique features. Link to comment Share on other sites More sharing options...
Streaky77 Posted November 18, 2010 Author Share Posted November 18, 2010 (I'm sorry, i take the opportunity you seems to be really better than french community about control) Really last question : Do you think it's possible to know if user has clicked in a control ? ex, To know if user has click into the white board of paint. thanks a lot :-) Link to comment Share on other sites More sharing options...
Tvern Posted November 19, 2010 Share Posted November 19, 2010 (edited) I can think of two ways to try to do this, but I'm not quite sure how to go about it.The first is to start monitoring for the right mouse button only when paint is the active window, then check the click coords.There was an example that would show the control under the mouse button a while ago which should help. I'll see if I can find it again.example (old, use the other one):#include <Misc.au3> Opt("WinTitleMatchMode", 4) Global $sAppIdentifyer = "[CLASS:MSPaintApp]" ;I think this is more consistent than the name. Global $sControlIdentifyer = "[CLASS:Afx:00000000FF6B0000:8; INSTANCE:1]" ;my control Class seems to be different from yours Global $dll = DllOpen("user32.dll") While 1 WinWaitActive($sAppIdentifyer,"") If _IsPressed("02",$dll) Then ;check if the click occured on the white board based on coords. ;i'll try to get back on this EndIf Sleep(10) WEndThe other, nicer way is if you could capture the event triggered by clicking the control. I think i've seen it done before, but I'm not sure how to do it. Perhaps someone will see this and explain though.gonna look for that other post now.Edit: Found it Edit2: Adjusted the WinWaitActive#include <Misc.au3> #include <WinAPI.au3> Opt("WinTitleMatchMode", 4) HotKeySet("{ESC}", "On_Exit") Global $sAppIdentifyer = "[CLASS:MSPaintApp]" Global $sControlClass = "Afx:00000000FF280000:8" ;don't forget to adjust! Global $sControlIdentifyer = "[CLASS:" & $sControlClass & "; INSTANCE:1]" Global $dll = DllOpen("user32.dll") Global $tPoint, $hWnd While 1 WinWaitActive($sAppIdentifyer,"") ;I found WinWaitActive() is a little slow to return, even if the window remains active, causing the script to miss clicks, if called often. ;This way it only gets called when the window goes inactive. While WinActive($sAppIdentifyer,"") If _IsPressed("02",$dll) Then $tPoint = DllStructCreate("int X;int Y") DllStructSetData ( $tPoint, "X", MouseGetPos(0)) DllStructSetData ( $tPoint, "Y", MouseGetPos(1)) $hWnd = _WinAPI_WindowFromPoint($tPoint) If _WinAPI_GetClassName($hWnd) = $sControlClass Then ConsoleWrite("Whiteboard right-clicked!" & @CRLF) While _IsPressed("02",$dll) Sleep(10) WEnd EndIf Sleep(10) WEnd WEnd Func On_Exit() Exit EndFuncAs you know a better way to identify the control must be found, as the class changes. You could reverse engineer the example to check the control present on a location you know to be the whiteboard, then get it's handle and use that. Edited November 19, 2010 by Tvern Link to comment Share on other sites More sharing options...
Streaky77 Posted November 19, 2010 Author Share Posted November 19, 2010 I make some test with the second script. It works good but the MouseGetPos() display the "screen coords position" and not the "control coords position" I'm currently trying to get the control mouse coords. thanks a lot Tvern Link to comment Share on other sites More sharing options...
Tvern Posted November 19, 2010 Share Posted November 19, 2010 Take a look at _WinAPI_GetMousePos, _WinAPI_GetMousePosX and _WinAPI_GetMousePosY. They allow you to get mouse posotions relevant to a window, or control. 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