Jump to content

controlclick questions


 Share

Recommended Posts

I'm having some problems finding the correct way to get controlclick to work when updating spybot's standalone updater. I've tried multiple combinations of titles, text, and (control ID's, ClassnameNN, text, and ControlHandles), but just haven't found a solution that works. Other programs I'm coding have the same problem using winwaitactive and controlclick. I'm sure it something basic I'm screwing up...any help is greatly appreciated!

Using AutoIT 3.2.2.0

Func RunSpybotUpdate1()
    Local $TempInstall = TempFile('.exe')
    TrayTip(@ScriptName, 'Updating Spybot Scan Engine...', 1)
    FileInstall("C:\antispyware\spybotsd_tools.exe", $TempInstall)
    RunWait(Quote($TempInstall))
    WinWaitActive("Spybot")
    ControlClick("Spybot", "", "&Install")
    WinWaitActive("Spybot")
    ControlClick("Spybot", "", "&Close")
    Sleep(2000)
    TrayTip(@ScriptName, 'Finished Updating Spybot Scan Engine', 1)
    FileDelete($TempInstall)
EndFunc ;==>RunSpybotUpdate1
Link to comment
Share on other sites

  • Moderators

ControlClick("Spybot", "&Install", "ClassNameNN")

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

ControlClick("Spybot", "&Install", "ClassNameNN")

Thanks for the quick reply! I tried your suggestion, and used Button1 for the ClassNameNN, but the button is never clicked and the script hangs. Here's the Au3Info screen if that helps. The Spybot tools updater screen is active, and if I understand right, just using "Spybot" for the title should be ok even though the full name is longer, right?

Press CTRL-ALT-F to freeze the display.

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:  Spybot - Search & Destroy Tools update Setup: Installation Folder
Class:  #32770
Size:   X: 260  Y: 172  W: 503  H: 393

>>>>>>>>>>> Mouse Details <<<<<<<<<<<
Screen: X: 630  Y: 538
Cursor ID:  2

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<
RGB:    Hex: 0x000000   Dec: 0

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<
Size:       X: 324  Y: 327  W: 75   H: 23
Control ID: 1
ClassNameNN:    Button2
Text:       &Install
Style:      0x50010001
ExStyle:        0x00000004

>>>>>>>>>>> Status Bar Text <<<<<<<<<<<


>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
&Install
Cancel
Nullsoft Install System v2.21 
Nullsoft Install System v2.21
C:\Program Files\Spybot - Search & Destroy\
B&rowse...
Space available: 60.9GB
Space required: 523.0KB
This will update your Spybot - Search & Destroy tool libraries. Please make sure Spybot - Search & Destroy is no longer running, then choose the program folder:
Destination Folder

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<
Link to comment
Share on other sites

  • Moderators

That shows Button2 is the ClassNameNN... also I don't know what the close button is, so you'll need to change that accordingly.

Func RunSpybotUpdate1()
    Local $TempInstall = TempFile('.exe')
    TrayTip(@ScriptName, 'Updating Spybot Scan Engine...', 1)
    FileInstall("C:\antispyware\spybotsd_tools.exe", $TempInstall)
    RunWait(Quote($TempInstall))
    Local $hWnd = WinGetHandle("Spybot - Search & Destroy Tools update Setup: Installation Folder")
    WinWaitActive($hWnd)
    ControlClick($hWnd, "", "Button2")
    WinWaitActive($hWnd)
    ControlClick($hWnd, '', 'Button2');This is &Close, if Button2 is not the ClassNameNN then change to the right one.
    Sleep(2000)
    TrayTip(@ScriptName, 'Finished Updating Spybot Scan Engine', 1)
    FileDelete($TempInstall)
EndFunc ;==>RunSpybotUpdate1

Edit:

Also note, that I am getting the handle for "Spybot - Search & Destroy Tools update Setup: Installation Folder", you may need to change that for the other WinWaitActivates accordingly... I don't know the game/program you are playing, so I have no idea.

Edited by SmOke_N

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

That shows Button2 is the ClassNameNN... also I don't know what the close button is, so you'll need to change that accordingly.

Func RunSpybotUpdate1()
    Local $TempInstall = TempFile('.exe')
    TrayTip(@ScriptName, 'Updating Spybot Scan Engine...', 1)
    FileInstall("C:\antispyware\spybotsd_tools.exe", $TempInstall)
    RunWait(Quote($TempInstall))
    Local $hWnd = WinGetHandle("Spybot - Search & Destroy Tools update Setup: Installation Folder")
    WinWaitActive($hWnd)
    ControlClick($hWnd, "", "Button2")
    WinWaitActive($hWnd)
    ControlClick($hWnd, '', 'Button2');This is &Close, if Button2 is not the ClassNameNN then change to the right one.
    Sleep(2000)
    TrayTip(@ScriptName, 'Finished Updating Spybot Scan Engine', 1)
    FileDelete($TempInstall)
EndFunc ;==>RunSpybotUpdate1

Edit:

Also note, that I am getting the handle for "Spybot - Search & Destroy Tools update Setup: Installation Folder", you may need to change that for the other WinWaitActivates accordingly... I don't know the game/program you are playing, so I have no idea.

The &Close is also Button2, and I made a typo in my description before, I meant Button2 just so you know. I used this code for the update section of my installer, but I'm still having problems. The script no longer hangs anymore, but the controlclicks aren't selecting the buttons at all. I can at least manually click the buttons and go to the next screen, where I couldn't before. Do the ' ' and " " in the two controlclick section make any difference since they are different? Neither of the two buttons are clicked to advance to the next screen, so I'm assuming it doesn't make any difference.

Thank you for you help, and sorry for being a headache for ya!

Link to comment
Share on other sites

  • Moderators

Try to ControlFocus() before you do ControlClick... or try this...

Func RunSpybotUpdate1()
    Local $TempInstall = TempFile('.exe')
    TrayTip(@ScriptName, 'Updating Spybot Scan Engine...', 1)
    FileInstall("C:\antispyware\spybotsd_tools.exe", $TempInstall)
    RunWait(Quote($TempInstall))
    Local $hWnd = WinGetHandle("Spybot - Search & Destroy Tools update Setup: Installation Folder")
    ;WinWaitActive($hWnd)
    _ControlClickLoop($hWnd, "", "Button2")
    ;WinWaitActive($hWnd)
    _ControlClickLoop($hWnd, '', 'Button2');This is &Close, if Button2 is not the ClassNameNN then change to the right one.
    Sleep(2000)
    TrayTip(@ScriptName, 'Finished Updating Spybot Scan Engine', 1)
    FileDelete($TempInstall)
EndFunc ;==>RunSpybotUpdate1

Func _ControlClickLoop($hWnd, $sText, $vCID)
    If IsHWnd($hWnd) = 0 And WinExists($hWnd) Then $hWnd = WinGetHandle($hWnd)
    Do
        ControlFocus($hWnd, $sText, $vCID)
        Sleep(10)
    Until ControlClick($hWnd, $sText, $vCID)
    Return 1
EndFunc

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

I tried using the _ContorlClickLoop, but it still doesn't select the buttons to advance the screen. I can manually select them, or by pushing Alt + I, or Alt + C, it will advance to the next screen. If I use mouseclick, will that vary on monitors with different resolutions? Do you have any ideas what's wrong with my code?

Link to comment
Share on other sites

I tried using the _ContorlClickLoop, but it still doesn't select the buttons to advance the screen. I can manually select them, or by pushing Alt + I, or Alt + C, it will advance to the next screen. If I use mouseclick, will that vary on monitors with different resolutions? Do you have any ideas what's wrong with my code?

I should clarify that I'm running into this problem with any the programs I'm calling and trying to use controlclick on. I have a gui which will install several different programs when you click on a button to do so. Everything will install fine manually clicking each of the next buttons on the individual programs, but none of the controlclicks work for any of the programs. Don't know if that helps out any. Thank you for all of you help so far...I'm just lost as to why all the things I've tried and all of your suggestions haven't selected any of the buttons.

Link to comment
Share on other sites

  • Moderators

I can manually select them, or by pushing Alt + I, or Alt + C, it will advance to the next screen.

If this works, why not just skip all the informalities and use ControlSend()?

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

If this works, why not just skip all the informalities and use ControlSend()?

I tried ControlSend() also and same thing. I made a really basic script to try to narrow down my problem. I'm just test opening the MS Backup utility on XP and using Alt + n to click the next button, and while ntbackup opens, the next button isn't clicked.

RunWait(@SystemDir & "\ntbackup.exe")
WinWaitActive("Backup or Restore Wizard")
ControlClick("Backup or Restore Wizard", "", "Button4")

That's my entire script as just a test. Am I not including something in the #include section that would be causing any type of controlsend, controlclick, etc to work for me?

Link to comment
Share on other sites

  • Moderators

I tried ControlSend() also and same thing. I made a really basic script to try to narrow down my problem. I'm just test opening the MS Backup utility on XP and using Alt + n to click the next button, and while ntbackup opens, the next button isn't clicked.

RunWait(@SystemDir & "\ntbackup.exe")
WinWaitActive("Backup or Restore Wizard")
ControlClick("Backup or Restore Wizard", "", "Button4")

That's my entire script as just a test. Am I not including something in the #include section that would be causing any type of controlsend, controlclick, etc to work for me?

Are you using 3.2.3.0 beta? I believe ControlSend() was fixed there... also remember that Title has to be correct, I typically use Opt('WinTitleMatchMode', 4) and classname=ClassUnderTitle to ensure I'm using the correct area.

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

Are you using 3.2.3.0 beta? I believe ControlSend() was fixed there... also remember that Title has to be correct, I typically use Opt('WinTitleMatchMode', 4) and classname=ClassUnderTitle to ensure I'm using the correct area.

I'm using 3.2.2.0 release. I held off on using the beta so I wouldn't run into any issues. I'll try the beta and try setting the match mode and see what happens. Thanks again for your help and fast responses!

Link to comment
Share on other sites

I've tried everything I can think of and have gone through the help files several times to double check how I'm using the commands. I've installed the beta also, but I'm still having problems. I can't even get ntbackup to open and click next on a standalone script that just has these 3 lines:

RunWait(@SystemDir & "\ntbackup.exe")
WinWaitActive("Backup or Restore Wizard", "Welcome to the Backup or Restore Wizard")
ControlClick("Backup or Restore Wizard", "Welcome to the Backup or Restore Wizard", "12325")

I've tried a lot of combinations and nothing so far has clicked next on the buttons even on the above standalone script. Here's the output from the active window tool:

Press CTRL-ALT-F to freeze the display.

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:  Backup or Restore Wizard
Class:  #32770
Size:   X: 387  Y: 301  W: 506  H: 392

>>>>>>>>>>> Mouse Details <<<<<<<<<<<
Screen: X: 758  Y: 667
Cursor ID:  2

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<
RGB:    Hex: 0xEDF4F7   Dec: 15594743

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<
Size:       X: 330  Y: 327  W: 75   H: 23
Control ID: 12325
ClassNameNN:    Button4
Text:       Finish
Style:      0x40010000
ExStyle:        0x00000004
(Control is hidden)

>>>>>>>>>>> Status Bar Text <<<<<<<<<<<


>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
Welcome to the Backup or Restore Wizard
This wizard helps you back up or restore the files and settings on your computer.
If you prefer, you can switch to <a>Advanced Mode</a> to change the settings used for backup or restore. This option is recommended for advanced users only.
Always start in &wizard mode
To continue, click Next.
< &Back
&Next >
Cancel

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<
Finish
Help

I'm using beta 3.2.3.0 and previously 3.2.2.0 did the same thing. Does the code work for you, or do you have changes that do work for you that I need to make? I'm trying to run the MS Backup tool as just something simple since the spybot updater wasn't working for me?

Link to comment
Share on other sites

  • 3 weeks later...

Wow, I'm like half a month late, but I just had to mention that RunWait will run the program, then wait for it to exit before continuing the script. Perhaps that's why nothing was working for you? Ideally your ntbackup script should look something like:

Run(@SystemDir & "\ntbackup.exe")
WinWait("Backup or Restore Wizard", "Welcome to the Backup or Restore Wizard")
WinActivate("Backup or Restore Wizard", "Welcome to the Backup or Restore Wizard")
WinWaitActive("Backup or Restore Wizard", "Welcome to the Backup or Restore Wizard")
ControlClick("Backup or Restore Wizard", "Welcome to the Backup or Restore Wizard", "12325")

More lines, but less overall code.

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...