simpleraison Posted December 3, 2010 Share Posted December 3, 2010 Hey guys is there any code which will help me check either if a button comes out of being greyed out whilst doing a process before continuing with the remaining commands? I could do it vice versa on the other hand and wait for a button to become not active before proceeding too! Thanks guys. :-) Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 3, 2010 Share Posted December 3, 2010 (edited) GuiCtrlGetState() See help file. Edit: As Zedna said, ControlCommand() makes more sense if it's not your own script's GUI. Edited December 3, 2010 by PsaltyDS 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...
Zedna Posted December 3, 2010 Share Posted December 3, 2010 (edited) If button is in other application then use ControlCommand() with 'IsEnabled' command Edited December 3, 2010 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
simpleraison Posted December 3, 2010 Author Share Posted December 3, 2010 If button is in other application then use ControlCommand() with 'IsEnabled' command Dude here is the code i am currently using but it seems as if it doesnt do anything?? :-( $isvisible = ControlCommand ( "Slow Commenter", "", "[CLASS:Button; INSTANCE:2]", "IsEnabled") WinWaitActive($isvisible, "", 1000000000000000000000000000) Link to comment Share on other sites More sharing options...
simpleraison Posted December 3, 2010 Author Share Posted December 3, 2010 GuiCtrlGetState()See help file.Dude considering the code i posted above how could i implement GuiCtrlGetState() into it? Sorry im real new to AutoIT! And so far only used primitive functions not delved into anything to deep! :-) Link to comment Share on other sites More sharing options...
Zedna Posted December 3, 2010 Share Posted December 3, 2010 Dude here is the code i am currently using but it seems as if it doesnt do anything?? :-( $isvisible = ControlCommand ( "Slow Commenter", "", "[CLASS:Button; INSTANCE:2]", "IsEnabled") WinWaitActive($isvisible, "", 1000000000000000000000000000) While ControlCommand("Slow Commenter", "", "Button2","IsEnabled","") = 0 Sleep(50) WEnd MsgBox(0,'','Now it is enabled.') Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
simpleraison Posted December 3, 2010 Author Share Posted December 3, 2010 While ControlCommand("Slow Commenter", "", "Button2","IsEnabled","") = 0 Sleep(50) WEnd MsgBox(0,'','Now it is enabled.') Zedna this is the code i just tried but no joy at all, any more ideas! :-( While ControlCommand("Slow Commenter", "", "[CLASS:Button2; INSTANCE:2]", "IsEnabled","") = 0 Sleep(50) WEnd MsgBox(0,'','Now it is enabled.') Link to comment Share on other sites More sharing options...
Varian Posted December 3, 2010 Share Posted December 3, 2010 I think the code should be"[CLASS:Button; INSTANCE:2]"or"Button2"Also, I think that the final MsgBox should be on the line after the WEnd statement.You can also try thisWhile 1 Select Case Not WinExists("Slow Commenter", "") _Status("ERROR", "Window 'Slow Commenter' is not Visible", 2) Case Not ControlCommand("Slow Commenter", "", "[CLASS:Button; INSTANCE:2]", "IsVisible", "") _Status("ERROR", "Button2 is not Visible", 2) Case ControlCommand("Slow Commenter", "", "[CLASS:Button; INSTANCE:2]", "IsEnabled", "") _Status("Success", "Button2 is Enabled" & @LF & "Button2 is named " & ControlGetText("Slow Commenter", "", "[CLASS:Button; INSTANCE:2]")) Exit Case Not ControlCommand("Slow Commenter", "", "[CLASS:Button; INSTANCE:2]", "IsEnabled", "") _Status("ERROR", "Button2 is not enabled yet", 2) EndSelect WEnd Func _Status($Title = "", $Text = "", $TimeOut = 0) MsgBox(0, $Title, $Text, $TimeOut) EndFunc ;==>_Status Link to comment Share on other sites More sharing options...
simpleraison Posted December 4, 2010 Author Share Posted December 4, 2010 I think the code should be"[CLASS:Button; INSTANCE:2]"or"Button2"Also, I think that the final MsgBox should be on the line after the WEnd statement. You can also try thisWhile 1 Select Case Not WinExists("Slow Commenter", "") _Status("ERROR", "Window 'Slow Commenter' is not Visible", 2) Case Not ControlCommand("Slow Commenter", "", "[CLASS:Button; INSTANCE:2]", "IsVisible", "") _Status("ERROR", "Button2 is not Visible", 2) Case ControlCommand("Slow Commenter", "", "[CLASS:Button; INSTANCE:2]", "IsEnabled", "") _Status("Success", "Button2 is Enabled" & @LF & "Button2 is named " & ControlGetText("Slow Commenter", "", "[CLASS:Button; INSTANCE:2]")) Exit Case Not ControlCommand("Slow Commenter", "", "[CLASS:Button; INSTANCE:2]", "IsEnabled", "") _Status("ERROR", "Button2 is not enabled yet", 2) EndSelect WEnd Func _Status($Title = "", $Text = "", $TimeOut = 0) MsgBox(0, $Title, $Text, $TimeOut) EndFunc ;==>_Status Varian thanks for the help so i added this code into the script all i get when the process is running and the button is greyed out is '_Status("ERROR", "Button2 is not enabled yet", 2)' and then the message box stays there whislt the process carries on running in the background and then i see the process finish in the background and the button become active and then nothing? I pressed ok in the message box but still nothing? Any ideas? Link to comment Share on other sites More sharing options...
Varian Posted December 5, 2010 Share Posted December 5, 2010 Varian thanks for the help so i added this code into the script all i get when the process is running and the button is greyed out is '_Status("ERROR", "Button2 is not enabled yet", 2)' and then the message box stays there whislt the process carries on running in the background and then i see the process finish in the background and the button become active and then nothing? I pressed ok in the message box but still nothing? Any ideas?Where is "Button2"...on what screen? What is the Button Text?..I will try to recreate the problem on my end Link to comment Share on other sites More sharing options...
simpleraison Posted December 8, 2010 Author Share Posted December 8, 2010 Where is "Button2"...on what screen? What is the Button Text?..I will try to recreate the problem on my endThe button appears on a window which appears on top of the original application. And the text in the button is 'Close' The button is located in the window in the bottom right! Hope that helps let me know if you need any more information. 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