finalfx Posted August 12, 2008 Share Posted August 12, 2008 (edited) Hey guys, I'm a newb to Autoit and looking for some basic help as it's been a while since I Programmed VBScript. I'm trying to detect if a window has popped up within a program. The new box does not have a title it is blank. It is the "show this box again" in CCLeaner. I figured the best way was to look for focus on the main window and if it fails to run through the process of "never show this again". But I don't know how to catch the 0/1 output from the timeout. Any help is appreciated guys. Also this may seem like a stupid question but i've looked at 10+ examples and I can't figure out how to execute buttons. The viewer windows says they are "button 1" and "button 3" and i tried "ControlSend" but no luck. Thanks everyone. Edited August 12, 2008 by finalfx Link to comment Share on other sites More sharing options...
herewasplato Posted August 12, 2008 Share Posted August 12, 2008 ... I'm trying to detect if a window has popped up within a program. The new box does not have a title it is blank. It is the "show this box again" in CCLeaner. ...You can try this code:Run("C:\Program Files\CCleaner\ccleaner.exe") WinWait("CCleaner") WinActivate("CCleaner") WinWaitActive("CCleaner") $ControlFocusReturn = ControlFocus("CCleaner", "&Run Cleaner", "[CLASS:ThunderRT6CommandButton; INSTANCE:2]") $ControlClickReturn = ControlClick("CCleaner", "&Run Cleaner", "[CLASS:ThunderRT6CommandButton; INSTANCE:2]") MsgBox(0, "$ControlFocusReturn", $ControlFocusReturn) MsgBox(0, "$ControlClickReturn", $ControlClickReturn) If WinWait("", "Do not show me this message again", 3) Then ControlFocus("", "Do not show me this message again", "[CLASS:ThunderRT6CheckBox; INSTANCE:1]") ControlCommand("", "Do not show me this message again", "[CLASS:ThunderRT6CheckBox; INSTANCE:1]", "Check", "") ControlFocus("", "Do not show me this message again", "[CLASS:ThunderRT6CommandButton; INSTANCE:2]") ;ControlClick("", "Do not show me this message again", "[CLASS:ThunderRT6CommandButton; INSTANCE:2]") EndIfYou can unremark the last line if you want to click on "OK" [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
herewasplato Posted August 12, 2008 Share Posted August 12, 2008 (edited) Doh - Welcome to the forums.I would have just edited my last post to add this welcome - but the forum sw has an issue with editing any post that uses the autoit tags around code.Edit: a better way to handle that window is the Adlib function.This line...If WinWait("", "Do not show me this message again", 3) Then...waits 3 seconds for that window to show - if it does not show, then the script moves on past the EndIf. (but you knew that :-) Edit2: Run this code from within the SciTE editorRun("C:\Program Files\CCleaner\ccleaner.exe") WinWait("CCleaner") WinActivate("CCleaner") WinWaitActive("CCleaner") AdlibEnable("_do_not_show") $Rtn1 = ControlFocus("CCleaner", "&Run Cleaner", "[CLASS:ThunderRT6CommandButton; INSTANCE:2]") $Rtn2 = ControlClick("CCleaner", "&Run Cleaner", "[CLASS:ThunderRT6CommandButton; INSTANCE:2]") ConsoleWrite(@CR & "$Rtn1 (ControlFocus) = " & $Rtn1 & @CR) ConsoleWrite(@CR & "$Rtn2 (ControlClick) = " & $Rtn2 & @CR) WinWaitClose("CCleaner", "&Run Cleaner") AdlibDisable() ;;; rest of script goes here - if any Exit Func _do_not_show() If WinExists("", "Do not show me this message again") Then ControlFocus("", "Do not show me this message again", "[CLASS:ThunderRT6CheckBox; INSTANCE:1]") ControlCommand("", "Do not show me this message again", "[CLASS:ThunderRT6CheckBox; INSTANCE:1]", "Check", "") ControlFocus("", "Do not show me this message again", "[CLASS:ThunderRT6CommandButton; INSTANCE:2]") ;ControlClick("", "Do not show me this message again", "[CLASS:ThunderRT6CommandButton; INSTANCE:2]") EndIf EndFunc ;==>_do_not_showSince I did not click "OK" in the code above, you can see the Adlib function running over and over every 250ms. Just kill the script manually via the AutoIt icon in the system tray.If you are just wanting to run CCleaner, then the code layout above might work for you. If you want to set it up - then the linear code in my other post might do better, but you will have to guess at the 3 second timeout for the WinWait line. A slow computer might need 6 or more seconds. Edited August 12, 2008 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] 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