Tahitijul Posted March 7, 2007 Share Posted March 7, 2007 Hello,I'm trying to use AutoIt, in order to automate the setup of an application.By using "Active Windows Info", I'd see that during the different stage of the setup, the main title of the windows doesn't change (so, i could'nt use WinWaitActive like i used to do).I'd decided to test the Control ID of some controls (ie "The InstallShield® Wizard will install ..." -> ControlID#:710), i'd tried by using GUICtrlRead & GUICtrlGetState but i couldn't get it work.I want to test the existence of a control ID, but i dont know which function i'm supposed to use. Can somebody help me ? Thanks Link to comment Share on other sites More sharing options...
dabus Posted March 7, 2007 Share Posted March 7, 2007 (edited) Err, I think this should be some sort of wintext, so WinWaitActive($Name, $Text) should do it... Give it a try. Or While 1 $Test=ControlCommand ( "title", "text", "controlID", "IsVisible", "" ) If $Test=1 Then ExitLoop Sleep (100) WEnd MsgBox(0, "It is visible now", "Gotcha") Edited March 7, 2007 by dabus Link to comment Share on other sites More sharing options...
SadBunny Posted March 7, 2007 Share Posted March 7, 2007 Hello,I'm trying to use AutoIt, in order to automate the setup of an application.By using "Active Windows Info", I'd see that during the different stage of the setup, the main title of the windows doesn't change (so, i could'nt use WinWaitActive like i used to do).I'd decided to test the Control ID of some controls (ie "The InstallShield® Wizard will install ..." -> ControlID#:710), i'd tried by using GUICtrlRead & GUICtrlGetState but i couldn't get it work.I want to test the existence of a control ID, but i dont know which function i'm supposed to use. Can somebody help me ? ThanksMaybe using ControlGetHandle, ControlGetText, ControlGetPos or something, repeatedly until @error = 0 (or return value is not ""). Since these functions should fail if the control is not accessible (for instance because it isn't there yet ) maybe this suits your purpose? Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
improbability_paradox Posted March 7, 2007 Share Posted March 7, 2007 (edited) Look up WinGetClassList(). This is an example which I think would work as a concept, but I am unable to test it right now. Func _ControlExists($WName, $CCName) local $WControls=stringsplit(WinGetClassList($WName),@LF) for $ICount = 1 to $WControls[0] if $WControls[$ICount]=$CCName then return 1 next return 0 EndFunc This Function should return 1 if the control is found, or 0 if it is not. Not that rather then checking for Control ID it is checking for ClassNameNN, which means that you will either need to pass that as the second parameter of the function, or change the function accordingly. Edited March 7, 2007 by improbability_paradox Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 7, 2007 Moderators Share Posted March 7, 2007 I've always used something like SadBunny has shown. If ControlGetHandle('Window', 'Control Text', 'Control ID') Then MsgBox(64, 'Info', 'Control Exists') Else MsgBox(16, 'Error', 'Control Does Not Exists') EndIf Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
DarthVega Posted March 7, 2007 Share Posted March 7, 2007 I've always used something like SadBunny has shown. If ControlGetHandle('Window', 'Control Text', 'Control ID') Then MsgBox(64, 'Info', 'Control Exists') Else MsgBox(16, 'Error', 'Control Does Not [s]Exists[/s] [b]Exist[/b]') EndIf Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 7, 2007 Moderators Share Posted March 7, 2007 Ha... see what I get for writing on the fly... Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Helge Posted March 7, 2007 Share Posted March 7, 2007 Ha... see what I get for writing on the fly...Control text...shouldn't that be window text ? Link to comment Share on other sites More sharing options...
SadBunny Posted March 7, 2007 Share Posted March 7, 2007 Control text...shouldn't that be window text ? Heheh... I'm sure Smoke will never ever write anything on the fly again... Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 7, 2007 Moderators Share Posted March 7, 2007 Heheh... I'm sure Smoke will never ever write anything on the fly again... Control text...shouldn't that be window text ? Um... No... It's Control text (Might want to check that one out for yourself ) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Helge Posted March 7, 2007 Share Posted March 7, 2007 (edited) In fact I did test that. If you're right then I don't understand the use of the 2nd parameter.The following code is working with the buttons in the Run-dialog. OK is the text of the...well, OK-button,while Button4 is the ID of the Browse-button. What button is clicked ? The Browse-button and not theOK-button. Why ? Because OK is a part of the window-text and Button4 is the ID for the Browse-button.ControlClick("Kjør", "OK", "Button4")Edit : If I'm wrong on this one I'll take that as a hint and head straight for bed Edited March 7, 2007 by Helge Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 7, 2007 Moderators Share Posted March 7, 2007 In fact I did test that. If you're right then I don't understand the use of the 2nd parameter. The following code is working with the buttons in the Run-dialog. OK is the text of the...well, OK-button, while Button4 is the ID of the Browse-button. What button is clicked ? The Browse-button and not the OK-button. Why ? Because OK is a part of the window-text and Button4 is the ID for the Browse-button. ControlClick("Kjør", "OK", "Button4") Edit : If I'm wrong on this one I'll take that as a hint and head straight for bed I've always used it this way personally, Control ID = 1 Text = '&OK' ClassNameNN = 'Something' ControlGetHandle($Win, '&OK', 'Something') I think very early on in my starting with AutoIt I found it didn't work with just 'Win Text', so I used the text that AutoInfo provided, and it always worked fine. Maybe you are right and I am wrong... you're example would prove me to be wrong of course, but I would have bet a bundle I wasn't. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
SadBunny Posted March 7, 2007 Share Posted March 7, 2007 Maybe you are right and I am wrong... you're example would prove me to be wrong of course, but I would have bet a bundle I wasn't.I should probably keep my mouth shut as a newcomer here, ESPECIALLY when pointing to the help of a function I have not used myself and even more when speaking to one of the most esteemed and active posters here... I know my place but I can't help it Anyway, look at the GontrolGetHandle help text:ControlGetHandle ( "title", "text", controlID)Parameterstitle The title of the window to access. text The text of the window to access. controlID The control to interact with. See Controls. Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
SadBunny Posted March 7, 2007 Share Posted March 7, 2007 Afterthought: to soothe the harshness of my near-blasphemic post just there, I will tell you that my first thought after looking this up in the help file and comparing it to Smoke's post was: "Gee, the help file must be wrong". To go short: after being on this forum for a couple of months, I learned to trust Smoke :-) (Btw, the next thing I thought was that since I had not tested let alone used this function was that I had to be not getting something due to newbiness...) Anyway, I'll go to bed myself now Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 7, 2007 Moderators Share Posted March 7, 2007 Afterthought: to soothe the harshness of my near-blasphemic post just there, I will tell you that my first thought after looking this up in the help file and comparing it to Smoke's post was: "Gee, the help file must be wrong". To go short: after being on this forum for a couple of months, I learned to trust Smoke :-)(Btw, the next thing I thought was that since I had not tested let alone used this function was that I had to be not getting something due to newbiness...)Anyway, I'll go to bed myself now No worries, If I'm right 20% of the time, that's good for me Anyway, you have to remember that the last time I probably read that thing was 2 years ago, that may or may not have been there.But to open everyones mind a bit... If you use the Control "Text" << wouldn't that also be a part of the "Win" text? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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