Jump to content

Button may or may not be active


Recommended Posts

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 by finalfx
Link to comment
Share on other sites

... 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]")
EndIf
You 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

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 editor

Run("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_show
Since 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 by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...