I really would like the possibility to use the same label in a script, placed in different #if blocks.
For hotkey labels this already works.
Here a simple example just to demonstrate how the test script basically works:
Code: Select all
;Main Script_Labels
#SingleInstance, Force
#include Joystick_Functions.ahk
Select:
Send 1
return
Select+Cross:
Send 2
return
Code: Select all
;Joystick_Functions
Joy11::
while GetKeyState("Joy11") ; While Joy11 is being pressed:
{
if GetKeyState("Joy2") ; If Joy2 is also pressed:
{
blocked := true ; Disable Joy11 functionality
GoSub, Select+Cross ; Run label for both buttons
KeyWait, Joy2 ; Wait until Joy2 has been released
}
}
KeyWait, Joy11 ; Wait until Joy11 has been released
if !(blocked) ; If Joy2 was not pressed
{
GoSub, Select ; Run label for the 1 button
}
Sleep, 20
blocked := false ; Reset value
return
Code: Select all
;Main Script_Labels
#SingleInstance, Force
#include Joystick_Functions.ahk
#if WinActive("ahk_class Notepad++")
Select:
Send 1
return
Select+Cross:
Send 2
return
#if
#if WinActive("ahk_class Notepad")
Select:
Send 3
return
Select+Cross:
Send 4
return
#if
Code: Select all
;Joystick_Functions
Joy11::
while GetKeyState("Joy11") ; While Joy11 is being pressed:
{
if GetKeyState("Joy2") ; If Joy2 is also pressed:
{
blocked := true ; Disable Joy11 functionality
Run_Label("Select+Cross") ; Execute function to run label depending on button and application
KeyWait, Joy2 ; Wait until Joy2 has been released
}
}
KeyWait, Joy11 ; Wait until Joy11 has been released
if !(blocked) ; If Joy2 was not pressed
{
Run_Label("Select") ; Execute function to run label depending on button and application
}
Sleep, 20
blocked := false ; Reset value
return
Run_Label(button)
{
if WinActive("ahk_class Notepad++")
{
GoSub, %button%_notepad++
}
if WinActive("ahk_class Notepad")
{
GoSub, %button%_notepad
}
}
Code: Select all
;Main Script_Labels
#SingleInstance, Force
#include Joystick_Functions.ahk
Select_notepad++:
Send 1
return
Select+Cross_notepad++:
Send 2
return
Select_notepad:
Send 3
return
Select+Cross_notepad:
Send 4
return
Thanks for reading!
Cheers!