Jump to content

Simple Script Help


 Share

Recommended Posts

I made an autoit script for installing Easy CD-DA Extractor, but sometimes it works and sometimes it doesn't and when it doesn't the option for disable the check box doesn't work either.

Here's my script:

; Setup Begins
Run("EasyCDDA.exe")

; Next and uncheck checkbox
WinWaitActive("Programa de instalación de Easy CD-DA Extractor")
Send("!s")
Send("{ENTER}")
; Begin uncheck checkbox
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{SPACE}")

; Confirm checkbox window
Send("{ENTER}")

; Installation begins...

; Windows Confirmation appears and send confirmation
WinWaitClose("Programa de instalación de Easy CD-DA Extractor")
; Tried to put this here, and sometimes work, other doesn't "WinWaitActive("Programa de instalación de Easy CD-DA Extractor")"
Send("!t") ; I've tried with ENTER

WinWaitActive("Recordar")
Run("taskkill /IM ezcddax.exe /F")

Additional info:

Posted Image

Posted Image

Edited by Acker
Link to comment
Share on other sites

Don't depend on the title of the installer window, grab its handle. Titles can change. Handles do not.

Don't use send to tab about a window or use !{key} modifiers, click the control directly.

$hwndCDDA = WinGetHandle("Programa de instalación de Easy CD-DA Extractor")
ControlClick($hwndCDDA, "", "[TEXT:&Terminar]", "primary", 1)
Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

Thanks for the help buddies :).

So far, the script select all the desired options, but the problem of not working on the last window is still there.

When the file copying finishes, there's like a small window refresh, but the window title (handle) has the same name title of all.

; Run the setup
Run("EasyCDDA.exe")

; Get Handle
$handle = WinGetHandle("Programa de instalación de Easy CD-DA Extractor")

; Select options
WinWaitActive($handle)
ControlClick($handle, "&Siguiente >", "[ClassNN:Button3]", "left", 1)
ControlClick($handle, "&Siguiente >", "[ClassNN:Button3]", "left", 1)
ControlClick($handle, "&Siguiente >", "[ClassNN:Button1]", "left", 1)
ControlClick($handle, "Habilitar Menús Contextuales en el Explorador de Windows", "[ClassNN:Button33]", "left", 1)
ControlClick($handle, "&Siguiente >", "[ClassNN:Button1]", "left", 1)

; Installation begins... Window Refresh

ControlClick($handle, "&Terminar", "[ClassNN:Button1]", "left", 1)

WinWaitActive("Recordar")
Run("taskkill /IM ezcddax.exe /F")
Link to comment
Share on other sites

Now that I fixed it. When the script is not compiled it's fully working as expected. But when I compile it doesn't work :).

; Run the setup
Run("EasyCDDA.exe")

; Get Handle
$handle = WinGetHandle("Programa de instalación de Easy CD-DA Extractor")

; Select options
WinWaitActive($handle)
ControlClick($handle, "&Siguiente >", "[ClassNN:Button3]", "left", 1)
ControlClick($handle, "&Siguiente >", "[ClassNN:Button3]", "left", 1)
ControlClick($handle, "&Siguiente >", "[ClassNN:Button1]", "left", 1)
ControlClick($handle, "Habilitar Menús Contextuales en el Explorador de Windows", "[ClassNN:Button33]", "left", 1)
ControlClick($handle, "&Siguiente >", "[ClassNN:Button1]", "left", 1)

; Installation begins... 

WinWaitActive($handle, "&Terminar")
ControlClick($handle, "&Terminar", "[ClassNN:Button1]", "left", 1)

WinWaitActive("Recordar")
Run("taskkill /IM ezcddax.exe /F")
Edited by Acker
Link to comment
Share on other sites

Instead of using "left" or "right" for the mouseclick, use "primary" or "secondary" since left handed users have the "right" mouse button as the primary and it will not function correctly with using "left"

Also, the text parameter in ControlClick() is ignored if you're using handles, so using anything other than a null string is pointless.

See the help file: http://www.autoitscript.com/autoit3/docs/functions/ControlClick.htm

Regarding your non-working compiled script...

Put a WinWait() after your run statement, and then activate the window.

Run("C:\program.exe")
If Not WinWait("XYZ", "", 30) Then
    ConsoleWrite("Error.  No Window." & @CRLF)
    If @Compiled Then MsgBox(0, "Error", "Could not find installation window.")
    Exit
EndIf
$handle = WinGetHandle("XYZ")
WinActivate($handle)
If Not WinWaitActive($handle, "", 30) Then
    ConsoleWrite("Error.  No Active Window." & @CRLF)
    If @Compiled Then MsgBox(0, "Error", "Could not activate installation window.")
    Exit
EndIf

Basic error checking can save a ton of grief.

Edit:

*facepalm* I see wut you did thar.

You're using "WinWaitActive" before you activate the window. It's going to fail. Always activate the window before using WinWaitActive ... and include a timeout with a fail-check. Otherwise ... it's just a useless statement.

Ok. I took your entire script and melded it with some error checking.

Global $hwnd_CDDA = Default, $iSecond = 1000
Run("EasyCDDA.exe"); run the program
If Not WinWait("Programa de instalación de Easy CD-DA Extractor", "", 30) Then ; wait 30 seconds for window to appear
    ConsoleWrite("Error.  No Window." & @CRLF)
    If @Compiled Then MsgBox(0, "Error", "Could not find installation window.")
    Exit
EndIf
$hwnd_CDDA = WinGetHandle("Programa de instalación de Easy CD-DA Extractor") ; grab the handle
WinActivate($hwnd_CDDA) ; activate the window
If Not WinWaitActive($hwnd_CDDA, "", 30) Then ; Wait 30 seconds to ensure window is active
    ConsoleWrite("Error.  No Active Window." & @CRLF)
    If @Compiled Then MsgBox(0, "Error", "Could not activate installation window.")
    Exit
EndIf

; Select options
ControlClick($hwnd_CDDA, "", "[ClassNN:Button3]")
Sleep(10 * $iSecond) ; sleep long enough to ensure window changes, or control is changed.
ControlClick($hwnd_CDDA, "", "[ClassNN:Button3]")
Sleep(10 * $iSecond) ; sleep long enough to ensure window changes, or control is changed.
ControlClick($hwnd_CDDA, "", "[ClassNN:Button1]")
Sleep(10 * $iSecond) ; sleep long enough to ensure window changes, or control is changed.
ControlClick($hwnd_CDDA, "", "[ClassNN:Button33]")
Sleep(10 * $iSecond) ; sleep long enough to ensure window changes, or control is changed.
; Button 33?  Typo?
ControlClick($hwnd_CDDA, "", "[ClassNN:Button1]")
Sleep(10 * $iSecond) ; sleep long enough to ensure window changes, or control is changed.


; Install begins

ControlClick($hwnd_CDDA, "", "[ClassNN:Button1]", "left", 1)

There are some other issues with the script, but I leave it to you.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

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