Autohotkey - Run only parts of the script Topic is solved

Ask gaming related questions
MN333

Autohotkey - Run only parts of the script  Topic is solved

19 Apr 2018, 18:04

**Hello everyone! I recently started experimenting with autohotkey. In this particular script i need help with isolating and only running a part of the script.

This Autohotkey script interacts with a game. I have playable Characters A - D. I want to automatically activate a macro depending on the choosen character. (And also deactivate any other macros if the Character is beeing switched) To determine which character is beeing picked i use the IMAGESEARCH command.

Now my Question: is it possible to only run one macro of multiple ones inside the same script? As far as i'm concerned i get problems with "same hotkey already present" errors. It would be really nice if this was somehow possible, altough i couldn't find anything particular about this as it's kinda hard to describe and search for.

I'm very very thankful for all answers you can give me to this topic :)**

Code: Select all

#IfWinActive Program

If WinActive("ahk_exe Program.exe")
    CoordMode, Pixel


;SELECTION CHECKS;



K0:

    $~LButton:: 
        Sleep, 100
    ImageSearch, FoundX, FoundY, 53, 1233, 2491, 1287,*2 C:\Users\XYZ\Desktop\CharacterA.png

    if ErrorLevel = 2
        SoundBeep, 750, 500

    else if ErrorLevel = 1
        goto K1

    else

        goto CharacterA
return

K1:

    ImageSearch, FoundX, FoundY, 53, 1233, 2491, 1287,*2 C:\Users\XYZ\Desktop\CharacterB.png

    if ErrorLevel = 2
        SoundBeep, 750, 500

    else if ErrorLevel = 1
        goto K2

    else
        goto CharacterB
return

K2:

    ImageSearch, FoundX, FoundY, 53, 1233, 2491, 1287,*2 C:\Users\XYZ\Desktop\CharacterC.png

    if ErrorLevel = 2
        SoundBeep, 750, 500

    else if ErrorLevel = 1
        goto K3

    else
        goto CharacterC
return

K3:

    ImageSearch, FoundX, FoundY, 53, 1233, 2491, 1287,*2 C:\Users\XYZ\Desktop\CharacterD.png

    if ErrorLevel = 2
        SoundBeep, 750, 500

    else if ErrorLevel = 1
        goto K0

    else
        goto CharacterD
return


;Chars;



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CharacterA:
 SoundPlay, C:\Users\XYZ\Desktop\CA_Voiceline.wav

examplemacro

    Return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;




;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CharacterB:
 SoundPlay, C:\Users\XYZ\Desktop\CB_Voiceline.wav

examplemacro

    Return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;




;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CharacterC:
 SoundPlay, C:\Users\XYZ\Desktop\CC_Voiceline.wav

examplemacro

    Return  
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;




;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CharacterD:
 SoundPlay, C:\Users\XYZ\Desktop\CD_Voiceline.wav

examplemacro

    Return  
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Return to “Gaming”

Who is online

Users browsing this forum: Evil-e and 13 guests