How can I wait until the Hourglass finishes?
Moderators: JRL, Dorian (MJT support)
-
- Newbie
- Posts: 1
- Joined: Wed Jun 15, 2005 12:16 pm
How can I wait until the Hourglass finishes?
I have a script that runs a program which refreshes about 50 graphs from a database. The graphs take anything from a couple of seconds to two minutes to refresh, depending upon the complexity, and afterwards the script prints the graph and moves on to the next one.
If I put in a 3 minute wait it runs fine, but takes almost three hours to run. Can anyone tell me how I make MacroScheduler wait until the mouse changes from an hourglass to a pointer, as this is the normal cue for the end of data refresh?
All clues gratefully received!
Dave Jesse
If I put in a 3 minute wait it runs fine, but takes almost three hours to run. Can anyone tell me how I make MacroScheduler wait until the mouse changes from an hourglass to a pointer, as this is the normal cue for the end of data refresh?
All clues gratefully received!
Dave Jesse
You can use the WaitCursorChanged command. But be warned that other applications can alter the cursor and you also need to be careful you don't call it too soon - you want to make sure you call this command after the cursor has become an hourglass - or you could try calling it twice assuming the cursor changes from default to hourglass when the activity starts and then back to default when it finishes.
You might have more luck watching a portion of the screen using WaitPixelColor or WaitRectChanged to wait for an area of the screen to change colour. Or GetControlText might be a better solution if there is an object with changing text - such as the text in the Status bar, or some other label, changing when the action has completed. You could put GetControlText in a loop and wait for this to change.
Another thought - you say the script prints each graph - is the option to print the graph disabled until the graph has finished being generated? If so you could have the script keep trying to print the graph - if the printer dialog doesn't appear after issuing the keystrokes to print the graph it loops back and tries again after a second or two. I have used this approach before where there was no other way to determine when an action had completed.
Just a few ideas that might help you wait for the activity to complete.
You might have more luck watching a portion of the screen using WaitPixelColor or WaitRectChanged to wait for an area of the screen to change colour. Or GetControlText might be a better solution if there is an object with changing text - such as the text in the Status bar, or some other label, changing when the action has completed. You could put GetControlText in a loop and wait for this to change.
Another thought - you say the script prints each graph - is the option to print the graph disabled until the graph has finished being generated? If so you could have the script keep trying to print the graph - if the printer dialog doesn't appear after issuing the keystrokes to print the graph it loops back and tries again after a second or two. I have used this approach before where there was no other way to determine when an action had completed.
Just a few ideas that might help you wait for the activity to complete.
MJT Net Support
[email protected]
[email protected]
I just wanted to confirm generally speaking with Macro Scheduler that
the verification or confirmation especially a web window or a window from an application say Excel has finished loading is not an etched-in-stone combination of commands but could be a combination - perhaps
infinite - of WaitReady, WaitCursorChanged, WaitWindowChanged
etc. where one may work better than another in given situation.
It really is a matter of working out what's best for the given
situation.
Also, with HTTPRequest there certain web pages I get a "null"
result in HTTPResult - for instance when I fully load up a couple
of my sports handicapping web pages. But then when I do an
HTTPRequest say on http://www.yahoo.com ... Viola! there's the HTML
for Yahoo in HTTPRequest.
Is there a rule of thumb when HTTPRequest will/won't work and
just wondering if what I'm describing has been encountered by
anyone else?
Thanks,
Joel.
the verification or confirmation especially a web window or a window from an application say Excel has finished loading is not an etched-in-stone combination of commands but could be a combination - perhaps
infinite - of WaitReady, WaitCursorChanged, WaitWindowChanged
etc. where one may work better than another in given situation.
It really is a matter of working out what's best for the given
situation.
Also, with HTTPRequest there certain web pages I get a "null"
result in HTTPResult - for instance when I fully load up a couple
of my sports handicapping web pages. But then when I do an
HTTPRequest say on http://www.yahoo.com ... Viola! there's the HTML
for Yahoo in HTTPRequest.
Is there a rule of thumb when HTTPRequest will/won't work and
just wondering if what I'm describing has been encountered by
anyone else?
Thanks,
Joel.
What I meant to write in my post is when I do a HTTPRequest on
http://www.yahoo.com ... HTTPResponse has the HTML for http://www.yahoo.com
other web pages HTTPResponse is null.
Joel.
http://www.yahoo.com ... HTTPResponse has the HTML for http://www.yahoo.com
other web pages HTTPResponse is null.
Joel.
In somewhat the same regard of my previous post in this
thread I find sometimes when I do a GetWindowText and
I know window_title is correct from GetActiveWindow I
likewise get a null result in the result variable (e.g.
WordPadText).
My work-around which seems to work for me is to do a
Select-All and copy to the clipboard ... noooo problem. I
assume if I'm able to to this the focus inherently has to b
correct as well. While my work around seems to work for
me what bothers me is the the GetWindowText is more
elegant and a direct command to get my intended/desired
window text result. The fact that it doesn't but my
considerbly less elegant solution does makes me wonder
how stable my solution is. I'd feel better if there was a
GetWindowText fix.
Anyone else experience a similar circumstance?
Thanks,
Joel.
thread I find sometimes when I do a GetWindowText and
I know window_title is correct from GetActiveWindow I
likewise get a null result in the result variable (e.g.
WordPadText).
My work-around which seems to work for me is to do a
Select-All and copy to the clipboard ... noooo problem. I
assume if I'm able to to this the focus inherently has to b
correct as well. While my work around seems to work for
me what bothers me is the the GetWindowText is more
elegant and a direct command to get my intended/desired
window text result. The fact that it doesn't but my
considerbly less elegant solution does makes me wonder
how stable my solution is. I'd feel better if there was a
GetWindowText fix.
Anyone else experience a similar circumstance?
Thanks,
Joel.
To determine why you don't get the html for some sites with HTTPRequest we would need to see the status code returned. Feel free to send a list of sites it fails to receive html for and we'll check them out.
GetWindowText can only return text from certain types of class objects. Generally speaking text for objects that you see beneath the specified parent window in Tools/View System Windows will be returned as a list. If, for your window, Tools/View System Windows returns no info then GetWindowText will also not be able to return any info. Only certain types of object classes will respond to the API functions that request their text. Your window could have custom objects that don't respond to the standard Windows messages that request window text.
GetWindowText can only return text from certain types of class objects. Generally speaking text for objects that you see beneath the specified parent window in Tools/View System Windows will be returned as a list. If, for your window, Tools/View System Windows returns no info then GetWindowText will also not be able to return any info. Only certain types of object classes will respond to the API functions that request their text. Your window could have custom objects that don't respond to the standard Windows messages that request window text.
MJT Net Support
[email protected]
[email protected]
Mjtnet.com Support.
Thank you very much for your reply and offer to investigate
the URL's/web pages I've found where (at least for me) HTTPRequest works/does not work (i.e. HTTPResponse contains the HTML code
from the web page from the HTTPRequest command)
HTTPRequest does not work for me in for the following URL:
http://www.vegasinsider.com/scoreboard.cfm?sport=mlb
However ... I have been able to get the vegasinsider.com
main page:
http://www.vegasinsider.com
to "work" using HTTPRequest.
For http://www.vegasinsider.com/scoreboard.cfm?sport=mlb
I have been able, as I explained earlier in the this thread,
byMacro Scheduler to set the focus on the window, Select All through a Firefox hotkey option (with a little bit of Waits what I call timing
tweaks), copy to the clipboard, change the focus to Excel, paste the clipboard and use <icrosoft Excel and its VB Macros as my pasrsing
and processing "engine".
Once I get through the processing and certain Cells are populated
with certain values (Using DDEPoke and DDERequest) I'll fire the
E-mail using SMTPSendMail which I've successfully realized doing
in the past.
For both of the web pages GetWindowText is null but I do realize
the GetActiveWindow string for both web pages. From your answer
I understand where I'd be getting a null using GetWindowText for
both URLS (windows)
So it looks like the clipboard is the solution and I have to incorporate
perhaps other Macro Scheduler commands to make sure my web page
is fully loaded. What I mean is if HTTPRequest works for all URLs or
in all instances if HTTPResponse is empty or null I can increase the
wait and try the web page again for a few times and then either
just continue on and/or generate an error ... however complex or
involved I want to make it. If the status of HTTPResponse is the
primary determining factor it makes the programming easier and
In My Humble Opinion (IMHO) reliable as there is just one main
factor or concern: the status of HTTPResponse to track.
I don't know if I'm using the correct vernacular or terminology.
I hope I've made myself clear. What is nice is I'm very confident
my project will be successful but at the outset I just want to know
to get as much efficient methodologies/Macro Scheduler commands/
command combinations down as possible.
Finally, I did a GetWindowText on the Windows Calculator and sure
enough what was in the display wound up in WordPadText so the
calculator from your reply must be a class of window or program
that works with GetWindowText.
Thanks in advance for your reply.
Joel S.
Thank you very much for your reply and offer to investigate
the URL's/web pages I've found where (at least for me) HTTPRequest works/does not work (i.e. HTTPResponse contains the HTML code
from the web page from the HTTPRequest command)
HTTPRequest does not work for me in for the following URL:
http://www.vegasinsider.com/scoreboard.cfm?sport=mlb
However ... I have been able to get the vegasinsider.com
main page:
http://www.vegasinsider.com
to "work" using HTTPRequest.
For http://www.vegasinsider.com/scoreboard.cfm?sport=mlb
I have been able, as I explained earlier in the this thread,
byMacro Scheduler to set the focus on the window, Select All through a Firefox hotkey option (with a little bit of Waits what I call timing
tweaks), copy to the clipboard, change the focus to Excel, paste the clipboard and use <icrosoft Excel and its VB Macros as my pasrsing
and processing "engine".
Once I get through the processing and certain Cells are populated
with certain values (Using DDEPoke and DDERequest) I'll fire the
E-mail using SMTPSendMail which I've successfully realized doing
in the past.
For both of the web pages GetWindowText is null but I do realize
the GetActiveWindow string for both web pages. From your answer
I understand where I'd be getting a null using GetWindowText for
both URLS (windows)
So it looks like the clipboard is the solution and I have to incorporate
perhaps other Macro Scheduler commands to make sure my web page
is fully loaded. What I mean is if HTTPRequest works for all URLs or
in all instances if HTTPResponse is empty or null I can increase the
wait and try the web page again for a few times and then either
just continue on and/or generate an error ... however complex or
involved I want to make it. If the status of HTTPResponse is the
primary determining factor it makes the programming easier and
In My Humble Opinion (IMHO) reliable as there is just one main
factor or concern: the status of HTTPResponse to track.
I don't know if I'm using the correct vernacular or terminology.
I hope I've made myself clear. What is nice is I'm very confident
my project will be successful but at the outset I just want to know
to get as much efficient methodologies/Macro Scheduler commands/
command combinations down as possible.
Finally, I did a GetWindowText on the Windows Calculator and sure
enough what was in the display wound up in WordPadText so the
calculator from your reply must be a class of window or program
that works with GetWindowText.
Thanks in advance for your reply.
Joel S.
While the question in this thread seems to have morphed into a totally different subject, I do have an idea to help your graph printing solution run quicker...(Maybe)...
If each print job has a unique ID in the print queue, then you could open the Printers and Faxes window and then open the specific printer your job is using. You might be able to read these jobs to see exactly (within a few seconds) when a job enters the print queue. IF (big IF here) the job's existence in the print queue is a sure sign that the app is finished and ready for the next input.
Remember that you have total control of the mouse, so you could move the mouse to a point on the screen then check for Pixel colors which would indicate the mouse is still in the hourglass shape....for instance, GetPixelcolor on coordinates where you are certain to expect either the standard background color or the white color of the top or bottom of the hourglass. Soooo many possibilities.....get creative.
SkunkWorks
If each print job has a unique ID in the print queue, then you could open the Printers and Faxes window and then open the specific printer your job is using. You might be able to read these jobs to see exactly (within a few seconds) when a job enters the print queue. IF (big IF here) the job's existence in the print queue is a sure sign that the app is finished and ready for the next input.
Remember that you have total control of the mouse, so you could move the mouse to a point on the screen then check for Pixel colors which would indicate the mouse is still in the hourglass shape....for instance, GetPixelcolor on coordinates where you are certain to expect either the standard background color or the white color of the top or bottom of the hourglass. Soooo many possibilities.....get creative.
SkunkWorks
Hello All/mjtnet.com support,
I wanted to share my findings or "discovery" of a nifty alternative
to bringing up a web page and using HTTPRequest to get the HTML
of it and/or my work-around bringing up a web page, select all,
copy to the clipboard and paste (paste special) into Excel.
There is a freeware text browser called lynx (and another similar
one confusingly called links) of which both have a command line
ASCII dump to a text file. This is not the HTML but just the text
in the web page.
The syntax is as follows:
In a DOS Window
c:\lynx283\del yahootext.txt
c:\lynx283\lynx - dump http://www.yahoo.com >> yahootext.txt
exit
The preceding can be made into a batch (.bat) file and while
it can be run from Windows the Dos window does not close
on the exit. In other words from the Start button it you run
the preceding batch file ... call it yahoo.bat the pre-existing
yahootext.txt file will be deleted, a new one created but the
DOS window on the exit just "hangs" and does not close.
However ... if you start from a DOS Window using Macro Scheduler:
Run Program>Command.com
and Using Macro Scheduler changing directory and run the
batch file ... Viola! the DOS window closes on the exit!
Sooo, the bottom line (no pun from my sports handicapping
sniffer application) I can export the text from any web page
and I don't have to be concerned with the variances of different
web pages, waits etc. using Macro Scheduler whether they are
fully loaded that I can proceedto do the select all and copy
to clipbaord. In this solution all I need to do is key on the
DOS window if it is open or closed. As soon as it closes I know
the ASCII text (not the HTML) of the web page has been exported to
a text file. This text file - a generic filename can be imported
to Excel.
If there is a problem and the DOS Window doesn't
close I see where I can program in a "hard" close to the DOS
Window. Slick 'eh? While at least for me this is a nice solution
and really makes my HTTPRequest moot, I'm still interested
in the story why some of my HTTPRequest "calls" work and
others don't.
So for those of you who like this solution to repeatedly going
to a given URL and for data updates again, the trick is first
establishing a DOS Window and then running the batch (.bat)
file ... not by running the batch file from the Start Button.
Hope I made some sense here and perhaps I in my own little
way contributed to the knowledge base of this fine Macro
Scheduler forum. Without the generous exchange of knowledge
and civility on this board I feel I never would achieved what I
already have with Macro Scheduler.
Joel.
There are several ways to go about it using Macro Editor
I wanted to share my findings or "discovery" of a nifty alternative
to bringing up a web page and using HTTPRequest to get the HTML
of it and/or my work-around bringing up a web page, select all,
copy to the clipboard and paste (paste special) into Excel.
There is a freeware text browser called lynx (and another similar
one confusingly called links) of which both have a command line
ASCII dump to a text file. This is not the HTML but just the text
in the web page.
The syntax is as follows:
In a DOS Window
c:\lynx283\del yahootext.txt
c:\lynx283\lynx - dump http://www.yahoo.com >> yahootext.txt
exit
The preceding can be made into a batch (.bat) file and while
it can be run from Windows the Dos window does not close
on the exit. In other words from the Start button it you run
the preceding batch file ... call it yahoo.bat the pre-existing
yahootext.txt file will be deleted, a new one created but the
DOS window on the exit just "hangs" and does not close.
However ... if you start from a DOS Window using Macro Scheduler:
Run Program>Command.com
and Using Macro Scheduler changing directory and run the
batch file ... Viola! the DOS window closes on the exit!
Sooo, the bottom line (no pun from my sports handicapping
sniffer application) I can export the text from any web page
and I don't have to be concerned with the variances of different
web pages, waits etc. using Macro Scheduler whether they are
fully loaded that I can proceedto do the select all and copy
to clipbaord. In this solution all I need to do is key on the
DOS window if it is open or closed. As soon as it closes I know
the ASCII text (not the HTML) of the web page has been exported to
a text file. This text file - a generic filename can be imported
to Excel.
If there is a problem and the DOS Window doesn't
close I see where I can program in a "hard" close to the DOS
Window. Slick 'eh? While at least for me this is a nice solution
and really makes my HTTPRequest moot, I'm still interested
in the story why some of my HTTPRequest "calls" work and
others don't.
So for those of you who like this solution to repeatedly going
to a given URL and for data updates again, the trick is first
establishing a DOS Window and then running the batch (.bat)
file ... not by running the batch file from the Start Button.
Hope I made some sense here and perhaps I in my own little
way contributed to the knowledge base of this fine Macro
Scheduler forum. Without the generous exchange of knowledge
and civility on this board I feel I never would achieved what I
already have with Macro Scheduler.
Joel.
There are several ways to go about it using Macro Editor
LYNX text browser alternative for HTTPRequest really works
All,
I just wanted to report in on my solution to the HTTPResult
really I described in this thread really seems to work now
that I've developed my application with it considerably further.
However, it is important to make programming considerations
if the export from LYNX is "null" or some other computer
computer malfunction occurs.
Joel.
I just wanted to report in on my solution to the HTTPResult
really I described in this thread really seems to work now
that I've developed my application with it considerably further.
However, it is important to make programming considerations
if the export from LYNX is "null" or some other computer
computer malfunction occurs.
Joel.
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
Glad to hear it's working. Another possible solution would be wget http://www.gnu.org/software/wget/wget.html It works well with macroscheduler and has options like timeouts and number of retries which help to bulletproof macros.
I perhaps spoke a little too soon with my LYNX solution.
It seems I'm encountering occasionally a "memory leak"
continually creating and closing a DOS window and/or
continually doing hardcore new data exports in the
same Excel spreadsheet.
If I' m not mistaken however when I was just doing
web page loads I had some symptoms there as well.
Will definitely investigate using this alternative as well.
Joel S.
It seems I'm encountering occasionally a "memory leak"
continually creating and closing a DOS window and/or
continually doing hardcore new data exports in the
same Excel spreadsheet.
If I' m not mistaken however when I was just doing
web page loads I had some symptoms there as well.
Will definitely investigate using this alternative as well.
Joel S.
Update on my LYNX solution.
Still using LYNX - had/having some problems with the Wget installation.
Still very interested in it as the alternative/better soltion than using
LYNX.
So I can either fiddle with Wget or continue developing my own
app that scans the sports handicapping boards for odds quotes
and look for perfect middling or can't lose "hedge" opportunities.
What I did was remove as many programs as possble in my Windows
startup. Have not had problems with creating and closing DOS windows
(which I think I'll have to create for the Wget solution anyway).
The interesting problem I'm encountering is when I create the
DOS window and use the text browser LYNX to export the text
from all the different web pages that post spread and money line
odds the majority of time the DOS window has a title of: LYNX
Ahhhh ... but if the given web page is a little sluggish the title
goes to: "Reading ..." and then back to "LYNX" so if I'm keying
on LYNX and it changes to "Reading ..." Macro Scheduler correctly
interprets the window is closed.
So rather than programming for either a LYNX or a Reading* window
title I just scan for the existence of all the text files which are the
exports of each odds web page I define in my batch file to export.
In Macro Scheduler I create a DOS window and implement a batch
file which changes subdirectories and then deletes all the previous
text files which are exports of the odds web pages I define in my
batch file. In other words the export of http://www.pinnaclesports.com
always exports to pinspoff.txt (pinnacle sports and offshore
abbreviated) using LYNX. pinspoff.txt is a standard filename I
recycle for pinnaclesports.
So, if all the various files exist I know that all the LYNX processing/
exports have been completed. I use a "null" file after my last
export in my batch file because the filename can be present but
still in the process of export.
Following is the batchfile:
cd\lynx283
del vioff.txt
del pinspoff.txt
del cariboff.txt
del sp3000of.txt
del betwwtof.txt
del greekoff.txt
del null.txt
lynx -dump http://www.vegasinsider.com/u/odds/offs ... _lines.cfm >> vioff.txt
lynx -dump http://www.pinnaclesports.com/vwGuestLi ... &descr=MLB >> pinspoff.txt
lynx -dump http://lines.caribsports.com:8080/lines/B.SBET.html >> cariboff.txt
lynx -dump http://www.sports3000.com/VwGameView.asp >> sp3000of.txt
lynx -dump http://lines.betwwts.com/scripts/lines.dll?s=0 >> betwwtof.txt
lynx -dump http://www.thegreek.com/sports/baseball ... e=7/1/2005 >> greekoff.txt
copy greekoff.txt null.txt
exit
Still using LYNX - had/having some problems with the Wget installation.
Still very interested in it as the alternative/better soltion than using
LYNX.
So I can either fiddle with Wget or continue developing my own
app that scans the sports handicapping boards for odds quotes
and look for perfect middling or can't lose "hedge" opportunities.
What I did was remove as many programs as possble in my Windows
startup. Have not had problems with creating and closing DOS windows
(which I think I'll have to create for the Wget solution anyway).
The interesting problem I'm encountering is when I create the
DOS window and use the text browser LYNX to export the text
from all the different web pages that post spread and money line
odds the majority of time the DOS window has a title of: LYNX
Ahhhh ... but if the given web page is a little sluggish the title
goes to: "Reading ..." and then back to "LYNX" so if I'm keying
on LYNX and it changes to "Reading ..." Macro Scheduler correctly
interprets the window is closed.
So rather than programming for either a LYNX or a Reading* window
title I just scan for the existence of all the text files which are the
exports of each odds web page I define in my batch file to export.
In Macro Scheduler I create a DOS window and implement a batch
file which changes subdirectories and then deletes all the previous
text files which are exports of the odds web pages I define in my
batch file. In other words the export of http://www.pinnaclesports.com
always exports to pinspoff.txt (pinnacle sports and offshore
abbreviated) using LYNX. pinspoff.txt is a standard filename I
recycle for pinnaclesports.
So, if all the various files exist I know that all the LYNX processing/
exports have been completed. I use a "null" file after my last
export in my batch file because the filename can be present but
still in the process of export.
Following is the batchfile:
cd\lynx283
del vioff.txt
del pinspoff.txt
del cariboff.txt
del sp3000of.txt
del betwwtof.txt
del greekoff.txt
del null.txt
lynx -dump http://www.vegasinsider.com/u/odds/offs ... _lines.cfm >> vioff.txt
lynx -dump http://www.pinnaclesports.com/vwGuestLi ... &descr=MLB >> pinspoff.txt
lynx -dump http://lines.caribsports.com:8080/lines/B.SBET.html >> cariboff.txt
lynx -dump http://www.sports3000.com/VwGameView.asp >> sp3000of.txt
lynx -dump http://lines.betwwts.com/scripts/lines.dll?s=0 >> betwwtof.txt
lynx -dump http://www.thegreek.com/sports/baseball ... e=7/1/2005 >> greekoff.txt
copy greekoff.txt null.txt
exit