poppe Posted March 14, 2012 Share Posted March 14, 2012 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 More sharing options...
FaridAgl Posted March 14, 2012 Share Posted March 14, 2012 Try this: ControlClick($WTitle, '', '[CLASS:Button; INSTANCE:2]', 'Main', 1) http://faridaghili.ir Link to comment Share on other sites More sharing options...
poppe Posted March 14, 2012 Author Share Posted March 14, 2012 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 Link to comment Share on other sites More sharing options...
somdcomputerguy Posted March 14, 2012 Share Posted March 14, 2012 (edited) The 'yes' button probably has a default setting, so pressing or sending enter, 'clicks, so to speak' that one. Edited March 14, 2012 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. 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