Sign in to follow this  
Followers 0
sc4ry

click java-button (or is it an image?)

9 posts in this topic

#1 ·  Posted (edited)

Hello,

i´m new in creating autoit-scripts and a german user (so my english wouldn´t be the best *g*)

now i have the problem clicking a button, and i hope, you can help me.

i hope that i got nearly all information you need to help me, so if not, please contact me and i try to find more =)

that´s my script

#include <IE.au3>
$sUrl = "http://intranetlink"
$sUsername = InputBox("UserID", "Bitte geben Sie Ihre UserID ein", "", "", 10, 10 )
$sPassword = InputBox("Passwort", "Bitte geben Sie Ihr Passwort ein", "", "*", 10, 10)
$oIE = _IECreate ($sUrl,0,1,1,0)
$oHWND = _IEPropertyGet($oIE, "hwnd")
WinSetState ($oHWND, "", @SW_MAXIMIZE )
$oForm = _IEFormGetCollection ($oIE, 0)
$oUsername = _IEFormElementGetObjByName ($oForm, "user")
$oPassword = _IEFormElementGetObjByName ($oForm, "password")
$oSelect = _IEFormElementGetObjByName ($oForm, "language")
_IEFormElementSetValue ($oUsername, $sUsername)
_IEFormElementSetValue ($oPassword, $sPassword)
_IEFormElementOptionselect ($oSelect, "German", 1, "byText")
_IEFormSubmit ($oForm)  

$LinkProdukte = "http://justanotherintranetlink"
_IENavigate($oIE, $LinkProdukte)
_IELoadWait($oIE)

now you can see on the following pic the button, i want to click (it´s for printing) and in ie left bottom you can read that it is javascript (java script:pm_divider('express')), at least i think so =). the properties of the "button" show the path for a gif-pic, the button uses. in the sourcecode i can´t find anything about the gif or or the javascript-name, only for the little yellow pop-up, if the mouse camps on the button.

but there is only:

//Array for language dependent button descriptions

buttontexts = new Array("Standarddruck");

function set_columns()

i´m nearly a noob in html and also java, so i don´t know where to search and what to search for. maybe it contains all information you want to know.

but _IEImgClick($oIE, s_f_prnt.gif) does not work (maybe only, because the site is not fully loaded when autoit goes on with the next step). the link i navigate to, is a bookmark which i only can start, when i logged in before.

post-22776-1177501228_thumb.jpg

Edited by sc4ry

Share this post


Link to post
Share on other sites



Based on your description, parts of the page are being dynamical generated. I suggest you use _IEBodyReadHTML to examine the active source and see if You can get further. Then post the relevant HTML and the code you have tried.

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

Check the parameters for _IEImgClick(), the third parameter specifies the search mode.

_IEImgClick($oIE, s_f_prnt.gif, "name")

I thought I posted this about an hour ago, but I forgot to hit "Add Reply" :shocked:

Share this post


Link to post
Share on other sites

hmm, nothing will work.

with ImgClick nothing happend and BodyReadHTML only gives back "0".

ImgClick would be a nice thing, but i think, i doesn´t work, because in the source code the gif does not exist =(

thank your for your help, but i become desperate with these topic =(

but another thing i don´t get is, why autoit goes on with the next step, while the page is loading with _IENavigate???

i think the only solution is my old solution. mouseclick and sleep =(

Share this post


Link to post
Share on other sites

I'm guessing Frames are involved... try _IEDocReadHTML instead of _IEBodyReadHTML (a FRAMESET has no body) and then read up on _IEFrame*

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

Whenever I run into a java button on the Dell website (where I spend a lot of time), I use code like this to click the button the old-fashioned way:

$realsize = WinGetPos("Dell.com - Login - K-12 Education - Windows Internet Explorer")
    MouseClick("Left",$realsize[0]+60,$realsize[1]+578) ; 3 and 17 greater than next values
    MouseClick("Left",$realsize[0]+62,$realsize[1]+565)
    MouseClick("Left",$realsize[0]+208,$realsize[1]+565)
    sleep(3000)

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

hey, thank you (all) for your help.

hope i can try your solution today. but does it solve the problem of different monitor resolutions?

and another question. because IELoadWait (Navigate) does not work (don´t really know why, maybe only a port of the site is reloaded), might there be another solution than sleep?

i request different sites from a server, and it depends on the capacity of the server, how long it will take. and if the side isn´t complete, autoit clicks on non existing buttons. any idea?

Share this post


Link to post
Share on other sites

Frames can be a pain, but figuring them out will address your questions.

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

#9 ·  Posted (edited)

The way I handle different screen resolutions is through a cheezy hack: First, I make sure that IE is maximized. Then I send multiple mouseclicks to the locations of the hyperlink or button in several different scenarios. For example, in 1024x768 I click at 30,30, while in 1280x1024 I click at 45,45. My code includes both clicks. However, this requires that there is nothing else in those same locations that will be clicked by accident. In my case, with the Dell website, most of the screens where the java buttons appear are mostly empty and doing the "shotgun approach" works fine. However, it is also dependent on how many rows your task bar has, whether or not you have the favorites window open, etc.

Certainly if DaleHolm's approach works in your case, that is by far the better approach. In my case, there were not frames, but just java encrusted hyperlinks that could not be reached by the IE.au3 functions (with my limited skills)...

Keep in mind that the target website will change in obvious (buttons move) and subtle ways (object names change), so be prepared to regularly update your code.

jefhal

hey, thank you (all) for your help.

hope i can try your solution today. but does it solve the problem of different monitor resolutions?

Edited by jefhal

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

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