jamsito Posted October 25, 2017 Posted October 25, 2017 Hi guys, I'm new here but I've been reading this forum for a while now. I'm writing a simple code that should click on a button. The process is: Open a control Window Click on a tab Click on another tab inside the previous one Click on the button The problem is that I can't get the info (ID, instance or handle) of these two tabs, since the whole tab bar is the same control (at least that's what Autoit Info says). I've got the ID of the main control (the pop up window) and also of the button itself, and I tried using "ControlClick" directly on the button, but it doesn't work, so I assume I need to click on the specific tabs first. I know I could do this by pointing with the mouse or using the TAB key, but I don't want to do so because the script will be used on different computers with different configurations. Attached you can find some screenshots to help you understand my problem. I would really appreciate your help, since I've been looking for an answer for a long time now. Thank you very much and sorry for my english
Earthshine Posted October 25, 2017 Posted October 25, 2017 so, the tabs may be done in software mate. it's most likely a TabStrip control. https://msdn.microsoft.com/en-us/library/aa443489(v=vs.60).aspx Can you try just sending TAB keys to get to the one that hosts your control? like: Send('{TAB}') Send('{TAB}') Then use: ControlClick('[CLASS:#32770]', 'Options', '[CLASS:Button; INSTANCE:16]') My resources are limited. You must ask the right questions
jamsito Posted October 26, 2017 Author Posted October 26, 2017 17 hours ago, Earthshine said: so, the tabs may be done in software mate. it's most likely a TabStrip control. https://msdn.microsoft.com/en-us/library/aa443489(v=vs.60).aspx Can you try just sending TAB keys to get to the one that hosts your control? like: Send('{TAB}') Send('{TAB}') Then use: ControlClick('[CLASS:#32770]', 'Options', '[CLASS:Button; INSTANCE:16]') Thanks for your answer! I've done what you said, and now I am on the desired tab (attached picture), but still can't click on the button. First I tried this: Opt("WinTitleMatchMode",2) WinActivate("CATIA") Send("!{t}"&"{o}") $options="[CLASS:#32770]" WinWaitActive($options) Send("{TAB 7}"&"{RIGHT}"&"{TAB 6}"&"{RIGHT}") ControlClick($options,"", "[CLASS:Button; INSTANCE:46]") It opens the right tab, then does nothing. Then I tried focusing on the "square" that contains the button first: Opt("WinTitleMatchMode",2) WinActivate("CATIA") Send("!{t}"&"{o}") $options="[CLASS:#32770]" WinWaitActive($options) Send("{TAB 7}"&"{RIGHT}"&"{TAB 6}"&"{RIGHT}") $square="[CLASS:Afx:0000000140000000:0:0000000000010003:0000000000000000:0000000000000000; INSTANCE:9]" $button="[CLASS:Button; INSTANCE:46]" ControlFocus($options,"", $square) ControlClick($square,"", $button) Aaaand nothing happened again. I think I don't really get how these controls inside other controls work... the window (that is already a control) contains multiple controls, so I'm not sure wether I can click directly on the button or I should first "focus" on the right control. Also, which control would be the right one? Anyways, nothing works so I'm totally lost.
Earthshine Posted October 26, 2017 Posted October 26, 2017 (edited) Sorry, I think I typed it wrong! ControlClick('[CLASS:#32770]', 'CTA5 - ENOVIA Collaborative Design for CATIA V5 Not Granted', '[CLASS:Button; INSTANCE:16]') If that does not work try this ControlClick('[CLASS:#32770]', '', '[CLASS:Button; INSTANCE:16]') If that doesn't work: If you can get access to Visual Studio 2015 to 2017 Enterprise edition, you could use Coded UI projects and record reliable tests in any .NET language you wanted. That's what I had to do in the end. Now I can automate test everything from VB6 to WPF Form apps (all new Windows apps are WPF, XML forms with controls drawn on them) Edited October 26, 2017 by Earthshine My resources are limited. You must ask the right questions
Earthshine Posted October 26, 2017 Posted October 26, 2017 (edited) If the above doesn't work, can you try something like this to poke the button? #include<Array.au3> ;~ OPT("WinTitleMatchMode",2) $a = WinList("Options") ;~ uncomment line below to look at what you find, name and handle of desired control ;~ _ArrayDisplay($A) ConsoleWrite(UBound($A)& @CRLF) FOR $N = 1 to $A[0][0] $hActiveWindow = WinGetHandle("") WinActivate($a[$N][1]) ;comment if using controlfocus ;~ ControlFocus($a[$N][1],"","") ;comment if using winactivate; ControlSend($a[$N][1],"CTA5 - ENOVIA Collaborative Design for CATIA V5 Not Granted","","{ENTER}") WinActivate($hActiveWindow) Next The above code was found here: in this case used to log onto an RDP client that is locked. https://stackoverflow.com/questions/26505329/autoit-controlsend-remote-desktop Edited October 26, 2017 by Earthshine My resources are limited. You must ask the right questions
jamsito Posted October 27, 2017 Author Posted October 27, 2017 16 hours ago, Earthshine said: If the above doesn't work, can you try something like this to poke the button? #include<Array.au3> ;~ OPT("WinTitleMatchMode",2) $a = WinList("Options") ;~ uncomment line below to look at what you find, name and handle of desired control ;~ _ArrayDisplay($A) ConsoleWrite(UBound($A)& @CRLF) FOR $N = 1 to $A[0][0] $hActiveWindow = WinGetHandle("") WinActivate($a[$N][1]) ;comment if using controlfocus ;~ ControlFocus($a[$N][1],"","") ;comment if using winactivate; ControlSend($a[$N][1],"CTA5 - ENOVIA Collaborative Design for CATIA V5 Not Granted","","{ENTER}") WinActivate($hActiveWindow) Next The above code was found here: in this case used to log onto an RDP client that is locked. https://stackoverflow.com/questions/26505329/autoit-controlsend-remote-desktop Thanks again for your help @Earthshine, but none of this has worked. I'm going to try the primitive way (using the mouse) and adapting the code to the different resolutions...
Earthshine Posted October 27, 2017 Posted October 27, 2017 (edited) you may have to modify that example code. uncomment out the the ArrayDisplay line to see what's in the array and make sure we have what we are looking for. Sorry mate. Edited October 27, 2017 by Earthshine My resources are limited. You must ask the right questions
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