WaitScreenImage more than once
Moderators: Dorian (MJT support), JRL
WaitScreenImage more than once
Hi All, relatively new to this, so please bare with me.
i'm trying to write a macro that will open outlook files from a DB and save them individually. i can do the bulk of it, but am stuck.
i'm using screencapture to wait for a certain symbol to come onto the screen, then i hit save as and go from there. I need to use the WaitScreenImage to search for this symbol, but the problem is that the symbol may be different depending on the type of MSG file that is open.
i want to have something like
WaitScreenImage>c:\image1.bmp
or
WaitScreenImage>c:\image2.bmp
save as function
does anyone know if this is possible?
i've added the code below.
many thanks
Arthur
----------------------
Let>k=1
Label>start
ReadLn>c:\\\MsgAttachmentIDs.txt,k,line
StringReplace>line, ,,tmpline
If>line=##EOF##,finish
run>C:\OpenMsgAttachment.exe %tmpline
wait>0.3
sent ALT + o
WaitScreenImage>C:\PP5\OpenMsgAttachment\button.bmp,20
PRESS ALT
send>fa
release ALT
i'm trying to write a macro that will open outlook files from a DB and save them individually. i can do the bulk of it, but am stuck.
i'm using screencapture to wait for a certain symbol to come onto the screen, then i hit save as and go from there. I need to use the WaitScreenImage to search for this symbol, but the problem is that the symbol may be different depending on the type of MSG file that is open.
i want to have something like
WaitScreenImage>c:\image1.bmp
or
WaitScreenImage>c:\image2.bmp
save as function
does anyone know if this is possible?
i've added the code below.
many thanks
Arthur
----------------------
Let>k=1
Label>start
ReadLn>c:\\\MsgAttachmentIDs.txt,k,line
StringReplace>line, ,,tmpline
If>line=##EOF##,finish
run>C:\OpenMsgAttachment.exe %tmpline
wait>0.3
sent ALT + o
WaitScreenImage>C:\PP5\OpenMsgAttachment\button.bmp,20
PRESS ALT
send>fa
release ALT
- Phil Pendlebury
- Automation Wizard
- Posts: 543
- Joined: Tue Jan 16, 2007 9:00 am
- Contact:
Here's how I do it with finding a position you could probably adapt this easily:
Code: Select all
Let>XPFound=0
Let>VISTAFound=0
FindImagePos>%Script_dir%/taskxp.bmp,SCREEN,50,1,X,Y,XPFound
FindImagePos>%Script_dir%/taskvista.bmp,SCREEN,50,1,X,Y,VISTAFound
If>{(%XPFound% > 0) OR (%VISTAFound% > 0)}
MouseMove>X_0,Y_0
// This is what happens if one of the images is found
Else
GOTO>Exit
// This is what happens if none of the images is found
Endif
Phil Pendlebury - Linktree
i've tried the above a few times, and it seems to keep failing in the if statement. i think it may be due to the image it's looking for not being in the screen at the time of the if statement. i was using the WaitScreenImage because the time it take for the screen to come up varies and is not always a fixed time. i think to fix this i can add in a Wait cmd, but i don't want to do that as it will eat up time.
any help is appreciated.
any help is appreciated.
Code: Select all
run>C:\Conversions\OpenMsgAttachment\OpenMsgAttachment.exe %tmpline%
wait>0.3
sent ALT + o
FindImagePos>C:\PP5\OpenMsgAttachment\button.bmp,SCREEN,0,1,X,Y,NumFound
FindImagePos>C:\PP5\OpenMsgAttachment\button2.bmp,SCREEN,0,1,X,Y,NumFound2
if>{(%numfound% > 0) OR (%numfound2% > 0)}
PRESS ALT
send>fa
release ALT
else
MessageModal>Fail!!
endif
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
thanks bob, unfortunately that didn't make a difference, i'm now trying to use the below method, althou, i still have to have a specific wait time, which i can't really have. The time it takes after i hit ALT+o varies between 5 and 10.
Code: Select all
Let>WSI_TIMEOUT=4
run>C:\Conversions\OpenMsgAttachment\OpenMsgAttachment.exe %tmpline%
WaitScreenImage>C:\PP5\OpenMsgAttachment\MsgProg.bmp,20
send> ALT + o
WaitScreenImage>C:\PP5\OpenMsgAttachment\button.bmp,20
//WaitScreenImage>C:\PP5\OpenMsgAttachment\button2.bmp,20
If>WSI_TIMEDOUT=FALSE
MessageModal>Normal
else
MessageModal>Undeliverable
endif
Let>k=k+1
Goto>start
label>finish
MessageModal>Finsihed.
Exit>0
Increase WSI_TIMEOUT, WaitWindowOpen, SetFocus
Try setting WSI_TIMEOUT to a value well over the usual range of 5-10.
Unfortunately it will wait the full 20 seconds if you look for the notfound image first. So look for both images simultaneously using a repeat loop:
Also make sure you are setting focus on the window you wish to accept the key stroke. If the image is in that window:
Or do it this way:
Try incorporating these suggestions into our script and let us know if that solves it.
Gale
Code: Select all
Let>WSI_TIMEOUT=20
//Will wait only 5 seconds if image is found in 5 seconds.
Code: Select all
Let>WSI_TIMEOUT=1
Let>counter=0
Repeat>counter
WaitScreenImage>C:\PP5\OpenMsgAttachment \button.bmp,20
if>WSI_TIMEDOUT=TRUE
WaitScreenImage>C:\PP5\OpenMsgAttachment\button2.bmp,20
endif
if>WSI_TIMEDOUT=FALSE
//found image, exit loop
Let>counter=10
else
Let>counter=counter+1
endif
Until>counter=10
Code: Select all
//Wait until image is found using WaitScreenImage
//Find image using FindImagePos
MouseMove>X_0,Y_0
LClick
//Send the keystrokes
Code: Select all
//Wait until image is found using WaitScreenImage
SetFocus>MyWindow
//Send the keystrokes
Try incorporating these suggestions into our script and let us know if that solves it.
Gale