I am trying to write a script that searches a specific window continuously waiting for a certain phrase to be writtten in the window and if it then finds it to finally continue to another macro I have already written.
Any suggestions? Sorry for my Newbyizm
Any help would be greatly appreciated.
Find Window with Text Problem
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7380
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Hi,
If using FindWindowWithText then it sounds like you'll need the Edits flag set.
However, since you already know the window, it sounds like the best approach is going to be a loop within which you set focus to the window, and grab the text using the clipboard and check to see if your phrase is in it, something like:
Label>textcheck
Wait>5
SetFocus>your window
//Assume the text editor is focused already
//copy all text to clipboard
Press Ctrl
Send>ac
Release Ctrl
Wait>2
GetClipBoard>thetext
Position>yourphrase,thetext,1,p
If>p=0,textcheck
Macro>yourmacro.scp
So here, if yourphrase is not in thetext the script branches back and loops again. The check is performed every 5 seconds. If yourphrase IS in thetext, the loop ends and the script calls your macro.
You will obviously need to do some tweaking but I hope this gives you the right idea.
If using FindWindowWithText then it sounds like you'll need the Edits flag set.
However, since you already know the window, it sounds like the best approach is going to be a loop within which you set focus to the window, and grab the text using the clipboard and check to see if your phrase is in it, something like:
Label>textcheck
Wait>5
SetFocus>your window
//Assume the text editor is focused already
//copy all text to clipboard
Press Ctrl
Send>ac
Release Ctrl
Wait>2
GetClipBoard>thetext
Position>yourphrase,thetext,1,p
If>p=0,textcheck
Macro>yourmacro.scp
So here, if yourphrase is not in thetext the script branches back and loops again. The check is performed every 5 seconds. If yourphrase IS in thetext, the loop ends and the script calls your macro.
You will obviously need to do some tweaking but I hope this gives you the right idea.
find window with text problem
Well, your idea works really good...theres just one problem...
Because I want to be able to type in the window and have the macro running at the same time...
I keep getting errors...like I'm sometimes using the A and C keys to type...and since the macro uses those keys...it's not working right...
Here's what I have "tweaked" so far
Label>textcheck
Wait>5
SetFocus>My Window
//Assume the text editor is focused already
//copy all text to clipboard
press shift
press tab
press tab
release shift
Press Ctrl
Send>ac
Release Ctrl
press tab
press tab
GetClipBoard>test
Position>yourphrase,test,1,p
If>p=0,textcheck
macro>mymacro.scp
That's why I was trying to use the findwindowwithtext command...
but I'm not smart enough to figure it out.
Any more suggestions?
Thanks very much for all your help!
Derail
Because I want to be able to type in the window and have the macro running at the same time...
I keep getting errors...like I'm sometimes using the A and C keys to type...and since the macro uses those keys...it's not working right...
Here's what I have "tweaked" so far
Label>textcheck
Wait>5
SetFocus>My Window
//Assume the text editor is focused already
//copy all text to clipboard
press shift
press tab
press tab
release shift
Press Ctrl
Send>ac
Release Ctrl
press tab
press tab
GetClipBoard>test
Position>yourphrase,test,1,p
If>p=0,textcheck
macro>mymacro.scp
That's why I was trying to use the findwindowwithtext command...
but I'm not smart enough to figure it out.
Any more suggestions?
Thanks very much for all your help!
Derail
find window with text problem
Oh I almost forgot
I keep getting Macro Scheduler errors
"cannot open clipboard"
Or something like that.
Thanks again!
Derail
I keep getting Macro Scheduler errors
"cannot open clipboard"
Or something like that.
Thanks again!
Derail