AutoDaemon

Start installation and send keystrokes after finishing

44 posts in this topic

Hey everyone,

newbie here.

I'm trying to write a script that starts an installation, waits for it to finish (or just wait really) and then send a set of keystrokes to the active window.

The program I want to automate is a ninite installer. I've used the search function and tried the two programs I found which should do the job but they don't.

I use Run("C:\path\program.exe") and for testing purposed tried to wait ten seconds before sending TAB, TAB, TAB, ENTER via (Send("{KEYSTROKE}").

The script starts my ninite installer but does nothing after that. 

How do I tell it to wait and send the keystrokes after the installation is done? Been playing around with WinWait or WinWaitActive but no luck so far.

 

Any advice to push me in the right direction?

 

Thanks in advance!

 

Regards

AutoDaemon

Share this post


Link to post
Share on other sites



Why not use RunWait to install ninite? The script continues when the installation has ended.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Tried that just now and it did nothing. After ninite has finished the window just "sits there".

Quote

RunWait("C:\ninite\ninite.exe")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{ENTER}")

This is my attempt so far. I know that it probably looks a bit stupid.

 

Thanks

Share this post


Link to post
Share on other sites

Does ninite run in the background or does it open a DOS window to display some progress information?
How does ninite get instructed which applications to install? If there is something like a config file can you add some kind of exit/end statement?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Maybe you could use the silent command line switch so that ninite ends after having installed all applications?
https://ninite.com/help/features/silent.html


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

The silent switches are for the pro version only. 

Basically it starts and then starts installing the programs and there is a window with a progress bar. I'm not sure but it feels like the window with the progress bar is a "new" window.

I'll maybe try WinActivate. Another quick question: Can I run the command scripts on a pc that doesn't have AutoIT installed?

Thank you for your answers!

Share this post


Link to post
Share on other sites
43 minutes ago, AutoDaemon said:

Can I run the command scripts on a pc that doesn't have AutoIT installed?

Sure. Compile the script to an Exe and run it on the other computer.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Wonderful! Thanks so far.

Share this post


Link to post
Share on other sites

Well I just tried to explicitly select the button "Close" with ControlClick but it didn't work either. Could it be that ninite is just automation resistant?

This is frustrating since it's basically such a minute problem but there is no fix to it :/

Share this post


Link to post
Share on other sites

#10 ·  Posted

Can you post what the AutoIt Window Info Tool shows for this button?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#11 ·  Posted

Sure thing. Anything else you'd need from info tool?

 

ButtonInfo_1.png

ButtonInfo_2.png

ButtonInfo_3.png

Share this post


Link to post
Share on other sites

#12 ·  Posted

Can you please post the line of your script where you use "ControlClick"?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#13 ·  Posted

RunWait("C:\ninite\ninite.exe")
Sleep(5000)
WinActivate("Ninite")
ControlClick("Ninite", "Close", "[CLASS:Button; INSTANCE:1]")

 

This was my attempt so far. With the sleep and winactivate commands I wanted to make sure that the correct window is indeed selected. As I said I'm still new to all of this o:)

Share this post


Link to post
Share on other sites

#14 ·  Posted

What does

$iRC = ControlClick("Ninite", "Close", "[CLASS:Button; INSTANCE:1]")
MsgBox(0, "", $iRC)

return?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#15 ·  Posted

Hi!

Thanks for your reply. Sorry couldn't get to it over the weekend.

Just tried it and it doesn't close the program but when i manually close it (I of course waited a moment before just clicking close)

the message box with "0" gets shown.

 

I also had a closer look at the installer: It starts with a progress bar, then it looks like it closes, opens a "new" progress bar, again "closing" it and then we get to the last window where I want to autoclick the button. What I'm trying to say here is that it's not a single continuous window. Could that be the problem?

 

Thanks so much again for helping!

Share this post


Link to post
Share on other sites

#16 ·  Posted

If all those windows have the same title I would try something like this.

While WinExists("Ninite")
    If ControlClick("Ninite", "Close", "[CLASS:Button; INSTANCE:1]") = 1 Then ExitLoop ; Successfull clicked the button
    Sleep(1000) ; Wait for a second
WEnd

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#17 ·  Posted

Doesn't work as well.

If I had to guess I'd say that maybe ninite knows of this and has some sort of "protection" against it?

Share this post


Link to post
Share on other sites

#18 ·  Posted

Last idea: Do not search for the button text.

While WinExists("Ninite")
    If ControlClick("Ninite", "", "[CLASS:Button; INSTANCE:1]") = 1 Then ExitLoop ; Successfull clicked the button
    Sleep(1000) ; Wait for a second
WEnd

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#19 ·  Posted

Tried it. Sadly doesn't work..

I may try some stuff out but thank you so much for your help! I really appreciate it. 

 

Share this post


Link to post
Share on other sites

#20 ·  Posted

Another try. Let's make sure we grab the correct window:

#include <Array.au3>

Global $aWinList = WinList("Ninite")
_ArrayDisplay($aWinList)
While WinExists("Ninite")
    If ControlClick("Ninite", "", "[CLASS:Button; INSTANCE:1]") = 1 Then ExitLoop ; Successfull clicked the button
    Sleep(1000) ; Wait for a second
WEnd

How many entries do you get?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

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