Jump to content
GoldenMike

Script Pauses when IE Popup Opens

Recommended Posts

GoldenMike

Hi. I have been using autoit for about eight months doing data entry and web scraping using my vendors website. I am in the medical industry and we do a lot of data entry. I have successfully navigated around almost all of their website using autoit and COM. There are pages on this site where data entry has to be entered through a pop up window. When the pop up window opens my script actually pauses and will resume after the window closes. My problem is trying to manipulate the pop up window. If I manually open the popup window, and then run the script, I can access the window and manipulate the data. If i write a script that opens the window, this will not work as the script pauses and will not resume until the window is closed. I have attempted setting up two seperate files, where the first file automatically opens the pop up window, and the second script is linked to a hotkey that would automate the data entry. This does not work either.

I contacted the programmers of my software vendor and they told me they use using window.showModalDialog() to open the pop up window.

When I researched the code i got http://msdn.microsoft.com/en-us/library/ie/ms536759(v=vs.85).aspx this link.

I found this line in the above reference. "A modal dialog box retains the input focus while open. The user cannot switch windows until the dialog box is closed." The wierd thing is that manually I can click on other windows and copy and paste into the dialog box/pop up window but the script won't let me do this. As I am not a programmer and I was wondering if anyone had any advice about this.

Edited by GoldenMike

Share this post


Link to post
Share on other sites
GoldenMike

Jfish, my problem is that my code actually stops while the window is open, so anything that is being coded haults.

Share this post


Link to post
Share on other sites
qsek

only solution i can think of is to launch another process of an autoit script that detects the modal window and enteres the data with ControlSend Methods

Edited by qsek

Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite

Share this post


Link to post
Share on other sites
DaleHohm

See the second example for _IEAction in the helpfile.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites
DaleHohm

The answer is in my reply - don't overlook it.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites
GoldenMike

Dale,

I did what you asked. Just as a test i tried copying the example script into a test file, and running it. When i do this I am having the same issue as previously on my own script.

The example script won't click the ok, on the alert window. I'm assuming these problems are related, just don't understand how to fix this.

$oIE = _IE_Example ("form")
$oSubmit = _IEGetObjByName ($oIE, "submitExample")
$hwnd = _IEPropertyGet($oIE, "hwnd")
_IEAction ($oSubmit, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

; Wait for Alert window, then click on OK
WinWait("Windows Internet Explorer", "ExampleFormSubmitted")
ControlClick("Windows Internet Explorer", "ExampleFormSubmitted", "[CLASS:Button; TEXT:OK; Instance:1;]")
_IELoadWait ($oIE)

Share this post


Link to post
Share on other sites
GMK

That's probably because it can't find the window using that title. (Depending on which version of IE that is used, and which OS is used, you may need to use the AutoIt Window Info tool to find the exact title.)

#include <IE.au3>

$oIE = _IE_Example("form")
$oSubmit = _IEGetObjByName($oIE, "submitExample")
Local $hwnd = _IEPropertyGet($oIE, "hwnd")
_IEAction($oSubmit, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

; Wait for Alert window, then click on OK
WinWait("Message from webpage", "ExampleFormSubmitted")
ControlClick("Message from webpage", "ExampleFormSubmitted", "[CLASS:Button; TEXT:OK; Instance:1;]")
_IELoadWait($oIE)

Share this post


Link to post
Share on other sites
qsek

How about adding a simple ConsoleWrite after the ControlSend to see if the script actually executes any command after that point.


Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite

Share this post


Link to post
Share on other sites
qsek

Jfish, my problem is that my code actually stops while the window is open, so anything that is being coded haults.

Like the OP said in this post, i dont think you can solve this problem by adding ANY code after the modal window is being opened.

I think its just a internal windows thing that modal windows are halting the whole process and are stuck in a winproc funnction or something until the window is closed

IMO the only chance here is to access from "outside" from an second autoitscipt process


Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite

Share this post


Link to post
Share on other sites
DaleHohm

@qsek, I suggest that YOU also look at the second example for _IEAction. This is a well-known situation with a simple solution.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites
TestUser

Hello Dale,

I have been looking at the AutoIT help file for the 2nd example under _IEAction that you recommend to deal with this issue, but I am unsure how it applies if you are dealing with an _IEImgClick that leads to a pop-up (which I am in my case). I'm not sure what I should substitute for

$oSubmit = _IEGetObjByName($oIE, "submitExample")

How do I translate an image click into an object that can be sent a "click"?

Share this post


Link to post
Share on other sites
GMK

You get the window title, then use _IEAttach. (Edit: use _IEAttach, if necessary, but you can use the window title to ControlClick, as in the example.)

Edited by GMK

Share this post


Link to post
Share on other sites
GoldenMike

Dale, Qsek, GMK,

I used the AutoIt Window Tool to Change the Title of the Window as follows:

#include <IE.au3>
$oIE = _IE_Example ("form")
$oSubmit = _IEGetObjByName ($oIE, "submitExample")
$hwnd = _IEPropertyGet($oIE, "hwnd")
_IEAction ($oSubmit, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")
; Wait for Alert window, then click on OK
WinWait("Message from Webpage")
ControlClick("Message from Webpage", "", "[CLASS:Button; TEXT:OK; Instance:1;]")
_IELoadWait ($oIE)

I am still not getting any success on the the ControlClick line.

I am sorry if I am missing something, but I would assume the sample script should work straight out from the example, or even with the simple change I made? Any ideas on what is going on?

Share this post


Link to post
Share on other sites
GMK

Which version of Windows and IE are you using? Also, in your case, have you found the window title of your popup window, then used _IEAttach?

$oPopup = _IEAttach("Popup Title")

Share this post


Link to post
Share on other sites
GoldenMike

Dale & GMK,

For some reason my computer is not recognizing the pop up window.

I added a "ConsoleWrite" line after the "WinWait" line

; Wait for Alert window, then click on OK
WinWait("Windows Internet Explorer", "ExampleFormSubmitted")
ConsoleWrite("pop up")
ControlClick("Message from Webpage", "", "[CLASS:Button; TEXT:OK; Instance:1;]")
_IELoadWait ($oIE)

And nothing shows in the console.

I've tried using the original windows title in the example script, and the title from the AutoIT Windows Tool:

Also I tried this code that removed the "WinWait" command, and I put a sleep command for 5 seconds, giving the window plenty of time to open. The "ControlClick" command line does not work in this case. The console get written to, and the script ends with nothing happening.

; Wait for Alert window, then click on OK
sleep(5000)
ConsoleWrite("pop up")
ControlClick("Message from Webpage", "", "[CLASS:Button; TEXT:OK; Instance:1;]")
_IELoadWait ($oIE)

Share this post


Link to post
Share on other sites
GMK

Can you paste the contents of the AutoIT Windows tool used for the popup window here for us to see?

Edited by GMK

Share this post


Link to post
Share on other sites
GoldenMike

GMK,

Here is the results from the summary window of AutoIt Window Tool

>>>> Window <<<<
Title:  Message from webpage
Class:  #32770
Position:   -2003, 1099
Size:   245, 171
Style:  0x94C801C5
ExStyle:    0x00010101
Handle: 0x0002065E
>>>> Control <<<<
Class:  Button
Instance:   1
ClassnameNN:    Button1
Name:  
Advanced (Class):   [CLASS:Button; INSTANCE:1]
ID: 2
Text:   OK
Position:   135, 96
Size:   88, 26
ControlClick Coords:    57, 13
Style:  0x50030000
ExStyle:    0x00000004
Handle: 0x00010660
>>>> Mouse <<<<
Position:   -1803, 1238
Cursor ID:  0
Color:  0xDDDDDD
>>>> StatusBar <<<<
>>>> ToolsBar <<<<
>>>> Visible Text <<<<
OK
ExampleFormSubmitted

>>>> Hidden Text <<<<

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

×