Independent loop inside of larger AHK file? Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
kunkel321
Posts: 176
Joined: 30 Nov 2015, 21:19
Facebook: https://www.facebook.com/kunkel321
Google: kunkel321

Independent loop inside of larger AHK file?

14 May 2019, 14:09

Hi All,
This is actually a continuation of this thread about waiting for a window to open. (thanks Osprey and Vsub!)

The loop works fine in an AHK script file by itself. I'm hoping to have it in with my main master AutoCorrect script that's always running in the background though. I made the below script just to test whether the loop would work "next to" other things. It does not. The first hotkey works, but the loop and the second hotkey do not.

I tried wrapping the loop in #WinWaitActive but that did not work either.

Ideas?

Code: Select all

#NoEnv
#SingleInstance force
;#################################

::testa::test A
Loop
{
    WinWaitActive,Web Student Management
    WinMaximize
    WinWaitNotActive
	Sleep, 1000
}
::textb::test B
Albireo
Posts: 793
Joined: 16 Oct 2013, 13:53

Re: Independent loop inside of larger AHK file?

15 May 2019, 06:13

I think many of us have the same problem with waiting for web pages.
When I do not find another solution, I read the color in one or a few places. If the desired color is available, the right window is active.
User avatar
evilC
Posts: 4721
Joined: 27 Feb 2014, 12:30

Re: Independent loop inside of larger AHK file?

15 May 2019, 08:08

The line ::testa::test A is before the loop. Hotkey / hotstring declarations in :: syntax stop execution, so the loop is unreachable code.
Put the hotstring at the end, with the other hotstring
kunkel321
Posts: 176
Joined: 30 Nov 2015, 21:19
Facebook: https://www.facebook.com/kunkel321
Google: kunkel321

Re: Independent loop inside of larger AHK file?  Topic is solved

15 May 2019, 09:53

Thanks for the replies. I guess I see what you mean about the loop being unreachable... That was a no-brainer. I'm thinking that having loops like this in the same file as bunch of hotstring and hotkey macros is not a feasible solution.

As for the second hotkey not working--I had a typo in the hotstring. :facepalm:

EDIT: Actually... It occurs to me that there is a better solution to my need. The window I'm waiting for in the loop is a website. I have the site bookmarked and already access it from a link on my launcher. So I'll replace the link with a link that launches a dedicated script. The script will launch the site, run the loop, then exit. :bravo:

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Gajoo, Google [Bot], Noxse, samzz, vsub and 207 guests