Return

Auto Hotkey

Return

Returns from a subroutine to which execution had previously jumped via function-call, Gosub, Hotkey activation, GroupActivate, or other means.

Return Expression

Parameters

Expression

This parameter should be omitted except when return is used inside a function.

Since this parameter is an expression, all of the following are valid examples:

return 3
return "literal string"
return MyVar 
return i + 1
return true  ; Returns the number 1 to mean "true".
return ItemCount < MaxItems  ; Returns a true or false value.
return FindColor(TargetColor)

Remarks

The space or comma after Return is optional if the expression is enclosed in parentheses, as in return(expression). However, Return is not a function and cannot be used mid-expression.

If there is no caller to which to return, Return will do an Exit instead.

There are various ways to return multiple values from function to caller described within Returning Values to Caller.

Related

Functions, Gosub, Exit, ExitApp, GroupActivate

Example

#z::
MsgBox The Win-Z hotkey was pressed.
Gosub MySubroutine
return
   
MySubroutine:
Sleep 1000
return