News:

Welcome to our NEW forum! We invite you to sign up today
so it can grow to be a valuable resource to all Toolbox users!

Main Menu

[Tip] Search for text in the current folder, image, or window

Started by Paul (Lead Developer), May 27, 2026, 10:00:31 PM

Previous topic - Next topic

Paul (Lead Developer)

Sometimes you are looking at an image (or folder/window) that has a lot of text, and you need to know if certain text is visible in it. For documents, you'd normally use the search function with the document's app, but for viewed images or a folder/window this isn't possible. This action, when bound to a hotkey, will search the current visible portion of a folder, image or window for the text you specify. Just press the hotkey when the item is active, and enter the text to find. You will then be told if the text is present or not (the action can't highlight or select the text for you).

Note: This action uses Windows OCR, so any failure to find the text is due to Windows (the OS) and not AlomWare Toolbox. ;D

(Start)
HOW TO USE: Copy from Start to End, and then paste into an action.
REFERENCE : See an example of pasting at alomware.com/paste.png
0001 Alert: Ask for a line of text "Search for this text:"
0002 Window: Assign active ""
0003 Window: Set windoc$ variable ""
0004 Action: Do this block if "windoc$<>blank$"
0005  Image: Assign "windoc$"
0006  Data: Assign "image"
0007 Action: End of block ""
0008 Action: Do this block if "windoc$=blank$"
0009  Image: Assign "window"
0010  Data: Assign "window"
0011 Action: End of block ""
0012 Action: Match case "0"
0013 String: Assign from assigned image ""
0014 Action: Do next step if "string$?alert$"
0015  String: Assign "The data$ DOES contain "alert$"."
0016 Action: Do next step if "string$!alert$"
0017  String: Assign "The data$ does NOT contain "alert$"."
0018 Alert: Show a message "string$"
(End)

[Edited to clarify visible portion. For example, a long folder of files won't be searched; just the on-screen visible portion of it].

oblivion

Not sure why it's taken me so long to try this extremely cool action.

I should say that it works perfectly but it wouldn't work for me until I'd added

0001 Wait: For action hotkey to be released ""
at the first line.

Paul (Lead Developer)

Thanks for sharing how to make it work for you, Oblivion. It's not needed here for my PCs, but I'm glad you sorted it for yourself. :)

I did toy with the idea of making an action not run until its hotkey is released, but that would break some actions from running immediately and/or correctly, such as this magnifying glass one: https://www.alomware.com/forum/index.php?topic=191.0

oblivion

Makes complete sense.

My best guess is that the need for it is variable depending on the speed of the machine -- or maybe just whatever's going on at the time. I get the same thing sometimes with the Keyboard: copy and Keyboard: paste commands, which I often (not always!) have to use a variant of

(Start)
0001 Macro: Type keys or use mouse "{z20}{ctrldown}c{ctrlup}{z20}"
(End)

to replace. Sadly, it makes the code harder to read :(

(for the puzzled, that's a 20 millisecond wait, holding the ctrl key down, pressing 'c' for "copy", releasing the ctrl key again and waiting another 20 milliseconds, the paste equivalent would replace the 'c' with a 'v' and cut would use an 'x'.)

On one hand, it's definitely a bit more reliable on my admittedly slightly overpowered laptop and allows the tweaking of the delay (z50 or z100 for a 20th or a 10th of a second respectively) if it's still unreliable but it's harder to read and harder to maintain, sadly.

I've a few times thought about asking for a config tweak that would allow the delay before copy / cut / paste commands to be managed across the whole of Toolbox Automation but that'd be a bit of a blunt instrument, I think, so I've resisted. :)