Sign in to follow this  
Followers 0
Shortsman

Enter not being sent

6 posts in this topic

#1 ·  Posted (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 by Shortsman

Share this post


Link to post
Share on other sites



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.


RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 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

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by Scriptonize

If you learn from It, it's not a mistake

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by Shortsman

Share this post


Link to post
Share on other sites

With what you posted, I think it should be:

ControlClick("Applying updates", "", "[CLASS:Button; INSTANCE:1]", "left")

RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

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  
Followers 0