Jump to content

WinGetHandle problem


ffdshow
 Share

Recommended Posts

Hi

I try to install a program using a script.

The problem is the window with "Install" button. All command I used to click on that

button failed.

I tried ControlClick, Send("{ENTER}"), Send("!n") and finally MouseClick.

WinGetHandle and ControlGetHandle doesn't help (I used WinGetHandle with this: AutoItSetOption("WinTitleMatchMode", 4)

on top).

ControlClick and MouseClick works if I start the installation manually and stop on

that window and then start a script with ControlClick or MouseClick command inside.

Link to comment
Share on other sites

Hi

I try to install a program using a script.

The problem is the window with "Install" button. All command I used to click on that

button failed.

I tried ControlClick, Send("{ENTER}"), Send("!n") and finally MouseClick.

WinGetHandle and ControlGetHandle doesn't help (I used WinGetHandle with this: AutoItSetOption("WinTitleMatchMode", 4)

on top).

ControlClick and MouseClick works if I start the installation manually and stop on

that window and then start a script with ControlClick or MouseClick command inside.

Run the AU3Info.exe AutoIt Window Info tool and see what you get for window class/title/text and the same for the control. Post the results if that doesn't give you the answer.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Hi

I try to install a program using a script.

The problem is the window with "Install" button. All command I used to click on that

button failed.

I tried ControlClick, Send("{ENTER}"), Send("!n") and finally MouseClick.

WinGetHandle and ControlGetHandle doesn't help (I used WinGetHandle with this: AutoItSetOption("WinTitleMatchMode", 4)

on top).

ControlClick and MouseClick works if I start the installation manually and stop on

that window and then start a script with ControlClick or MouseClick command inside.

It appears you have not given us enough information. What program are you trying to install? We need to know how many windows are open during the install that are associated with this program. Are you using the correct title info for the WinWaitActive command before you do the send.

Really, the winzip install example that comes with autoit is a very good example on what you need to do in most install circumstances.

Link to comment
Share on other sites

Run the AU3Info.exe AutoIt Window Info tool and see what you get for window class/title/text and the same for the control. Post the results if that doesn't give you the answer.

Au3info window:

CODE
>>>> Window <<<<

Title: VideoLAN VLC media player 0.8.6d Setup

Class: #32770

Position: 382, 179

Size: 503, 393

Style: 0x94CA084C

ExStyle: 0x00010100

Handle: 0x0002064E

>>>> Control <<<<

Class: Button

Instance: 2

ClassnameNN: Button2

ID: 1

Text: &Install

Position: 324, 327

Size: 75, 23

ControlClick Coords: 37, 7

Style: 0x50010001

ExStyle: 0x00000004

Handle: 0x00020658

>>>> Mouse <<<<

Position: 746, 542

Cursor ID: 2

Color: 0xFDFDFD

>>>> StatusBar <<<<

>>>> Visible Text <<<<

< &Back

&Install

Cancel

Nullsoft Install System v2.33-1

Nullsoft Install System v2.33-1

Choose Install Location

Choose the folder in which to install VideoLAN VLC media player 0.8.6d.

C:\Program Files\VideoLAN\VLC

B&rowse...

Space available: 26.0GB

Space required: 31.9MB

Setup will install VideoLAN VLC media player 0.8.6d in the following folder. To install in a different folder, click Browse and select another folder. Click Install to start the installation.

Destination Folder

>>>> Hidden Text <<<<

And again ControlClick command works if is started from a separate script.
Link to comment
Share on other sites

Given that you haven't provided your script, I'm going to guess that you're either blocking on a condition that is never true thus ControlClick() is never even called, or you're not waiting until the button is ready to be clicked so the ControlClick() goes off into the void.

Link to comment
Share on other sites

Given that you haven't provided your script, I'm going to guess that you're either blocking on a condition that is never true thus ControlClick() is never even called, or you're not waiting until the button is ready to be clicked so the ControlClick() goes off into the void.

This

is the installer.

The script:

Opt("TrayIconDebug", 1)
Opt("SendKeyDelay", 200)
Run("vlc-0.8.6d-win32.exe")

; Please select a language.
WinWait("Installer Language", "Please select a language.")
WinActivate("Installer Language", "Please select a language.")
ControlClick("Installer Language", "", "Button1")

; Welcome to the VideoLAN VLC media player 0.8.6d Setup Wizard
WinWaitActive("VideoLAN VLC media player 0.8.6d Setup", "Welcome to the VideoLAN VLC media player 0.8.6d Setup Wizard")
ControlClick("VideoLAN VLC media player 0.8.6d Setup", "", "Button2")

; License Agreement
WinWaitActive("VideoLAN VLC media player 0.8.6d Setup ", "License Agreement")
ControlClick("VideoLAN VLC media player 0.8.6d Setup ", "", "Button2")

; Choose Components
WinWaitActive("VideoLAN VLC media player 0.8.6d Setup ", "Choose Components")
ControlClick("VideoLAN VLC media player 0.8.6d Setup ", "", "Button2")

; License Agreement
WinWaitActive("VideoLAN VLC media player 0.8.6d Setup ", "License Agreement")
ControlClick("VideoLAN VLC media player 0.8.6d Setup ", "", "Button2")

; Choose Install Location
WinWaitActive("VideoLAN VLC media player 0.8.6d Setup ", "Choose Install Location")
ControlClick("VideoLAN VLC media player 0.8.6d Setup ", "", "Button2")

; Completing the VideoLAN VLC media player 0.8.6d Setup Wizard
WinWaitActive("VideoLAN VLC media player 0.8.6d Setup ", "Completing the VideoLAN VLC media player 0.8.6d Setup Wizard")
ControlCommand("VideoLAN VLC media player 0.8.6d Setup ", "", "Button4", "UnCheck", "")
ControlClick("VideoLAN VLC media player 0.8.6d Setup ", "", "Button2")

The installation is stopped on "Choose Install Location"

Link to comment
Share on other sites

Did it not occur to you when you were copy and pasting ""VideoLAN VLC media player 0.8.6d Setup" for the 8th time to maybe make it a variable? Why do you have 2 spaces at the end of that string in every usage but the first? Probably not related to your problem, but it's still stupid to write the same string so many times.

Link to comment
Share on other sites

Rewrite the script but with the same result.

Opt("TrayIconDebug", 1)
Opt("SendKeyDelay", 200)
Run("vlc-0.8.6d-win32.exe")
$title = "VideoLAN VLC media player 0.8.6d Setup"

; Please select a language.
WinWait("Installer Language", "Please select a language.")
WinActivate("Installer Language", "Please select a language.")
ControlClick("Installer Language", "", "Button1")

; Welcome to the VideoLAN VLC media player 0.8.6d Setup Wizard
WinWaitActive($title, "Welcome to the VideoLAN VLC media player 0.8.6d Setup Wizard")
ControlClick($title, "", "Button2")

; License Agreement
WinWaitActive($title, "License Agreement")
ControlClick($title, "", "Button2")

; Choose Components
WinWaitActive($title, "Choose Components")
ControlClick($title, "", "Button2")

; License Agreement
WinWaitActive($title, "License Agreement")
ControlClick($title, "", "Button2")

; Choose Install Location
WinWaitActive($title, "Choose Install Location")
ControlClick($title, "", "Button2")

; Completing the VideoLAN VLC media player 0.8.6d Setup Wizard
WinWaitActive($title, "Completing the VideoLAN VLC media player 0.8.6d Setup Wizard")
ControlCommand($title, "", "Button4", "UnCheck", "")
ControlClick($title, "", "Button2")
Link to comment
Share on other sites

The following code is for the portable version of VLC and it works fine for me:

$titlebar1 = "VLC Media Player Portable | PortableApps.com Installer"
Opt("TrayIconDebug", 1)
Run("portvlc086cpaf.exe")

;First dialog screen
WinWaitActive($titlebar1)
Send("{ENTER}")

;Second dialog screen
WinWaitActive($titlebar1)
Send("C:\temp\VLCPortable")
Send("{ENTER}")

;Third dialog screen
WinWaitActive($titlebar1)
Send("!f")
Link to comment
Share on other sites

Problems that I notice:

  • WinWaitActive not needed for Control* functions so use WinWait instead to ensure reliability.
  • 2 license windows in the script but I experienced 1 only. Perhaps the installation causes the 2nd license window to not appear when you have had it installed previously so I added AdlibEnable to handle it.
This works for me:

Opt("TrayIconDebug", 1)
$pid = Run('vlc-0.8.6d-win32.exe')
$title = "VideoLAN VLC media player"

; Please select a language.
If WinWait("Installer Language", "Please select a language", 60) Then
    ControlClick("Installer Language", "Please select a language", "Button1")
    ; Start checking for a license window during installation
    AdlibEnable('_Adlib')
    ; Welcome to the VideoLAN VLC media player 0.8.6d Setup Wizard
    WinWait($title, "Welcome to the VideoLAN VLC media player")
    ControlClick($title, "Welcome to the VideoLAN VLC media player", "Button2")
    ; Choose Components
    WinWait($title, "Choose Components")
    ControlClick($title, "Choose Components", "Button2")
    ; Choose Install Location
    WinWait($title, "Choose Install Location")
    ControlClick($title, "Choose Install Location", "Button2")
    ; Completing the VideoLAN VLC media player 0.8.6d Setup Wizard
    WinWait($title, "Completing the VideoLAN VLC media player")
    ControlCommand($title, "Completing the VideoLAN VLC media player", "Button4", "UnCheck")
    ControlClick($title, "Completing the VideoLAN VLC media player", "Button2")
    ; Stop checking for a license window
    AdlibDisable()
    ; Continue when setup process has finished
    ProcessWaitClose($pid)
EndIf

Exit

Func _Adlib()
    ; License Agreement
    If WinExists($title, "License Agreement") Then
        ControlClick($title, "License Agreement", "Button2")
    EndIf
EndFunc

:)

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...