Can't activate Java icon. Please help.

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Jaylee
Junior Coder
Posts: 45
Joined: Wed Feb 08, 2006 4:48 am

Can't activate Java icon. Please help.

Post by Jaylee » Tue Feb 14, 2006 4:12 am

G'day,

I am using Version 6 on XP with IE6.

I need to print information which is displayed by Internet Explorer on a normal html page. Printing the page in this raw format uses many more printed pages and the end result is quite messy and difficult for people needing to process the request. The IE6 page has a Java (printer shaped) icon on it which is usually activated manually by left clicking with the mouse. This loads the printable version of the information and this provides a far better format for printing and manual actioning.

When I hover over the icon, IE displays the following at the bottom of the window: Shortcut to javascript:ShowPrintPage(). The tag which shows next to the mouse pointer when hovering reads: Printer friendly version.

I tried using the code, below to locate the icon and activate it so it loads the printable page:

Let>ShowPrintPage()=PrintIcon
SetFocus>Myname Web Form*
Send>PrintIcon
//I also tried LClick for the next action to emulate the mouse.
Press ENTER



I could have sworn this worked with the Press ENTER option on my laptop over the weekend but now I am
doubting my sanity because I simply cannot replicate this on the desktop PC.

Can anybody help, please? I am still very much a raw beginner with using this application so please be very exact when explaining where I am going wrong, and whether I can actually get a result using this code. (I've gone back to emulating a mouse click on the icon for the moment simply to get the code running.)

I really appreciate any assistance you can give.

TIA. :D

J.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Feb 14, 2006 7:44 am

You *Might* be able to get it to work by typing this into the address bar of IE:

Javascript:ShowPrintPage()

Try it manually, if it works you're in luck and you can make the macro do this. If not, forget it, you need to click on the icon.

Using mouse coordinates to click on the icon is, of course, unreliable as the page and icon can move. The only reliable way to do it would be to use the Image Recognition Library. You'd also need the latest version of Macro Scheduler.

http://www.mjtnet.com/imagerecognition.htm
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Jaylee
Junior Coder
Posts: 45
Joined: Wed Feb 08, 2006 4:48 am

Post by Jaylee » Tue Feb 14, 2006 10:16 am

Hello Marcus,

Thank you for the tip. Typing Javascript:ShowPrintPage() into the address bar works and brings up the printable page. (At least I may not be going totally insane ... I was sure I was getting a result on the laptop yesterday and thought I had the code the same when I entered it onto the desktop).

I am really new at this. Could I please ask for assistance with how to use this information with code as it seems whatever I tried yesterday isn't working now?

BTW ... I would love a later version. Still working on the boss ... :D

TIA.

J.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Feb 14, 2006 10:25 am

Hi,

Just send that text to the address bar. Alt-d accesses the address bar quickly, so:

Press ALT
Send>d
Release ALT
Send>Javascript:ShowPrintPage()
Press Enter

Keep working on the boss because automating IE is a thousand times simpler with WebRecorder! With WebRecorder you could just have recorded that.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Jaylee
Junior Coder
Posts: 45
Joined: Wed Feb 08, 2006 4:48 am

Post by Jaylee » Tue Feb 14, 2006 11:20 am

Marcus, you're a life saver!

I'll give this a go in the morning. It's a bit late in the evening here and I really should go home.

Thanks again.
J.

Jaylee
Junior Coder
Posts: 45
Joined: Wed Feb 08, 2006 4:48 am

Post by Jaylee » Wed Mar 08, 2006 1:48 am

Hi,

I am now working with V8.

My problem is with the delay which sometimes occurs when a web page loads. My code activates a hyperlink. IE6 opens a new window to follow the link and often shows "Done" in the status bar although the screen remains blank. I have used WaitWindowOpen to allow the IE window the time required to open and load. If it hasn't within the timeout period, an additional wait period has been applied. This is okay except in the situation where IE says it's finished but the screen remains stubbornly blank for a very extended period of time. So my code then merrily accesses the address bar and tells the Java print icon to activate. Result = doesn't happen because the Java icon hasn't appeared (or anyting else for that matter) on the web page.

I don't have WebRecorder at this stage (and I'm unlikely to get approval to buy it in the near future). Is there another function I could use? I thought about FindWindowWithText but the window which contains the hyperlink the code originally activated needs to remain open for other functions and contains a great deal of text the same as the Web page so may be unreliable as a workaround. Worst case, I suppose, is closing the first window, using FindWindowWithText and reopening the first window at a later point for further action. This would greatly slow down the whole process and severely test my very basic skills with code writing.

Any suggestions would be greatly appreciated.

TIA. :D
J.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Mar 08, 2006 3:45 am

How are you opening IE? The best (support recommended) way to handle opening pages is:

VBSTART
Dim IE
Sub CreateIE
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = 1
End Sub

Sub Navigate(URL)
IE.navigate URL
End Sub

Sub WaitBusy
do while IE.Busy
loop
End Sub

Sub DestroyIE
IE.Quit
Set IE = Nothing
End Sub

VBEND

VBRun>CreateIE
VBRun>Navigate,http://www.whatever.com
VBRun>WaitBusy
.
.
.
do stuff
.
.
//then close IE
VBRun>DestroyIE

Jaylee
Junior Coder
Posts: 45
Joined: Wed Feb 08, 2006 4:48 am

Post by Jaylee » Wed Mar 08, 2006 7:29 am

Hello Me-again,

Thank you for the suggestion. I had a go with the code you supplied and changed the URL to reflect a known internet site but when IE started it tried to go to a site I didn't recognise. Trust me when I say this VBScript code is way out of my league at the moment as I have never used VBScript. In fact, I've not long been using Macro Scheduler script (I am using the "Beginners" forum for a VERY good reason!! :lol: )

IE opens in the script I have developed as a direct result of activating a hyperlink contained in the body of an email message. Every hyperlink is different as these point to web forms submitted by different users and contained on a server. The hyperlinks can also be positioned in different places in the message body as other factors determine the length of the entire message.

Right now, I am using very basic (but effective) code as follows:


SetFocus>Approved Application*
//Locates hyperlink using the "Find" window
Press F4
Send>http
PushButton>Find,&Find Next
//Removes highlighting from Find result to allow hyperlink to activate
Press RIGHT
//Activates hyperlink
Press ENTER

It is at this point that the IE window opens but then may have a lengthy delay with the data appearing on the page even though IE says it is "Done".

I'll try hunting around this forum and the Internet in general to get some clues on how to understand VBScript. I'll also try to get some info on learning this script as I think I'll be needing it. :D

Kind regards, :D
J

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Mar 08, 2006 9:08 am

Jaylee,

The **ONLY** way of reliably waiting for the page to finish loading is to use the VBScript method, which controls IE via it's own interface. IE provides you a property called Busy. This is beautifully convenient - yes, IE actually GIVES you a property called Busy and when it has stopped loading the page it sets it to false. Wow! This makes life so wonderfully simple. ALL we need to do then is navigate the page and wait for this busy flag to go false.

Two ways of doing that in Macro Scheduler: 1) use VBScript as suggested by Me_again, 2) use WebRecorder, which wraps this all up, lets you record it and makes it a bit easier.

Try this really simple example:

VBSTART
Dim IE

Sub CreateIE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible=1
End Sub

Sub Navigate(URL)
IE.Navigate URL
End Sub

Sub WaitBusy
do while IE.Busy
loop
End Sub

Sub KillIE
IE.Quit
Set IE = nothing
End Sub

VBEND

//do this once at start
VBRun>CreateIE

//use this when you want to navigate
VBRun>Navigate,http://www.mjtnet.com

//use this to wait for the page to finish loading
VBRun>WaitBusy
MessageModal>Done!

...


P.S. - Don't be overwhelmed by the VBScript - you don't even need to modify 90% of it ... the bits before VBSTART and VBEND are given - you don't even need to try to understand it. Just paste it in and forget about it. All you need to understand are these SIMPLE bits:

//do this once at start
VBRun>CreateIE

//use this when you want to navigate
VBRun>Navigate,http://www.mjtnet.com

//use this to wait for the page to finish loading
VBRun>WaitBusy
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Jaylee
Junior Coder
Posts: 45
Joined: Wed Feb 08, 2006 4:48 am

Post by Jaylee » Wed Mar 08, 2006 12:33 pm

G'day Marcus,

Thank you for the further example and explanation. This code operated perfectly with no modification. I'll have a play to see how best to adapt it once my existing code has begun to follow the hyperlink.

Kind regards, :D
J.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Mar 08, 2006 12:50 pm

Just make sure you start IE by using the CreateIE code first, EVEN if you send keystrokes to it using your existing methods. Instead of running internet explorer you should use:

VBRun>CreateIE

This ensures that your script then knows about the IE object and can later use the Busy property. If you start it with Run Program or Execute File or grab an existing window the script won't know about it and you won't be able to use Busy.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Mar 08, 2006 2:21 pm

Jaylee wrote:G'day Marcus,

Thank you for the further example and explanation. This code operated perfectly with no modification. J.
Could someone kindly point out the error in the code I posted :cry:

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Mar 08, 2006 2:29 pm

Nothing wrong with it - it is identical to mine, save for the URL.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Mar 08, 2006 7:57 pm

Ah, seems there is a whatever.com, I need to stop using that :oops:

Jaylee
Junior Coder
Posts: 45
Joined: Wed Feb 08, 2006 4:48 am

Post by Jaylee » Thu Mar 09, 2006 8:13 am

Hello Me_again,

It's a safe bet it was me and not your code! :lol:

Thanks.

J.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts