Jump to content

ControlSend goes to wrong button


 Share

Recommended Posts

Hello

I have a weird problem.

I'm doing a script that automatically installs a 3rd party software. At the last window the installer asks whether pc hould be restarted and there are two buttons: yes and no.

Yes button is [CLASS:Button; INSTANCE:1]

No button is [CLASS:Button; INSTANCE:2]

I want it to press No button, but it always seems to press the Yes button, because PC restarts.

My code:

$WTitle = WinGetTitle("[active]")
sleep (1000)
ControlFocus($WTitle, "", "[CLASS:Button; INSTANCE:2]")
sleep (1000)
ControlSend($WTitle, "", "[CLASS:Button; INSTANCE:2]", "{ENTER}")

I even tried to set the focus to the No button first, which it does ok, but for some reason it seems to always press yes, because the pc restarts when i run this script.

If i comment out the last line (the controlsend) the pc is not restarted.

What is wrong?

Link to comment
Share on other sites

Thanks for help

For some reason if i use {SPACE} instead of {ENTER} it works ok.

ControlSend($WTitle, "", "[CLASS:Button; INSTANCE:2]", "{ENTER}")

Ends up restarting the PC

But:

ControlSend($WTitle, "", "[CLASS:Button; INSTANCE:2]", "{SPACE}")

Ends up closing the window, and not restarting, like it should.

Could there be a bug? I don't understand why using Enter makes it restart, when the Enter is sent to No button.

Anyway it works now :oops:

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