Sign in to follow this  
Followers 0
b0br0ff

Problem with finding the window

8 posts in this topic

Hi all and thank U in advance. I have a problem with finding a window. I need to open IE and download file to local machine, when needed link is clicked opens "File Download" dialog and I need to click "Open" button. And here is the problem, I can't find this window!!! Below U can find the code that does not work:

CODE
#include <IE.au3>

;Opt("WinWaitDelay",250)

AutoItSetOption("WinTitleMatchMode", 4)

$oIE = _IECreate("http://qa/calltrace/")

_IELinkClickByText($oIE, "Archives")

_IELinkClickByIndex($oIE, 1)

$handle = WinGetHandle("File Download")

If @error Then

MsgBox(4096, "Error", "Could not find the correct window")

Else

MsgBox(0, "Message", "Found")

Send("!O");

EndIf

Then I tried to execute just a part of the mentioned code (in separate script) and it works! It is able to find specified window!

CODE
$handle = WinGetHandle("File Download")

If @error Then

MsgBox(4096, "Error", "Could not find the correct window")

Else

MsgBox(0, "Message", "Found")

Send("!O");

EndIf

My opinion is that including library "<IE.au3>" affects other functions.

Share this post


Link to post
Share on other sites



Hi all and thank U in advance. I have a problem with finding a window. I need to open IE and download file to local machine, when needed link is clicked opens "File Download" dialog and I need to click "Open" button. And here is the problem, I can't find this window!!! Below U can find the code that does not work:

CODE
#include <IE.au3>

;Opt("WinWaitDelay",250)

AutoItSetOption("WinTitleMatchMode", 4)

$oIE = _IECreate("http://qa/calltrace/")

_IELinkClickByText($oIE, "Archives")

_IELinkClickByIndex($oIE, 1)

$handle = WinGetHandle("File Download")

If @error Then

MsgBox(4096, "Error", "Could not find the correct window")

Else

MsgBox(0, "Message", "Found")

Send("!O");

EndIf

Then I tried to execute just a part of the mentioned code (in separate script) and it works! It is able to find specified window!

CODE
$handle = WinGetHandle("File Download")

If @error Then

MsgBox(4096, "Error", "Could not find the correct window")

Else

MsgBox(0, "Message", "Found")

Send("!O");

EndIf

My opinion is that including library "<IE.au3>" affects other functions.

In your first script, you set WinTitleMatchMode to 4, meaning advanced mode. Then you are looking for the window in normal WinTitleMatchMode syntax. That shouldn't work. In the second example you didn't set the WinTitleMatchMode, thus defaulting it to 1 (match the title from the start). Thus it does work.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

The issue is perhaps that the window does not exist at the time that you use WinGetHandle(). Try using a WinWait() to pause the script until the window does appear.

Try this

#include <IE.au3>

;Opt("WinWaitDelay",250)
AutoItSetOption("WinTitleMatchMode", 4)

$oIE = _IECreate("http://qa/calltrace/")
_IELinkClickByText($oIE, "Archives")
_IELinkClickByIndex($oIE, 1)

WinWait("File Download")
$handle = WinGetHandle("File Download")
If @error Then
    MsgBox(4096, "Error", "Could not find the correct window")
Else
    MsgBox(0, "Message", "Found")
    Send("!O");
EndIf

:whistle:

@SadBunny

WinTitleMatchMode 4 syntax includes the syntax of WinTitleMatchMode 1 :lmao:

Share this post


Link to post
Share on other sites

In your first script, you set WinTitleMatchMode to 4, meaning advanced mode. Then you are looking for the window in normal WinTitleMatchMode syntax. That shouldn't work. In the second example you didn't set the WinTitleMatchMode, thus defaulting it to 1 (match the title from the start). Thus it does work.

Thanks, I set WinTitleMatchMode to 1 and now it works, but anyway something is wrong here because it takes minutes to find needed window!

Share this post


Link to post
Share on other sites

@SadBunny

WinTitleMatchMode 4 syntax includes the syntax of WinTitleMatchMode 1 :lmao:

I stand corrected - it's right there in the help file now that I looked more closely :whistle:


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

I stand corrected - it's right there in the help file now that I looked more closely :whistle:

It is really strange but window "File Download" can be found only after IE window is closed, it is really strange ...

post-25011-1184148275_thumb.png

Share this post


Link to post
Share on other sites

It is really strange but window "File Download" can be found only after IE window is closed, it is really strange ...

Trying to reproduce now...


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

Trying to reproduce now...

Got heavily distracted... Something with a woman. :whistle:

Anyway, I created an online website with a one link with a useless text file called uselessfile.xyz on it, and have no trouble with immediately finding the window even though the parent IE window remains open. I even reactivated the default XP theme for testing... Weird indeed.

#include <IE.au3>

;Opt("WinWaitDelay",250)
AutoItSetOption("WinTitleMatchMode", 4)

$oIE = _IECreate("http://members.chello.nl/~b.bergsma5")
_IELinkClickByIndex($oIE,0)

WinWait("Bestand downloaden"); <- "File Download" in Dutch
MsgBox(0,"test","File Download dialog window present.")
Exit

Roses are FF0000, violets are 0000FF... All my base are belong to you.

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