Sign in to follow this  
Followers 0
Docfxit

WordPerfect X5 Unattended Install

16 posts in this topic

I'd like to create an unattended install for WordPerfect X5.

I can't get it recognize the license screen. The code I have goes past the license screen. It must be recognizing the screen before the license screen which isn't showing long enough for me.

; Include User.INI Info
#include "IniRead.au3"

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
AutoItWinSetTitle(@ScriptName)
; AutoItSetOption("SendKeyDelay", 20)
AutoItSetOption("TrayIconDebug", 1) ;0-off
; Set so that tray displays current line number
If _OSVersion() = "Win7" Then
    $ProgramFiles = "C:\Programs\"
Else
    $ProgramFiles = "C:\Program Files\"
EndIf
Run('C:\Dnload\9xAddons\WordPerfect Office X5\Setup.exe')
WinWait("WordPerfect Office X5 - InstallShield Wizard","WordPerfect Office X5 Setup is preparing")
If Not WinActive("WordPerfect Office X5 - InstallShield Wizard","WordPerfect Office X5 Setup is preparing") Then WinActivate("WordPerfect Office X5 - InstallShield Wizard","WordPerfect Office X5 Setup is preparing")
WinWaitActive("WordPerfect Office X5 - InstallShield Wizard","WordPerfect Office X5 Setup is preparing")
;Sleep(300)
WinWait("WordPerfect Office X5 - InstallShield Wizard","Installing")
If Not WinActive("WordPerfect Office X5 - InstallShield Wizard","Installing") Then WinActivate("WordPerfect Office X5 - InstallShield Wizard","Installing")
WinWaitActive("WordPerfect Office X5 - InstallShield Wizard","Installing")
;Sleep(300)

;License Screen
WinWait("WordPerfect Office X5","Tab")
If Not WinActive("WordPerfect Office X5","Tab") Then WinActivate("WordPerfect Office X5","Tab")
WinWaitActive("WordPerfect Office X5","Tab")
Send("{TAB}{UP}{ENTER}")

WinWait("WordPerfect Office X5","Please enter your in")
If Not WinActive("WordPerfect Office X5","Please enter your in") Then WinActivate("WordPerfect Office X5","Please enter your in")
WinWaitActive("WordPerfect Office X5","Please enter your in")
Send($First)
Send("{SPACE}")
Send($Last)
Send("{TAB}")

Info Window

>>>> Window <<<<
Title:  WordPerfect Office X5
Class:  #32770
Position:   582, 94
Size:   798, 610
Style:  0x940800CC
ExStyle:    0x000D0000
Handle: 0x000F0440

>>>> Control <<<<
Class:  Internet Explorer_Server
Instance:   1
ClassnameNN:    Internet Explorer_Server1
Name:   
Advanced (Class):   [CLASS:Internet Explorer_Server; INSTANCE:1]
ID: 
Text:   
Position:   0, 0
Size:   798, 610
ControlClick Coords:    368, 86
Style:  0x56000000
ExStyle:    0x00000000
Handle: 0x000E0416

>>>> Mouse <<<<
Position:   950, 180
Cursor ID:  2
Color:  0xE9F7FD

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<


>>>> Hidden Text <<<<

Posted Image

Thank you,

Docfxit

Share this post


Link to post
Share on other sites



Note this part:

>>>> Control <<<<
Class:  Internet Explorer_Server

That's an embedded instance of Internet Exploder. If you want to work with HTML elements of the page it's displaying, get an object reference with _IEAttach() using the "embedded" type, then use the other _IE* functions on it.

:mellow:


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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Note this part:

>>>> Control <<<<
Class:  Internet Explorer_Server

That's an embedded instance of Internet Exploder. If you want to work with HTML elements of the page it's displaying, get an object reference with _IEAttach() using the "embedded" type, then use the other _IE* functions on it.

:mellow:

Thank you for the reply...

I have added the code.

#include <IE.au3>

$hHelp = WinGetHandle("[CLASS:HH Parent; TITLE:AutoIt Help]", "")
ConsoleWrite("$hHelp = " & $hHelp & @LF)

$oIE = _IEAttach($hHelp, "embedded")
If IsObj($oIE) Then
    $sHTML = _IEBodyReadHTML($oIE)
    ConsoleWrite("sHTML = " & $sHTML & @LF)
Else
    ConsoleWrite("Error attaching to IE")
EndIf

I have installed the DebugBar.

The IE Interpreted Source Code from DebugBar show this.

<HTML XMLNS:ICA = "ICA"><HEAD><TITLE>Setup Wizard</TITLE><LINK rel=stylesheet type=text/css href="Style.css">
<META content="text/html; charset=UTF-8" http-equiv=content-type>
<META id=ICADlg name=ICADlg content=text/html ICA:ShadowGraphicTransparency="255" ICA:ShadowGraphicOffsetTop="-2" ICA:ShadowGraphicOffsetLeft="-2" ICA:ShadowGraphic="Images\Shadow.png" ICA:TransparencyColorRBG="0,128,128" ICA:DlgFrame="0" ICA:DlgHW="610,798">
<script language=jscript type=text/jscript src="js\Tabs.js"></SCRIPT>

<script language=jscript type=text/jscript>
 /*  Globals *******************************************************/
        var g_ICA   = window.external;

        
      /*  function ShowSerialDialog()   ***************************************
        *
        *   Returns: true/false
        *
        *   -   checks to see if the serial number is hardcoded, if it is then
        *       we move to the Install page, if not the serial number page
        *******************************************************************/
        function ShowSerialDialog()
        {
             var sGuid = g_ICA.GetProperty("Script.RT.GUID");
            
             if("{C478443A-7E62-4AFF-9B34-5E020F6A50CA}" == sGuid)
            {
                window.location = "SN_Retail.htm";
            }
            else if("{B3AA510F-6EA0-4B75-AA41-D715ED52D39A}" == sGuid)
            {
                window.location = "SN_Trial.htm";
            }
            
            return true;
            
        } //function ShowSerialDialog()

</SCRIPT>
</HEAD>
<BODY style="BACKGROUND-COLOR: #008080"><!-- background -->
<DIV id=idBackGrd></DIV><IMG class=CloseBtn alt="" src="Images/close.png" ICA:Function="ICACancelSetup"> <!-- page content panel -->
<DIV id=idTabPanel>
<DIV class=DlgHeaderTitles>Please read the following license agreement carefully </DIV>
<DIV style="WIDTH: 750px; TOP: 30px" class=DlgBlock><IFRAME style="BORDER-BOTTOM-STYLE: double; BORDER-BOTTOM-COLOR: dimgray; BORDER-RIGHT-STYLE: double; BORDER-TOP-COLOR: dimgray; WIDTH: 99%; BORDER-TOP-STYLE: double; HEIGHT: 305px; BORDER-RIGHT-COLOR: dimgray; BORDER-LEFT-STYLE: double; BORDER-LEFT-COLOR: dimgray" id=idEula src="EN.htm" frameBorder=0 name=Eula>
            </IFRAME></DIV>
<DIV style="TOP: 355px" class=DlgBlock><LABEL accessKey=A title="" for=idCheckBox1><INPUT id=idCheckBox1 title="" type=checkbox name=AcceptLicense ICA:Function="ICAEulaCheckbox"> <B>I <U>a</U>ccept the terms in the license agreement.</B> </LABEL></DIV></DIV><!-- div id="idTabPanel" END --><!-- ------------------------------------------------------------ --><!-- <div> Wizard Buttons (at bottom of dialog) - START -->
<DIV class=DlgWizardBtns>
<TABLE border=0 width="100%">
<TBODY>
<TR>
<TD align=right></TD>
<TD width=120 align=left><BUTTON accessKey=N id=idNext disabled onclick=ShowSerialDialog(); type=submit ICA:Disable="!AcceptLicense=1"><U>N</U>ext &gt;</BUTTON> </TD>
<TD width=120 align=right><BUTTON accessKey=C style="VISIBILITY: visible" id=idCancel ICA:Function="ICACancelSetup"><U>C</U>ancel</BUTTON> </TD></TR></TBODY></TABLE></DIV><!-- <div class="DlgBlock"> Wizard Buttons (at bottom of dialog) - END --></BODY></HTML>

I don't know how to use the other _IE* functions.

How would I code it to put a check mark in the box by "I accept the terms in the license agreement."

and then click on the Next button?

Thank you,

Docfxit

Edited by docfxit

Share this post


Link to post
Share on other sites

You see the checkbox element has id=idCheckBox1, so _IEGetObjByName() to get an object reference to that element (ID is the same as Name for this purpose), then use _IEFormElementCheckBoxSelect() on it.

See help file. You're almost there!

:mellow:


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

Share this post


Link to post
Share on other sites

Thanks for the help...

Did I do this correct?

$hHelp = WinGetHandle("[CLASS:HH Parent; TITLE:AutoIt Help]", "")
ConsoleWrite("$hHelp = " & $hHelp & @LF)

$oIE = _IEAttach($hHelp, "embedded")
If IsObj($oIE) Then
    $sHTML = _IEBodyReadHTML($oIE)
    $idCheckBox1Result = _IEFormGetObjByName ($s_name "idCheckBox1")
    $idCheckBox1Result2 = _IEFormElementCheckBoxSelect ($s_name = "idCheckBox1", $f_select = 1)
    $idNextResult = _IEFormGetObjByName ($s_name "idNext")
    $idNextResult2 = _IEFormImageClick ($o_object = "idNext")
    
    ConsoleWrite("sHTML = " & $sHTML & @LF)
Else
    ConsoleWrite("Error attaching to IE")
EndIf

Do I have enough?

Do I have too much in there?

What should I do for error reporting?

Thanks,

Docfxit

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Bad syntax. You can't be doing this in SciTE or it would have pointed that out to you. Use SciTE, and run Tidy (Ctrl-t), and the syntax checker (Ctrl-F5) before posting any code on the forum.

When you provide parameters to a function, just supply the value, not the function's local variable name for it. For example, just "idCheckBox1", not $s_name = "idCheckBox1" in the function call.

When trying IE stuff, add _IEErrorHandlerRegister() to the top of your script and run it from SciTE (F5) to see any error messages in the console pane (bottom of the SciTE window).

On the actual IE stuff I may have lead you a little astray because that page doesn't use a FORM container. It has an IFrame but we don't care because the checkbox is not inside that frame. I don't have that app to test it with, but you might have to do things a little more directly:

#include <IE.au3>

_IEErrorHandlerRegister()

$hHelp = WinGetHandle("[CLASS:HH Parent; TITLE:AutoIt Help]", "")
ConsoleWrite("$hHelp = " & $hHelp & @LF)

$oIE = _IEAttach($hHelp, "embedded")
If IsObj($oIE) Then
    $oChkBx = _IEGetObjById($oIE, "idCheckBox1")
    If IsObj($oChkBx) Then
        ConsoleWrite("Before checked = " & $oChkBx.checked & @LF)
        $oChkBx.checked = True
        $oChkBx.fireEvent("onchange")
        $oChkBx.fireEvent("onclick")
        ConsoleWrite("After checked = " & $oChkBx.checked & @LF)
    Else
        ConsoleWrite("Error attaching to IE")
    EndIf
Else
    ConsoleWrite("Error attaching to IE")
EndIf

:mellow:

Edited by PsaltyDS

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

Share this post


Link to post
Share on other sites

That's really super. Thank you for showing me how to write it.

I have tried running it. I'm having a problem that the script isn't waiting for the window to open.

Before this window is ready for input there are three other screens that come up during the unpacking and setup initializing phase.

How can I get the script to wait for the window?

Thank you,

Docfxit

Share this post


Link to post
Share on other sites

WinWait(), see help file.

:mellow:

Thank you for the reply...

I can do WinWait("WordPerfect Office X5", "")

The problem is there is three other windows that pop up before this and they all match this WinWait(). None of them have any unique identifying text that I can see.

Is there some way I can use an If statement in a loop to wait for this window?

Thank you,

Docfxit

Share this post


Link to post
Share on other sites

One way would be to keep track of the old window handles with the same title, and react when the new one showed up.

Another would be to watch for something else unique about the window. Are they all the same class, do they all have embedded IE? If so, does the IE doc in each have a unique title property? Etc.

When you visually look at the windows, how can you tell them apart?

:mellow:


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

Share this post


Link to post
Share on other sites

One way would be to keep track of the old window handles with the same title, and react when the new one showed up.

Another would be to watch for something else unique about the window. Are they all the same class, do they all have embedded IE? If so, does the IE doc in each have a unique title property? Etc.

When you visually look at the windows, how can you tell them apart?

:mellow:

Thanks for the reply...

The screens go by very quickly. I don't know how I could capture any information about them.

When I visually look at the windows I can tell them apart.

The first window says "WordPerfect Office X5 Setup is preparing"

The second window says "Installing"

Thanks,

Docfxit

Share this post


Link to post
Share on other sites

Thanks for the reply...

The screens go by very quickly. I don't know how I could capture any information about them.

When I visually look at the windows I can tell them apart.

The first window says "WordPerfect Office X5 Setup is preparing"

The second window says "Installing"

Thanks,

Docfxit

If they don't stick around to clutter the desktop, they are irrelevant. All you need is unique identifying info for the one window you ARE interested in. How do you recognize that one? Use AU3Info.exe to examine the one you're interested in. If the class/title of the window is not unique enough, how does this "Installing" appear? What kind of control is it in? If it's not in visible text of the window, is it in an embedded IE instance? Flash object? What?

:mellow:


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

Share this post


Link to post
Share on other sites

If they don't stick around to clutter the desktop, they are irrelevant. All you need is unique identifying info for the one window you ARE interested in. How do you recognize that one? Use AU3Info.exe to examine the one you're interested in. If the class/title of the window is not unique enough, how does this "Installing" appear? What kind of control is it in? If it's not in visible text of the window, is it in an embedded IE instance? Flash object? What?

:mellow:

The info window is in post #1 in this thread. Can I wait for something there?

Thanks,

Docfxit

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

This example waits a max of 2 minutes for a window of the same class and title, which has an embedded IE containing an element called "idCheckBox1":

#include <IE.au3>

Global $iTimer, $aWinList, $hWnd = 0
Global $oIE, $oChkBx

; Wait max of 2 minutes for window
$iTimer = TimerInit()
While 1
    ; Check timeout
    If TimerDiff($iTimer) >= 120000 Then ExitLoop

    ; Get list of candidate windows
    $aWinList = WinList("[CLASS:#32770; TITLE:WordPerfect Office X5", "")
    For $n = 1 To $aWinList[0][0]
        ; Test for embedded IE
        $oIE = _IEAttach($aWinList[$n][1], "embedded")
        If @error Then ContinueLoop

        ; Test for correct page
        $oChkBx = _IEGetObjById($oIE, "idCheckBox1")
        If IsObj($oChkBx) Then
            ; Check accept EULA
            ConsoleWrite("Debug:  Before checked = " & $oChkBx.checked & @LF)
            $oChkBx.checked = True
            $oChkBx.fireEvent("onchange")
            $oChkBx.fireEvent("onclick")
            ConsoleWrite("Debug:  After checked = " & $oChkBx.checked & @LF)
            
            ; Exit loop - found window
            $hWnd = $aWinList[$n][1]
            ExitLoop
        Else
            ContinueLoop
        EndIf
    Next

    Sleep(100)
WEnd

If $hWnd Then
    ControlSend($hWnd, "", "", "!n") ; Next
    MsgBox(64, "Success", "Success")
Else
    MsgBox(16, "Failed", "Did not find window")
EndIf

Notice it gets a list of windows that initially match class and title, then checks each in more detail to find the correct one.

:mellow:

Edit: Good point by GEOSoft below: It's hard to believe WordPerfect doesn't have a silent install available.

:P

Edited by PsaltyDS

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

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

A couple of tips

all versions of Installshield recognize the /s switch to do a silent install and you won't need to accept the agreement.

Go to this page, scroll down to InstallShield and learn how to create an answer file so you don't even have to enter the key code.

http://unattended.sourceforge.net/installers.php

You don't need this at all

If _OSVersion() = "Win7" Then
    $ProgramFiles = "C:\Programs\"
Else
    $ProgramFiles = "C:\Program Files\"
EndIf

Just use $ProgramFiles = @ProgramFilesDir & "\"

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

You don't need this at all

If _OSVersion() = "Win7" Then
    $ProgramFiles = "C:\Programs\"
Else
    $ProgramFiles = "C:\Program Files\"
EndIf

Just use $ProgramFiles = @ProgramFilesDir & "\"

Thank you for the reply...

What @ProgramFilesDir gives me is "C:\Program Files (x86)"

Which is not what I want. That is a protected folder that programs can't write in. The reason I use "C:\Programs" is because it's not protected. It's a folder I create so that any program that is not Win7 savy can write into it.

Thanks,

Docfxit

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
Sign in to follow this  
Followers 0