b0br0ff Posted July 11, 2007 Share Posted July 11, 2007 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. Link to comment Share on other sites More sharing options...
SadBunny Posted July 11, 2007 Share Posted July 11, 2007 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");EndIfThen 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");EndIfMy 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. Link to comment Share on other sites More sharing options...
MHz Posted July 11, 2007 Share Posted July 11, 2007 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 @SadBunny WinTitleMatchMode 4 syntax includes the syntax of WinTitleMatchMode 1 Link to comment Share on other sites More sharing options...
b0br0ff Posted July 11, 2007 Author Share Posted July 11, 2007 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! Link to comment Share on other sites More sharing options...
SadBunny Posted July 11, 2007 Share Posted July 11, 2007 @SadBunnyWinTitleMatchMode 4 syntax includes the syntax of WinTitleMatchMode 1 I stand corrected - it's right there in the help file now that I looked more closely Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
b0br0ff Posted July 11, 2007 Author Share Posted July 11, 2007 I stand corrected - it's right there in the help file now that I looked more closely It is really strange but window "File Download" can be found only after IE window is closed, it is really strange ... Link to comment Share on other sites More sharing options...
SadBunny Posted July 11, 2007 Share Posted July 11, 2007 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. Link to comment Share on other sites More sharing options...
SadBunny Posted July 11, 2007 Share Posted July 11, 2007 Trying to reproduce now... Got heavily distracted... Something with a woman. 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now