Jump to content

Recommended Posts

Posted

This works:

$WindowTitle = "Npcap " & $Version & " Setup"

WinWait($WindowTitle,"License Agreement",10)
ControlClick($WindowTitle,"",1)
WinWait($WindowTitle,"Installation Options")
If $Pause = "False" Then
  ControlClick($WindowTitle,"",1)
EndIf
WinWait($WindowTitle,"Setup was completed successfully")
; Wait for the "Next" button to be active
Sleep(2000)
ControlClick($WindowTitle,"",1)
WinWait($WindowTitle,"Thank you for installing Npcap")
ControlClick($WindowTitle,"",1)

If the second argument is not a null string the ControlClick calls do not work.

Posted (edited)

The only use for "text" argument that truly matters is when you have 2 windows with identical titles and you want to distinguish between them based on its content.

Take the following example, I don't have to use the "text" parameter for all win* and control* functions until I have 2 windows with identical title.  Then I can distinguish them by their content :

Run("notepad")  ; start first instance
WinWaitActive("Sans titre") ; don't need to specify any text since there is only 1 window with that title
ControlSend("Sans titre", "", "Edit1", "123")

Run("notepad")  ; start second instance
WinWaitActive("Sans titre") ; again only 1 window with that title since first change title to add * (no need for text)
ControlSend("Sans titre", "", "Edit1", "456")

ControlSend("*Sans titre", "123", "", "^s") ; now we got 2 windows with identical titles -- need to specify text to refer to the right window
WinWait("Enregistrer sous") ; no need for text as this is a unique window title
ControlClick("Enregistrer sous", "", 2) ; id 2 = cancel

Sorry my Notepad is in french !

ps. I always prefer using handle instead of title, there's a reduced chance of creating a bug with handle cause they are uniquely defined.

Edited by Nine

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
  • Recently Browsing   0 members

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