Necessary using "Return" in command starting "#IfWinActive" and ending "#IfWinActive"?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
cadudesun
Posts: 129
Joined: 04 Jun 2016, 10:26

Necessary using "Return" in command starting "#IfWinActive" and ending "#IfWinActive"?

16 Feb 2019, 09:59

Hi,

I'd appreciate your help.
In the script below, is it necessary using "Return" if there is command starting with "#IfWinActive" and ending "#IfWinActive"?
Actually, my full script has hundreds of lines with this kind of syntax for many different programs shortcuts customization.
Or it would be redundant (no need) since the "#if" commands already work as "Return", doesn't allowing the script going ahead?

Thank you!

Code: Select all

;Add-ons
#IfWinActive, ahk_exe thunderbird.exe
^+l::
send, !{t}
Sleep 50
Send, {down 3}{right}
Return
#IfWinActive
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Necessary using "Return" in command starting "#IfWinActive" and ending "#IfWinActive"?

16 Feb 2019, 10:04

The returns are for your hotkeys and not the #IF section

You can drop the second #IFWinactive

Code: Select all

#IfWinActive, ahk_exe thunderbird.exe    ; Start #IF section 

^+l::
send, !{t}
Sleep 50
Send, {down 3}{right}
Return

^+k::
send, !{t}
Sleep 50
Send, {down}{enter}
Return

#If  ; Exit #If section

cadudesun
Posts: 129
Joined: 04 Jun 2016, 10:26

Re: Necessary using "Return" in command starting "#IfWinActive" and ending "#IfWinActive"?

18 Feb 2019, 13:23

Hellbent wrote:
16 Feb 2019, 10:04
The returns are for your hotkeys and not the #IF section

You can drop the second #IFWinactive
Many thanks for the teachings @Hellbent!!!
cadudesun
Posts: 129
Joined: 04 Jun 2016, 10:26

Re: Necessary using "Return" in command starting "#IfWinActive" and ending "#IfWinActive"?

18 Feb 2019, 13:30

By the way, even for single line commands, do I need to use "return"?
In the example below (a) is without return, and (b) with return because of multiple lines with send commands.

Code: Select all

#IfWinActive, ahk_exe WINWORD.EXE

;a)HIGHLIGHT
!1::send, ^!h 

;b)Select Paragraph
!2::
send, ^{up}
send, ^+{down}
Return
Thanks!
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Necessary using "Return" in command starting "#IfWinActive" and ending "#IfWinActive"?

18 Feb 2019, 13:31

No return is needed for your single line hotkey. Likewise for hotstrings.
cadudesun
Posts: 129
Joined: 04 Jun 2016, 10:26

Re: Necessary using "Return" in command starting "#IfWinActive" and ending "#IfWinActive"?

19 Feb 2019, 06:22

Hellbent wrote:
18 Feb 2019, 13:31
No return is needed for your single line hotkey. Likewise for hotstrings.
Thank you very much!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Nerafius and 98 guests