Continue after defining a function

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
fona
Posts: 65
Joined: 07 Apr 2022, 06:43

Continue after defining a function

Post by fona » 07 Apr 2023, 08:51

Hello everyone,

My script doesn't want to continue after defining the function video5. Does it go against the principles of AHK or there is a chance to get it work the way I want.

A simple example below:

Code: Select all

F10:
video5()
{
SendInput {b}{s} 
}
SendInput {k} 
Click
SendInput {m} 
return

gregster
Posts: 9111
Joined: 30 Sep 2013, 06:48

Re: Continue after defining a function

Post by gregster » 07 Apr 2023, 08:58

Like I alluded to in your other topic, you are currently using a function hotkey, i.e. you are defining a function inside of a hotkey subroutine. It's a special case. In this case, code outside of the function won't be executed.
You can place the function outside of the hotkey subroutine, though - but then you'll have to call it explicitly:

Code: Select all

F10::
video5()
SendInput {k} 
Click
SendInput {m} 
return

video5() {
	SendInput {b}{s} 
}
Try to understand the difference between defining a function inside versus outside of a hotkey/hotstring subroutine.

Post Reply

Return to “Ask for Help (v1)”