Stopping loop if variable in current window Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
doctorafterman
Posts: 26
Joined: 26 Aug 2019, 08:45

Stopping loop if variable in current window

26 Aug 2019, 10:28

I'm writing a loop right now that needs to stop if there's certain text in the current chrome window.
My current method of doing this is:

Code: Select all

Send ^a^c
If InStr( Clipboard, "stopping variable" )
Break
This selects all text on the screen, puts it in the clipboard and checks the clipboard. Any other ways to do this that are less prone to error?
User avatar
Sir Teddy the First
Posts: 94
Joined: 05 Aug 2019, 12:31
Contact:

Re: Stopping loop if variable in current window  Topic is solved

26 Aug 2019, 13:26

You could try WinText, possibly with DetectHiddenText on, but as I am not using Chrome myself, I'm not entirely sure that this will work.

Despite that, you could increase your chance of success by adding a sleep command inbetween the send-command, maybe even a second loop that checks your clipboard, like this:

Code: Select all

Clipboard := ""

Loop,
{
	Send ^a
	Sleep 50
	Send ^c
	Sleep 100
}Until Clipboard

If InStr( Clipboard, "stopping variable" )
Break
This way you could be sure that the script actually copied something from the website.
:eh: :think:
doctorafterman
Posts: 26
Joined: 26 Aug 2019, 08:45

Re: Stopping loop if variable in current window

27 Aug 2019, 07:38

Sir Teddy the First wrote:
26 Aug 2019, 13:26
You could try WinText, possibly with DetectHiddenText on, but as I am not using Chrome myself, I'm not entirely sure that this will work.

Despite that, you could increase your chance of success by adding a sleep command inbetween the send-command, maybe even a second loop that checks your clipboard, like this:

Code: Select all

Clipboard := ""

Loop,
{
	Send ^a
	Sleep 50
	Send ^c
	Sleep 100
}Until Clipboard

If InStr( Clipboard, "stopping variable" )
Break
This way you could be sure that the script actually copied something from the website.
This is a great addition - honestly the select all method has been working so far and it's quick enough that I suppose I don't need to fix what ain't broke.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], HiSoKa, TAC109 and 33 guests