Let me start out by saying I new here and just started using this program a few days ago, Running the 30 day trial. If I can get the script below to work, I'll have no choice but to purchase the program. Estimated yearly savings would be 100 - 200 hours.
Although the script below uses the Display Properties panel as an active window, my actual program uses a third party software program in which I wish to capture screens and paste them into a word document.
One Word document could contain as much as 500 screen captures. My problem is, it misses a beat every so often. I'm testing on both windows XP and 2000.. When running on windows 2000 the first screen capture never gets pasted into the document. After that both XP and 2000 miss pasting the image or the number I add the bottom of the image... approx 2% failure
I've tried a couple of approaches, Print screen and Screen capture then "shift" "ins" the clipboard image to the word document.
See below.. any input would be welcome
//Specify the path of the Word file here
Let>filename=%SCRIPT_DIR%\doc111.doc
IfFileExists>filename
//Start Word
ExecuteFile>filename
'WaitWindowOpen>Microsoft Word -*
//Ask how many rows we should get
Input>maxrows,How many screen shall I capture?,500
//Open Display Properties
Run>rundll32 shell32.dll,Control_RunDLL Desk.cpl
WaitWIndowOpen>Display Properties
Let>r=1
Repeat>r
SetFocus Display Properties
Press Tab
//Press ALT
Press Print Screen
WaitClipBoard
Release ALT
SetFocus>Word*
WaitReady>0
Wait>.05
Press Enter
Press Shift
Press Ins
Wait>.10
Press Enter
Release Shift
Wait>.05
Send>%r%
Let>r=r+1
Until>r=maxrows
Else
MessageModal>Could not find: %filename%
Endif
Help with printscreen and clipboard
Moderators: Dorian (MJT support), JRL
Intermittent errors are usually due to timing problems. You seem to be aware of many ways for bulletproofing your script from a timing perspective. I see you've used WaitClipBoard, and WaitReady for example. Though they are generally thought of as a last resort, plain old Waits might still be appropriate. What I usually do is add large waits (large might be 2 seconds) in many places to make the script 100% reliable, then work on reducing or removing them while maintaining reliability. I usually feel reliability is more important than speed.
I also see you are using two techniques in your repeat statement that I have personally abandoned even though they show up in the help files. One is I try to never use a single character as a variable. Rather than "r" as a variable I would use "rr". (Actually I prefer "kk"). The other change I would make is the location of the add statement in the repeat loop. I would set variable "rr" to 0 (zero) outside of the repeat loop then add 1 (one) to "rr" in the first line of the repeat loop. The reason is that as you have it now, if variable "maxrows" is set to 500, you will actually only loop 499 times. The 499th time through when "rr" becomes 500 and the next line tests to see that "rr" does equal 500 and the loop is done. You can easily prove this to yourself by stepping through a low count loop in the editor. For example:
Let>rr=1
Repeat>rr
MessageModal>%rr%
Let>rr=rr+1
Until>rr=5
Versus
Let>rr=0
Repeat>rr
Let>rr=rr+1
MessageModal>%rr%
Until>rr=5
The first sample will loop 4 times, the second will loop 5 times.
Hope this is helpful
I also see you are using two techniques in your repeat statement that I have personally abandoned even though they show up in the help files. One is I try to never use a single character as a variable. Rather than "r" as a variable I would use "rr". (Actually I prefer "kk"). The other change I would make is the location of the add statement in the repeat loop. I would set variable "rr" to 0 (zero) outside of the repeat loop then add 1 (one) to "rr" in the first line of the repeat loop. The reason is that as you have it now, if variable "maxrows" is set to 500, you will actually only loop 499 times. The 499th time through when "rr" becomes 500 and the next line tests to see that "rr" does equal 500 and the loop is done. You can easily prove this to yourself by stepping through a low count loop in the editor. For example:
Let>rr=1
Repeat>rr
MessageModal>%rr%
Let>rr=rr+1
Until>rr=5
Versus
Let>rr=0
Repeat>rr
Let>rr=rr+1
MessageModal>%rr%
Until>rr=5
The first sample will loop 4 times, the second will loop 5 times.
Hope this is helpful