This line will never execute

Get help with using AutoHotkey and its commands and hotkeys
0xDEADC0DE
Posts: 9
Joined: 14 Jan 2016, 10:31

This line will never execute

Post by 0xDEADC0DE » 18 Jan 2021, 18:54

I created a small sample to show you my problem.
Perhaps you can point me to the right direction what's wrong.

Code: Select all

#Warn All

#+a::
    Run, mmsys.cpl
    WinWait, Sound
return

SetWinDelay,2
I get the error
image.png
image.png (6.82 KiB) Viewed 84 times
But why? The return is for the hotkey?

User avatar
mikeyww
Posts: 5386
Joined: 09 Sep 2014, 18:38

Re: This line will never execute

Post by mikeyww » 18 Jan 2021, 19:14

AHK will not execute isolated code that follows hotkey or hotstring routines, but you can put such code at the top of the script. This is explained on the following page.

https://www.autohotkey.com/docs/Scripts.htm#auto

User avatar
YoucefHam
Posts: 346
Joined: 24 Aug 2015, 12:56
Facebook: https://fb.me/YoucefHamDz
Google: [email protected]
GitHub: YoucefHam
Location: Algeria
Contact:

Re: This line will never execute

Post by YoucefHam » 18 Jan 2021, 19:14

Try this

Code: Select all

#Warn All

#+a::
    Run, mmsys.cpl
	SetWinDelay, 5000 ;1000 = 1 seconds
    WinWait, Sound
	MsgBox, Hi
return
:wave: There is always more than one way to solve a problem. ;)

garry
Posts: 2630
Joined: 22 Dec 2013, 12:50

Re: This line will never execute

Post by garry » 19 Jan 2021, 03:59

you can remove #Warn , so not get error message
but as example above : it opens sound , but setwindelay never can work when you have return after this command > Run, mmsys.cpl

Code: Select all

;#Warn All
!h::
    Run, mmsys.cpl
    return        ;- this return is wrong here
	SetWinDelay, 5000 ;1000 = 1 seconds
    WinWait, Sound
	MsgBox, Hi
return

Post Reply

Return to “Ask For Help”