Shortsman Posted August 9, 2012 Share Posted August 9, 2012 (edited) Hi I'm trying to automate a programs update running, all that needs to be done is sleep, then enter. It automatically installs and needs to be closed by pressing a finish button (pressing enter works). My script is: ShellExecute("servershareapp.exe") sleep(15000) Send("{ENTER}") The Enter never gets pushed to the application though, if I manually press enter on the keyboard after the script has finished executing it closes the application, so the windows definitely has focus. Any ideas, am I missing something really obvious?! Edited August 9, 2012 by Shortsman Link to comment Share on other sites More sharing options...
abberration Posted August 9, 2012 Share Posted August 9, 2012 It is possible that the window is losing focus. You can use WinActivate to make it active again. However, if possible, it would be best to use ControlClick to directly click the button. Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
Xenobiologist Posted August 9, 2012 Share Posted August 9, 2012 (edited) Maybe 15 Sec is not enough? Try using ShellexecuteWait or create o MsgBox bevor it goes to Send your enter. Script will pause until you click the Msgbox away. (For testing) And of course there a commands to activate, check state, send directly to the button / window and so on. Edited August 9, 2012 by Xenobiologist Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Scriptonize Posted August 9, 2012 Share Posted August 9, 2012 (edited) A quick and dirty example... Local $Loop Run("calc.exe") WinActivate("Calculator") sleep(500) Send("1") Send("{NUMPADADD}") Send("2") sleep(500) Do WinActivate("Calculator") Send("{NUMPADENTER}") $Loop = $Loop + 1 sleep(500) Until $Loop >= 9 Send("{ALTDOWN}{F4}{ALTUP}") Edited August 9, 2012 by Scriptonize If you learn from It, it's not a mistake Link to comment Share on other sites More sharing options...
Shortsman Posted August 9, 2012 Author Share Posted August 9, 2012 (edited) I've tried WinActivate, and even tried opening notepad.exe beforehand to make sure it was stealing the focus back (it was). Shellexecutewait won't work I don't think, as the application won't close until enter is pressed. The 15 second timeout is long enough, it's actually a good 5 seconds after it finished. I'm a little confused at how to use ControlClick, if I use the Window info tool the summary is: >>>> Window <<<< Title: Applying updates Class: #32770 Position: 2696, 480 Size: 486, 239 Style: 0x94C800C4 ExStyle: 0x00050101 Handle: 0x00212092 >>>> Control <<<< Class: Button Instance: 1 ClassnameNN: Button1 Name: Advanced (Class): [CLASS:Button; INSTANCE:1] ID: 1 Text: Finish Position: 395, 171 Size: 75, 23 ControlClick Coords: 44, 10 Style: 0x50010000 ExStyle: 0x00000004 Handle: 0x002521F4 >>>> Mouse <<<< Position: 3138, 686 Cursor ID: 0 Color: 0x000000 >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< Checking update environment Update 1: already installed Update 2: already installed Update 3: already installed Update 4: already installed Progress1 Finish Program sucessfully updated. >>>> Hidden Text <<<< Edited August 9, 2012 by Shortsman Link to comment Share on other sites More sharing options...
abberration Posted August 9, 2012 Share Posted August 9, 2012 With what you posted, I think it should be: ControlClick("Applying updates", "", "[CLASS:Button; INSTANCE:1]", "left") Easy MP3 | Software Installer | Password Manager 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