Jump to content

Start installation and send keystrokes after finishing


Recommended Posts

I tried it too. With the Ninite dialog open, this code:

While WinExists("Ninite")
    WinActivate("Ninite")
    If ControlClick("Ninite", "", "[CLASS:Button; INSTANCE:1]") = 1 Then
        ConsoleWrite("OK" & @CRLF)
        ExitLoop ; Successfull clicked the button
    EndIf
    ConsoleWrite("Nok" & @CRLF)
    Sleep(1000) ; Wait for a second
WEnd

... immediately says "OK", but nothing happens to the window. (If I click the "Close" button manually everything is ok.) I also doublechecked that "CLASS:Button; INSTANCE:1" is indeed the Close button we're talking about, and if I read out the handle (ControlGetHandle) I get a non-null result, so it's found.

If I break it (say, I ask it to ControlClick INSTANCE:2, then it keeps saying Nok and looping.

So it really looks like the button can be found like any other, it even accepts the click, but it just doesn't react to it if it came from the AutoIt script's ControlClick command.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

AH! I got it. Should have seen it right away with these results :( 

Put #RequireAdmin on top of your script!

(The Ninite installer seems to elevate itself to admin rights, and if a gui runs as admin you can normally read it as a user, even interact with it, but Windows just makes everything act as though it accepted commands while it actually didn't. Now, if you make your script elevate itself to admin rights as well, it works with the gui just fine.)

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

That would have been my next guess ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Okay that was a bit fast for me. Sorry I had some meetings yesterady and didn't get the chance to check back here..

Thank you for your replies!

Anyways I executed the script after I've run Ninite and those were the results.

Tried the script with #requireadmin but it didn't click the button so far. :>

ArrayDisplay.png

Link to comment
Share on other sites

So we have multiple windows all starting with the text we are looking for. Could you please insert the following line at the top of your script so AutoIt does an exact title match?

Opt("WinTitleMatchMode", 3)

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Perfect. Now we are sure we access the correct window. Still not clicking the Close button?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Another idea would be to set

Opt("WinSearchChildren", 1)

so AutoIt searches child windows as well.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Hi.

So far I've tried each suggestion of yours.

At the moment it looks like this:

Quote

#RequireAdmin
#include <Array.au3>
RunWait("C:\ninite\ninite.exe")
Opt("WinTitleMatchMode", 3)
Opt("WinSearchChildren", 1)

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

 

I have tried your (SadBunnys) suggestion on the top of this page as well.

Am I overlooking something obvious? To get some practice I wrote some  easier scripts for my daily use yesterday :D

Thank you guys so much!

Link to comment
Share on other sites

Ok, there's more. I tried it, apparently there's a close button somewhere in the quick windows that ninite opens and closes which is not the final close button you're looking for and clicking it works, but does nothing, then your loop quits, then the final popup comes and the script doesn't find that button any more.

This works for me. It feels way wonky but sometimes you have to do some wonkiness to work around a weird 3rd-party GUI :)

#RequireAdmin
#include <Array.au3>

Run("C:\tmp\nin.exe")

$handle = 0

While True
    While True
        Sleep(10)
        If getCloseButtonHandle() Then
            If ControlClick("Ninite", "", "[CLASS:Button; TEXT:Close; INSTANCE:1]") Then
                ToolTip("Clicked OK!")
                ExitLoop
            EndIf
        EndIf
    WEnd
    ; Wait for a possible next Ninite window containing a close button
    ; if it exists after a second, keep the loop going, otherwise exit
    Sleep(1000)
    $handle = getCloseButtonHandle()
    If Not getCloseButtonHandle() Then ExitLoop
WEnd

Func getCloseButtonHandle()
    Return ControlGetHandle("Ninite", "", "[CLASS:Button; TEXT:Close; INSTANCE:1]")
EndFunc   ;==>getCloseButtonHandle

/edit2: be sure to repair the link to your ninite exe :) 

Edited by SadBunny
Pasted wrong version of code

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

Refactored button definition into a variable so you only have to change it in one place if you have to change it (easier and less error-prone):

#RequireAdmin
#include <Array.au3>

Run("C:\tmp\nin.exe")

$handle = 0

$buttonDefinition = "[CLASS:Button; TEXT:Close; INSTANCE:1]"

While True
    While True
        Sleep(10)
        If getCloseButtonHandle() Then
            If ControlClick("Ninite", "", $buttonDefinition) Then
                ToolTip("Clicked OK!")
                ExitLoop
            EndIf
        EndIf
    WEnd
    ; Wait for a possible next Ninite window containing a close button
    ; if it exists after a second, keep the loop going, otherwise exit
    Sleep(1000)
    $handle = getCloseButtonHandle()
    If Not getCloseButtonHandle() Then ExitLoop
WEnd

Func getCloseButtonHandle()
    Return ControlGetHandle("Ninite", "", $buttonDefinition)
EndFunc   ;==>getCloseButtonHandle

 

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

I know I keep changing the code, but I noticed I really wasn't using $handle anymore :) 

#RequireAdmin
#include <Array.au3>

Run("C:\tmp\nin.exe")

$buttonDefinition = "[CLASS:Button; TEXT:Close; INSTANCE:1]"

While True
    While True
        Sleep(10)
        If getCloseButtonHandle() Then
            If ControlClick("Ninite", "", $buttonDefinition) Then
                ToolTip("Clicked OK!")
                ExitLoop
            EndIf
        EndIf
    WEnd
    ; Wait for a possible next Ninite window containing a close button
    ; if it exists after a second, keep the loop going, otherwise exit
    Sleep(1000)
    If Not getCloseButtonHandle() Then ExitLoop
WEnd

Func getCloseButtonHandle()
    Return ControlGetHandle("Ninite", "", $buttonDefinition)
EndFunc   ;==>getCloseButtonHandle

 

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...