Jump to content
Sign in to follow this  
JayFran

IE Focus issue

Recommended Posts

JayFran

I writing a script for myself to make life easier for me, my issue come when I try to click on links to open file upload boxes or to click on a input to send some information there. I understand what i am doing wrong. please help me with a solution.

#include <ie.au3>
#include<Debug.au3>

$oIE = WinActivate("Changes - Windows Internet Explorer")
$changes = _IEGetObjByName($oIe, "mx583")
$hwnd = _IEPropertyGet($oIE, "hwnd")
_IEAction($changes, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")
_IELoadWait ($oIE))

Share this post


Link to post
Share on other sites
DaleHohm

This is just wrong on so many levels:

$oIE = WinActivate("Changes - Windows Internet Explorer")

Please look at _IEAttach

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
JayFran

This is just wrong on so many levels:

$oIE = WinActivate("Changes - Windows Internet Explorer")

Please look at _IEAttach

Dale

My apologies. Im new. I've been working at this code all day. here's what i got so far. its still not working though.

#include <ie.au3>
#include<Debug.au3>
WinActivate("[fusion:CompanyName] - Windows Internet Explorer")
$hwnd = WinGetHandle("[CLASS:Internet Explorer_Server; INSTANCE:1]")
 $oIE = _IEAttach ($hwnd, "text")
 _IELinkClickByText($hwnd, "Return")
 _IELoadWait($oIE)
;ControlClick($oIE, "", "[CLASS:Button; INSTANCE:1]", "{Enter}")
;ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

and the other one is

#include <ie.au3>
#include<Debug.au3>

$t_number = "C4534"

WinActivate("Changes - Windows Internet Explorer")
$oIE = _IEAttach("Changes - Windows Internet Explorer")
$changes = _IEGetObjById($oIe, "mx583")
$hwnd = _IEPropertyGet($oIE, "hwnd")
_IEAction($changes, "focus")
ConsoleWrite($t_number)
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

I really am trying, I like to figure things out myself, but I also know when to ask for help especially if im not knowledgable on the matter. I appreciate the feedback.

Edited by JayFran

Share this post


Link to post
Share on other sites
DaleHohm

A lot of work went into creating quality examples for all of the IE functions. I must assume that you have not yet worked through any of them -- don't just look at them, run them, they are all self-contained and fully functional.

The reason I say this is that you are not passing the right kinds of parameters to the functions and by running the examples you will start to understand how they work.

Also, make sure you run your code in SciTe with F5 and then watch the console carefully for the messages written there and take the time to figure out what they mean.

As another hint, look at _IEAttach with the windowtitle parameter.

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
JayFran

A lot of work went into creating quality examples for all of the IE functions. I must assume that you have not yet worked through any of them -- don't just look at them, run them, they are all self-contained and fully functional.

The reason I say this is that you are not passing the right kinds of parameters to the functions and by running the examples you will start to understand how they work.

Also, make sure you run your code in SciTe with F5 and then watch the console carefully for the messages written there and take the time to figure out what they mean.

As another hint, look at _IEAttach with the windowtitle parameter.

Dale

Thanks Dale. I read thru the Help Files and ran a few examples. I've written some code without any errors ;) now the only thing is that its not clicking on the Return button. I'm in need of another critique. Any help is appreciated as always.

Hopefully, this code looks better then my 1st code.

#include <ie.au3>
#include<Debug.au3>

AutoItSetOption("WinTitleMatchMode", 4)
WinActivate("[fusion:CompanyName] - Windows Internet Explorer")
$hwnd = WinGetHandle("[CLASS:Internet Explorer_Server; INSTANCE:1]")
$oIE = _IEAttach ("[fusion:CompanyName]", "windowtitle")
ControlClick("[fusion:CompanyName] - Windows Internet Explorer", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

Share this post


Link to post
Share on other sites
JayFran

A lot of work went into creating quality examples for all of the IE functions. I must assume that you have not yet worked through any of them -- don't just look at them, run them, they are all self-contained and fully functional.

The reason I say this is that you are not passing the right kinds of parameters to the functions and by running the examples you will start to understand how they work.

Also, make sure you run your code in SciTe with F5 and then watch the console carefully for the messages written there and take the time to figure out what they mean.

As another hint, look at _IEAttach with the windowtitle parameter.

Dale

#include <ie.au3>
#include<Debug.au3>

AutoItSetOption("WinTitleMatchMode", 4)
WinActivate("[fusion:CompanyName] - Windows Internet Explorer")
$oIE = _IEAttach ("[fusion:CompanyName]", "windowtitle")
ControlClick("[fusion:CompanyName] - Windows Internet Explorer", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "left",1,1052,120)

If I put in the coordinates it works. the only porblem is the window has to be maximized and i have a bigger screen then

some of the other cpu's. i need a more robust way to complete this function. ill still be working on that until then. I also noticed that in the Window Info pan there is no name, text or id for this return button.

Share this post


Link to post
Share on other sites
DaleHohm

The Internet Explorer content area is a single windows control so you will not see other contrls embedded in it... instead it uses domething called the DOM (Document Object Model) to work with the content. This is the main focus of the IE.au3 library.

Please read about _IEGetObjByID and _IEAction, click

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
PsaltyDS

Doesn't have much to do with the IE UDF, but I notice something about your window title; that it looks too much like an advanced title spec, but isn't. Note this demo:

$hGUI_1 = GUICreate("[fusion:CompanyName]", 300, 300, 200, 200)
GUISetState(@SW_SHOW, $hGUI_1)

$hGUI_2 = GUICreate("{fusion:CompanyName}", 300, 300, 600, 600)
GUISetState(@SW_SHOW, $hGUI_2)

MsgBox(64, "Titles", "[fusion:CompanyName] = " & WinGetTitle("[fusion:CompanyName]", "") & @CRLF & _
        "{fusion:CompanyName} = " & WinGetTitle("{fusion:CompanyName}", ""))

Do
Until GUIGetMsg() = -3

The window title is returned for "{fusion:CompanyName}", but not for "[fusion:CompanyName]". The reason is AutoIt thinks you are trying to use an advanced spec, but with an unrecognized property name "fusion". An example of the usual syntax would be: "[CLASS:IEFrame; TITLE:Google]".

This applies to native AutoIt window title matching. The _IEAttach() function doesn't use that and so wouldn't be confused, but WinActivate() and ControlClick() would.

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
JayFran

The Internet Explorer content area is a single windows control so you will not see other contrls embedded in it... instead it uses domething called the DOM (Document Object Model) to work with the content. This is the main focus of the IE.au3 library.

Please read about _IEGetObjByID and _IEAction, click

Dale

Thats sounds good Dale, but the only problem with that is there is no ID for this object. I've been trying multiple ways to click on this button but am having a difficult time doing so. I'm posting the print screens of the page and the attributes of that page. Is there something that can be done with the outerhtml even though it hidden?

And here is my new code I written for this so far. There is actually 3 scenarios for errors and I managed to write script for 2 of the three. this one is a real pain.

#include <ie.au3>
#include<Debug.au3>

AutoItSetOption("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("WinTextMatchMode", 1)
$oIE = _IECreate("https://129.39.231.133/maximo/webclient/login/loginerror.jsp")
Sleep(1100)
If $oIE = "https://129.39.231.133/maximo/webclient/login/loginerror.jsp" Then 
    $error_return = _IEAttach("{fusion:CompanyName}", "windowtitle");tried taking PsaltyDS advice and switching from "[]" to "{}"
    ControlClick($oIE, "Return", "", "left", 1)
EndIf

post-59549-12825697248311_thumb.jpg

post-59549-12825697320465_thumb.jpg

Share this post


Link to post
Share on other sites
JayFran

Doesn't have much to do with the IE UDF, but I notice something about your window title; that it looks too much like an advanced title spec, but isn't. Note this demo:

$hGUI_1 = GUICreate("[fusion:CompanyName]", 300, 300, 200, 200)
GUISetState(@SW_SHOW, $hGUI_1)

$hGUI_2 = GUICreate("{fusion:CompanyName}", 300, 300, 600, 600)
GUISetState(@SW_SHOW, $hGUI_2)

MsgBox(64, "Titles", "[fusion:CompanyName] = " & WinGetTitle("[fusion:CompanyName]", "") & @CRLF & _
        "{fusion:CompanyName} = " & WinGetTitle("{fusion:CompanyName}", ""))

Do
Until GUIGetMsg() = -3

The window title is returned for "{fusion:CompanyName}", but not for "[fusion:CompanyName]". The reason is AutoIt thinks you are trying to use an advanced spec, but with an unrecognized property name "fusion". An example of the usual syntax would be: "[CLASS:IEFrame; TITLE:Google]".

This applies to native AutoIt window title matching. The _IEAttach() function doesn't use that and so wouldn't be confused, but WinActivate() and ControlClick() would.

;)

Thanks, I see your point. I'll have to watch out for that then. In the meantime I will try to figure something out for this button click. I tried to use the controlclick but that doesnt seem to be working.

Share this post


Link to post
Share on other sites
DaleHohm

There are many ways of getting a reference to a DOM element... if there is no ID, then take a look at _IETagnameGetCollection($oIE, "button", your-zero-based-index)

Also, _IECreate does NOT return a URL, but rather an object reference... please work through some of the example in the helpfile and do a little more reading.

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
JayFran

There are many ways of getting a reference to a DOM element... if there is no ID, then take a look at _IETagnameGetCollection($oIE, "button", your-zero-based-index)

Also, _IECreate does NOT return a URL, but rather an object reference... please work through some of the example in the helpfile and do a little more reading.

Dale

I've been working on this problem. I found that the Tag name=BUTTON and the innertext=Return. Im not not of how to go about the next step. If i use something like the bodyread or html read it will only read it as a whole. I cant figure out how to make it close in on the tage name then ignite a click. Any help is appreciated.

Share this post


Link to post
Share on other sites
PsaltyDS

I've been working on this problem. I found that the Tag name=BUTTON and the innertext=Return. Im not not of how to go about the next step. If i use something like the bodyread or html read it will only read it as a whole. I cant figure out how to make it close in on the tage name then ignite a click. Any help is appreciated.

Did you try _IEGetObjByName() or _IEFormElementGetObjByName()?

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
JayFran

Finally! I got it to work. Here is the final code snippet.

@Dale I only used _IECreate for testing out a specific error I was working on at the time. Im going to add this part into the final code in case one of the errors come up.

Thanks for your help as always. i appreciate it.

#include <ie.au3>
#include<Debug.au3>

AutoItSetOption("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("WinTextMatchMode", 1)
$oIE = _IECreate("https://129.39.231.133/maximo/webclient/login/loginerror.jsp", 1, 1, 1, 1)
_IELoadWait($oIE)

If $oIE <> _IEAttach("Start Center", "windowtitle") Then $oP = _IETagNameGetCollection($oIE, "button", 0)
$return = _IEAction($oP, "click")

Share this post


Link to post
Share on other sites
JayFran

Did you try _IEGetObjByName() or _IEFormElementGetObjByName()?

;)

Yup. There was no name, id, form, or link. It was only a button node and text with some jsp.

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  

×