Jump to content
Sign in to follow this  
poppe

ControlSend goes to wrong button

Recommended Posts

poppe

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?

Share this post


Link to post
Share on other sites
poppe

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:

Share this post


Link to post
Share on other sites
somdcomputerguy

The 'yes' button probably has a default setting, so pressing or sending enter, 'clicks, so to speak' that one.

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
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
Sign in to follow this  

×