With this function it runs IE in kiosk mode defaulting to hidden. It will make the window a child window, resize, relocate, and redraw. It will then show the window if the ShowWin flag is set to true.

It does not handle killing the process I would like to register a cleanup function if there is a way to call a function before application close. I wan't able to find a simple way to handle this just yet, so for the time being your application should call _IEQuit on application close.

Edited March 26, 2012 by slbmeh

Share this post

Link to post

Share on other sites

DaleHohm 59

DaleHohm 59

I really like what you did. I really appreciated _IECreate2, but didn't like the process polling algorithm.

I have enhanced what you posted to further follow the IE.au3 style, made it more bullet-proof and included a working example. Haven't tested all of the failure scenarios, so your testing and that of others would be good. Nice.

Notes: This modification move navigation to the URL out of the function. It creates a random URL for the initial creation so that there will be no trouble with duplicate windows. It adds a timeout waiting for the browser to be created.

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=YDoesn'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

slbmeh 1

slbmeh 1

Notes: This modification move navigation to the URL out of the function. It creates a random URL for the initial creation so that there will be no trouble with duplicate windows. It adds a timeout waiting for the browser to be created.

I like that. Duplicate windows was a concern for me, it wouldn't affect me, because I know what could screw it up... But if others were to use it, I couldn't think of how to prevent that.

One thing I have encountered with this method is that if you use _IEPropertyGet for hwnd after you set parent it will give the parent handle and not that of the actual IE window. Do you know if there is a better way to get the handle?

I currently have this piece of code that I do not like, because I have multiple child windows and if one is open it doesn't always give expected results.

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=YDoesn'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

wraithdu 69

wraithdu 69

I'm uncertain as to how much benefit a ByRef would be, generally the same downside as a Global with added complexity.

Absolutely not. You add one byref parameter to the function call ie ByRef $hWnd, and pass in a variable of your choosing, both in name and scope. The function sets that var to the created window hwnd before changing its parent. You can do what you want with it after that. This way you can keep the same object return as the standard UDF functions.

Edited March 27, 2012 by wraithdu

Share this post

Link to post

Share on other sites

slbmeh 1

slbmeh 1

Absolutely not. You add one byref parameter to the function call ie ByRef $hWnd, and pass in a variable of your choosing, both in name and scope. The function sets that var to the created window hwnd before changing its parent. You can do what you want with it after that. This way you can keep the same object return as the standard UDF functions.

My mention of added complexity was not of the function itself, but in applied use cases. Adding a ByRef parameter isn't difficult, but it would add a mandatory parameter that would not be necessary in many cases adding unnecessary complexity to the third party code using this function.

Share this post

Link to post

Share on other sites

DangerousDan 1

DangerousDan 1

I really like what you did. I really appreciated _IECreate2, but didn't like the process polling algorithm.

I have enhanced what you posted to further follow the IE.au3 style, made it more bullet-proof and included a working example. Haven't tested all of the failure scenarios, so your testing and that of others would be good. Nice.

Dale

Dale,

You don't need to use IEAttach at all... create the object, assign it theatre mode, full screen, and hide the status bar if you need to. So far I have found that the embedded object doesn't automatically take the focus when you selet the GUI title bar, so I added an "if winactive then winactivate" line in my main program loop. I'm sure there is a better solution, but I'm still not exactly an expert with GUI's... more like a seasoned amatuer:)

Also of note: the vertical scroll bars do not redraw every time the window is resized, the GUI background color is shown until you mouseover the scroll bars or an element in the webpage that changes with the mouseover (button that emboldens, for example). I'm using _WinAPI_MoveWindow to move the embedded object when the parent moves, and have even tried manually redrawing the window after the move, hiding and unhiding it... many unconventional things as well as everything I could search for that was within my capabilities at this point, all to no avail. I worked around this by turning the scroll bars off and then back on any time the window is resized. It's a little messy visually, but it works.

I'm using autoit to scrape customer account numbers, as they are viewed by sales in our AS400, to pull up in Salesforce.com. Most of our sales people are on thin clients. I had to find a way of getting the object without using the collections method in the IEAttach function... for some reason this part of the function always gets stuck in an endless loop on our thin clients.Took me forever to figure out that was the issue, and then quite awhile to figure out a way around it. The above methods work perfectly on a PC, but my solution works in our very restrictive thin client environment and appears to be more efficient in my limited experience.

Your posts have been instrumental in my own coding, thank you for your posts and any criticism you may be wiling (anyone for that matter) to give on my code below.

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=YDoesn'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

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=YDoesn'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

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=YDoesn'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

Sign in

Similar Content

I was wondering how I read data inside of a iframe. I would like to be able to click something inside a iframe. However, I can't even find the tag.
The id and name change all the time so I can't use those.
The code highlighted in blue is what I am trying to click. (second picture)
Here is what I have tried.
$target = ""
$tags = $oIE.document.GetElementsByTagName("div")
For $tag in $tags
$class_value = $tag.GetAttribute("class")
If string($class_value) = "s_92 altstyle s_93 s_94" Then
$target = $tag
ConsoleWrite("Tag Found " & $target.outerText&@CRLF)
ExitLoop
EndIf
Next

WinActivate("MEDITECH - Internet Explorer")
Sleep (500)
$oIE = _IEAttach("MEDITECH")
$oDiv1 = _IEGetObjById($oIE, "sysmenu-searchbarbutton")
_IEAction($oDiv1, "click")
I am just trying to click the little magnifying glass, next to the gear button with no luck. I was hoping someone might have an idea why this is not working?

I am trying to type a name in patient summary search box. How should I go about doing this. I am clearly not doing it right. (Attached Picture of HTML code.)
This is what I have tried. I assume this is not working because it is not a form?
WinActivate("MEDITECH - Internet Explorer")
Sleep (500)
$oIE = _IEAttach("MEDITECH")
$oForm = _IEFormGetObjByName($oIE, "systemMenu")
$oText = _IEFormElementGetObjByName($oForm, "sysmenu-searchbarinput")
_IEFormElementSetValue($oText, "Hey! This works!")

I have a script that opens some Excel books that are stored in SharePoint . Without getting to much into detail as its a very long story I have to open Internet Explorer to the SP site in order for all of this crap to work.

Anyway I have a bit of code in my script that i found via google-fu
$ieList = ProcessList("iexplore.exe")
If IsArray($ieList) Then
For $I = 1 To Ubound($ieList) -1
ProcessWaitClose($ieList[$I][1])
Next
EndIf
Exit
Now on Windows 7 this bit works great. On Windows Server 2012 R2 where this things runs is another story. I need to be able to force close all instances of Internet explorer that are running as part of my code.