Independent loop inside of larger AHK file? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
kunkel321
Posts: 1085
Joined: 30 Nov 2015, 21:19

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
ste(phen|ve) kunkel
Albireo
Posts: 1756
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: 4823
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
User avatar
kunkel321
Posts: 1085
Joined: 30 Nov 2015, 21:19

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:
ste(phen|ve) kunkel

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: GEOVAN, jameswrightesq and 160 guests