Loop stops functioning

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Shawn Dion
Posts: 1
Joined: 22 Jul 2017, 10:54

Loop stops functioning

22 Jul 2017, 11:03

Hello fellow coders
I really hate asking for help but I'll be honest I'm stumped with this problem that should be straight forward

Code: Select all

SetTitleMatchMode, 2
^j::
SetTitleMatchMode, 2
Sleep 1000
ControlSend,, {F12}, OBS 
run "C:\Program Files (x86)\Winamp\Winamp.exe" "e:\Music\Song1.mp3"
Sleep 2000
SetTitleMatchMode, 2
Loop {
  IfWinExist,Winamp [Stopped]
  { ControlSend,, {F11}, OBS 
    continue
  }
  Sleep, 1000
}
SetTitleMatchMode, 2
Sleep 1000
ControlSend,, {F12}, OBS 
run "C:\Program Files (x86)\Winamp\Winamp.exe" "e:\Music\Song2.mp3"
Sleep 2000
SetTitleMatchMode, 2
Loop {
  IfWinExist,Winamp [Stopped]
  { ControlSend,, {F11}, OBS 
    continue
  }
  Sleep, 1000
}
Return
What my code is supposed to do is after pressing Ctrl-J is send F12 (Record mode for Open Broadcast Video Recorder) then load Winamp with the first song wait until the winamp screen title says Winamp [Stopped] send the F11 key to stop the recording on OBS then load the next song in the list and repeating the same code over and over for several files unfortunately the code stops after pressing the F11 key at this point I'm totally clueless in why the code won't restart.

Any help would be greatly appreciated.

Shawn Dion

P.S: I'm running this on 64 bit Windows 10.
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Loop stops functioning

22 Jul 2017, 12:33

Hi.
I think your script isn't able to leave your loop. It detects the WinAmp-window, sends keystroke to OBS and continues detecting same WinAmp-window again and again.
In your case, you have to even close the WinAmp-window after detecting it. Instead of continue, you have to break your loop.

Using Loop, Files, ... would be a better choice for your script idea.

If the WinAmp-window is not an additionally window, as I think, than the first part of my answer is incorrect.
Einfach nur ein toller Typ. :mrgreen:
Guest

Re: Loop stops functioning

22 Jul 2017, 13:40

Thanks for the information.

I had not noticed a quick way to loop files I'll definitely go with that method instead as with my other method I would of had over 1.4k lines of repeat code.

Found what I needed with the example related to the command.

Shawn

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 282 guests