Jump to content

Working with IE windows


Recommended Posts

Hi Docfxit,

I'm having trouble connecting to the window as well (downloaded the trial to test).

What exactly is the purpose of this?

My guess would be an unattended install, and if that's correct, maybe you would have more success using the command line options already provided.

The
/q
switch can be used in conjunction with one of the following
parameters:
n
— The user does not see the user interface during installation.
Errors are recorded in a log file.
(For more information, see “Do I
want to create an installation log?” on page 28.)
b
— The user sees only a progress bar and a
Cancel
button. If the
user pushes the
Cancel
button, the installati
on is rolled back.
b!
— The user sees only a progress bar and cannot cancel the
installation.
b+
— The user sees only a progress bar and a
Cancel
button. If the
user pushes the
Cancel
button, the installation is immediately rolled
back. (The user is not prompted to
confirm the cancel
lation request.)
r
— The user sees a progress bar, along with a page containing
information about the installation.
The user can choose to cancel the
installation.
f

— The user sees the full user interface

 

so if you want the users to see nothing, use the /qn switch.

Hope this helps.  I had no luck getting connected to the embedded IE for WordPerfect Office X6.

Link to comment
Share on other sites

  • Replies 43
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Okay, it's been one of those days for me, this works fine:

#RequireAdmin
#include <IE.au3>
$aWinList = WinList("[CLASS:#32770; TITLE:WordPerfect Office X6]", "")
$oIE = _IEAttach($aWinList[1][1], "Embedded")
If @error Then MsgBox(0,'Error - ' & @error, @extended)
MsgBox(0,'test', _IEBodyReadHTML($oIE))

Amazing what difference #RequireAdmin made LOL

Link to comment
Share on other sites

Well I'd love to help more, but I cannot take it any further than the installer, and even at that it looks like using the trial version will be a bit different than the full version, but here is what I have up to the serial number validation for what it's worth.

#RequireAdmin
#include <IE.au3>

$SerialNumber = '0123456789'

$aWinList = WinList("[CLASS:#32770; TITLE:WordPerfect Office X6]", "")
$oIE = _IEAttach($aWinList[1][1], "Embedded")
If @error Then MsgBox(0,'Error - ' & @error, @extended)

;Accept EULA
$oIE.document.parentWindow.execScript('ShowSerialDialog();',"javascript")
While _IEPropertyGet($oIE, "busy")
    Sleep(100)
WEnd

;Set to use a serial
$oCB = _IEGetObjById($oIE, 'idInputSerialLabel')
_IEAction($oCB, "click")

;Enter serial
$oSerial = _IEGetObjById($oIE, 'idSNInput')
_IEFormElementSetValue($oSerial, $SerialNumber)

;Validate serial
$oIE.document.parentWindow.execScript('ValidateSN();',"javascript")

I should mention that the best way to do this unattended install is still by command line switches, but I found this entertaining to look in to :D

Edited by danwilli
Link to comment
Share on other sites

I'd like to learn how you figured out the objid.  I don't see that information in the AutoIt v3 Window Info screen.  You are correct that I am working on creating an unattended install.  I can't use the command line switches because I install all software to a different folder called c:programs so I don't run into the security problems designed into windows.

Thanks,

Docfxit

Link to comment
Share on other sites

 

You can either take a look at the html with

_IEBodyReadHTML($oIE)

Or, what I did, was use

_IEPropertyGet($oIE, "locationurl")
in order to grab the local URL that the installer was displaying, toss it in to IE and use the developer tools.

 

I have been trying for hours to figure out how to use either one of these.

I entered the first one into my script after $oIE was created.

Local $sHTML = _IEBodyReadHTML($oIE)
$sHTML = $sHTML & "<p><font color=red size=+5>Big RED text!</font>"
_IEBodyWriteHTML($oIE, $sHTML)
If @error Then MsgBox(0,'Error - ' & @error, @extended)
 MsgBox(0, "$sHTML", $sHTML)

Now I can see the information I think I need. The only problem I see is:

1. I can't search in the msgbox.

2. I can't copy text in the msgbox.

Then I opened the developer tools.

I used this code:

$locationurl = _IEPropertyGet($oIE, "locationurl")

 MsgBox(0, "$locationurl Status", $locationurl)

And it gave me this output:

post-6489-0-48595700-1371081771_thumb.jp

 

I think I'm ok now.  I will work on the rest of the script.

Thanks,

Docfxit

Edited by Docfxit
Link to comment
Share on other sites

looks like the right url, just pop that in to IE and use the developer tools to explore your options.  I'd just put it in the clipboard

ClipPut(_IEPropertyGet($oIE, "locationurl"))

 

You can put the html content of the page in the clipboard as well, but why bother if you can use IE's developer tools.

The code you posted where you are adding text to the page is working as expected (it's adding to the html body), but because of the layout of the page, you're not going to actually see the change visually.

Try modifying something within one of the DIVs to actually see a change.

Local $sHTML = _IEBodyReadHTML($oIE)
$sHTML = StringReplace($sHTML, "Please read the following license agreement carefully.", "<FONT color=red>Please skim over the license agreement, or ignore it completely.</FONT>")
_IEBodyWriteHTML($oIE, $sHTML)
Link to comment
Share on other sites

I have been adding each window to this script one at  a time.  I thought it might be time to see if it will run from the begging.  I'm getting stuck at the first window.

How can I run the program and wait until the first window opens?

#include <IE.au3>
#include <Array.au3>
#RequireAdmin

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 = 'Win_7' Then
    $ProgramFiles = "C:\Programs\"
Else
    $ProgramFiles = "C:\Program Files\"
EndIf

_IEErrorHandlerRegister()

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

$SerialNumber = '0123456789'
Run('C:\Dnload\9xAddons\WordPerfect Office X6 v16.0.0.318\Setup.exe')
Do
    Sleep(100)
Until WinList("[CLASS:#32770; TITLE:WordPerfect Office X6]") ; <--- It doesn't recognize this line
$aWinList = WinList("[CLASS:#32770; TITLE:WordPerfect Office X6]", "")
$oIE = _IEAttach($aWinList[1][1], "Embedded")
If @error Then MsgBox(0, 'Error - ' & @error, @extended)

The script is stopping on the Until line.  It doesn't recognize when the window pops up.

Thanks,

Docfxit

PS: When I'm in the full text editor on this web page I changed the color of:

<--- It doesn't recognize this line

to red.

When I post it the red disapears. 

How can I get the red to stay?

Edited by Docfxit
Link to comment
Share on other sites

What does the help file say that WinList returns?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Thanks for the help...

I think I'm getting closer.  It still isn't finding the window.

#include <IE.au3>
#include <Array.au3>
#RequireAdmin

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 = 'Win_7' Then
    $ProgramFiles = "C:\Programs\"
Else
    $ProgramFiles = "C:\Program Files\"
EndIf

_IEErrorHandlerRegister()

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

$SerialNumber = '0123456789'
;Run('C:\Dnload\9xAddons\WordPerfect Office X6 v16.0.0.318\Setup.exe')

While True
    $timer = TimerInit()
    Do
        Local $var = WinList()
        _ArrayDisplay($var, "WinList")
        For $i = 1 To $var[0][0]
            ; Only display visble windows that have a title
            MsgBox(0, "Title", $var[$i][0])
            If $var[$i][0] = "WordPerfect Office X6" Then
                ExitLoop
            EndIf
        Next
        Sleep(100)
    Until TimerDiff($timer) > 30000 ; thirty seconds
WEnd


$aWinList = WinList("[CLASS:#32770; TITLE:WordPerfect Office X6]", "")
$oIE = _IEAttach($aWinList[1][1], "Embedded")
If @error Then MsgBox(0, 'Error - ' & @error, @extended)
Exit

The ArrayDisplay is showing:

post-6489-0-50664400-1371147954_thumb.jp

The msgbox on line 37 never comes up.

Why doesn't the msgbox show up?

Thanks,

Docfxit

Edited by Docfxit
Link to comment
Share on other sites

Use StringInStr instead of a straight comparison to the window title. Or even better use the window title in your WinList function instead of getting all open windows.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I changed the code.  The MsgBox is showing the "WordPerfect Office X6" every time.

The If statement isn't exiting the loop.

#include <IE.au3>
#include <Array.au3>
#RequireAdmin

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 = 'Win_7' Then
    $ProgramFiles = "C:\Programs\"
Else
    $ProgramFiles = "C:\Program Files\"
EndIf

_IEErrorHandlerRegister()

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

$SerialNumber = '0123456789'
;Run('C:\Dnload\9xAddons\WordPerfect Office X6 v16.0.0.318\Setup.exe')

While True
    $timer = TimerInit()
    Do
        Local $var = WinList("WordPerfect Office X6")
        ;        _ArrayDisplay($var, "WinList")
        For $i = 1 To $var[0][0]
            ; Only display visble windows that have a title
            MsgBox(0, "Title " & $i, $var[$i][0])
            If StringInStr($var[$i][0], "WordPerfect Office X6") Then
                ExitLoop
            EndIf
        Next
        Sleep(100)
    Until TimerDiff($timer) > 30000 ; thirty seconds
WEnd


$aWinList = WinList("[CLASS:#32770; TITLE:WordPerfect Office X6]", "")
$oIE = _IEAttach($aWinList[1][1], "Embedded")
If @error Then MsgBox(0, 'Error - ' & @error, @extended)
Exit

Thanks,

Docfxit

Edited by Docfxit
Link to comment
Share on other sites

Your ExitLoop is only going to break you out of the For/Next loop, not the Do/Until or the While/Wend loops. If you want to break out of all loops to get to the next piece of code outside the While loop, you need to use "ExitLoop 3", 1 is the current loop (For loop), 2 would be the Do loop, 3 would be the While loop.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

It depends, do you need to keep looking for the window every 30 seconds if it's not there the first time around?
I'd also rewrite the While loop section like this.
 

Local $var
While True
    $timer = TimerInit()
    Do
        $var = WinList("WordPerfect Office X6")
        If $var[0][0] <> 0 Then Exitloop 2 ; if the window is found, exit both loops
        Sleep(100)
    Until TimerDiff($timer) > 30000 ; thirty seconds
WEnd

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

 

It depends, do you need to keep looking for the window every 30 seconds if it's not there the first time around?

I'd also rewrite the While loop section like this.

 

Local $var
While True
    $timer = TimerInit()
    Do
        $var = WinList("WordPerfect Office X6")
        If $var[0][0] <> 0 Then Exitloop 2 ; if the window is found, exit both loops
        Sleep(100)
    Until TimerDiff($timer) > 30000 ; thirty seconds
WEnd

I don't understand the point of the 30 second timer here.  If the window isn't found within 30 seconds, check for another 30 seconds?  Why have the timer and do loop at all then?

Link to comment
Share on other sites

Thanks for the great streem lined version.

It's continuing the script long before the correct screen that I need to wait for is coming up.

There is text on the screen.  Is it posible to wait for the text?

"End-User License Agreement"

Thanks,

Docfxit

Link to comment
Share on other sites

I don't understand the point of the 30 second timer here.  If the window isn't found within 30 seconds, check for another 30 seconds?  Why have the timer and do loop at all then?

The way I was thinking is I only want it to wait for 30 seconds once.  Just in case it didn't start properly.  I didn't want it to be in a loop forever.

Thanks,

Docfxit

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