I'd like to know if there is a way to have a script find text in the active window (it's a medical records program), and if it exists, then goto label, and if not, go to a different label..
I know some of the basics, but can't figure out the find text part..
When i run the example script for Text Capture it can see the text when i point to it..
In the past I've used the image tools (FindImagePos) to do something similar, but there doesn't seem to be a text recognition that works like the image tools.
Thanks for any help!
Find text on screen, then, else...
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
You can do something like:
GetWindowTextEx>window_title,text
Pos>text_to_find,text,1,p
If>p>0
//text was found in window
Else
//text not found in window
Endif
GetWindowTextEx>window_title,text
Pos>text_to_find,text,1,p
If>p>0
//text was found in window
Else
//text not found in window
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Thanks!
So I have this... but it just goes through to exit like it's not seeing the word..
I don't have a title for the window because it changes all the time, I hope that doesn't make it not look at the screen.
If the word Tanni is on screen I want it to run the script...
Label>Start
GetWindowTextEx>,text
Pos>Tanni,text,1,p
If>p>0
//text was found in window
Goto>Change
Else
//text not found in window
Goto>Exit
Endif
Label>Change
// Select and change old for new
Press F7
Wait>1
Press LShift
Press Down * 16
Wait>1
Release LShift
Wait>1
Press LCTRL
Wait>0.5
Send>v
Wait>0.2
Release LCTRL
Wait>2
Press Esc
Wait>1
Press Down
Wait>1
Press Enter
Goto>Start
Label>Exit
// Get out and go to the next one
Wait>1
Press Esc
Wait>1
Press Down
Wait>1
Press Enter
Goto>Start
So I have this... but it just goes through to exit like it's not seeing the word..
I don't have a title for the window because it changes all the time, I hope that doesn't make it not look at the screen.
If the word Tanni is on screen I want it to run the script...
Label>Start
GetWindowTextEx>,text
Pos>Tanni,text,1,p
If>p>0
//text was found in window
Goto>Change
Else
//text not found in window
Goto>Exit
Endif
Label>Change
// Select and change old for new
Press F7
Wait>1
Press LShift
Press Down * 16
Wait>1
Release LShift
Wait>1
Press LCTRL
Wait>0.5
Send>v
Wait>0.2
Release LCTRL
Wait>2
Press Esc
Wait>1
Press Down
Wait>1
Press Enter
Goto>Start
Label>Exit
// Get out and go to the next one
Wait>1
Press Esc
Wait>1
Press Down
Wait>1
Press Enter
Goto>Start
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
GetWindowText requires a window title.
Instead of GetWindowText you can use GetTextInRect and specify a rectangular portion of the screen which could be the entire screen - or the active window - in which case you don't care what the title is you just use whatever is on the screen.
So the following gets the text from the active window:
Instead of GetWindowText you can use GetTextInRect and specify a rectangular portion of the screen which could be the entire screen - or the active window - in which case you don't care what the title is you just use whatever is on the screen.
So the following gets the text from the active window:
Code: Select all
GetActiveWindow>wTitle,x,y,w,h
GetTextInRect>x,y,{%x%+%w%},{%y%+%h%},text
Pos>Tanni,text,1,p
If>p>0
//Tanni found
Else
//Not found
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: Find text on screen, then, else...
Does it have to be exact Lower and Uppercase?
If yes then how to make the script to find text doesn't matter lower or uppercase...
If yes then how to make the script to find text doesn't matter lower or uppercase...
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: Find text on screen, then, else...
Usually you use the UpperCase>or LowerCase> commands to make them either uppercase or lowercase...