Keybind/Macrobased Navigation Topic is solved

Ask gaming related questions (AHK v1.1 and older)
MeNameDark
Posts: 3
Joined: 19 Mar 2023, 20:43

Keybind/Macrobased Navigation

Post by MeNameDark » 19 Mar 2023, 21:15

Hi, I'm relatively new to AHK and I'm far more familiar with python, if that provides any help.

I'm trying to create a script that will wait for a key to be pressed(i), and when that key is pressed, I want to temporarily have the option to press numbers 1-8 to send a string such as the ones seen below (eg. Desert, Forest, Tundra),
and once that string is sent, I now want to be able to press 1-8 to send the actual integer as a string and press return.

All while maintaining the function of the 1-8 keys, so these would essentially only be active while using the pressed(i) in that particular instance.

An example visual aid from a video game voice line navigation menu, except mine would be purely through logic and no gui
Image

I was hoping to do this via shortcut assignment within a function, but that doesn't seem to be an option with AHK, would appreciate the help!

Code: Select all

i::
    ;This is garbage
    Sleep, 200
    SendInput, {= down}
    Sleep, 250	
    SendInput {= up}
    Sleep, 250
    MouseClick, right
    Sleep, 200
    Send /
    Sleep, 100
    ; Send Desert
    ; Send {Space down}
    Loop {
    While !variable 
        Sleep 50
        variable:=0 ; 
    if variable:= 1
        *$1::
            Send Desert
            variable:=1
        ~$2::Send Forest
        ~$3::Send Tundra
[Mod edit: Based on posted code, moved topic to v1 help...later moved to the gaming section.]

off
Posts: 176
Joined: 18 Nov 2022, 21:54

Re: Keybind/Macrobased Navigation  Topic is solved

Post by off » 20 Mar 2023, 00:43

Hello, perhaps something like this?

Code: Select all

Navigation=0

~i::
Navigation=1
Return

#If (Navigation=1) ; first menu selection
1::
Nav_1=1
Navigation=0
Return

2::
Nav_2=1
Navigation=0
Return

3::
Nav_3=1
Navigation=0
Return

#If (Nav_1=1) ; second menu selection
1::
MsgBox, You selected Menu 1 in Nav_1 from Navigation Menu.
Nav_1=0
Return

2::
MsgBox, You selected Menu 2 in Nav_1 from Navigation Menu.
Nav_1=0
Return

;etc.

#If (Nav_2=1)
1::
MsgBox, You selected Menu 1 in Nav_2 from Navigation Menu.
Nav_2=0
Return

;etc..
My Creations
IMG2HotString - Send image file easily with your hotstring!
CtrlSend - A small solution for sending keys to window in background that doesn't accept ControlSend's key
ControlProcess

MeNameDark
Posts: 3
Joined: 19 Mar 2023, 20:43

Re: Keybind/Macrobased Navigation

Post by MeNameDark » 20 Mar 2023, 09:58

@off

This is exactly what I was thinking of,

Additionally, do you know perhaps if there is a way to break out of the sequence? Say I hit {i},{1} and then change my mind and wish to break out of the nav menu.
Preferably I would be able to perform a certain action upon pressing the break key, somewhat like a daemon.

MeNameDark
Posts: 3
Joined: 19 Mar 2023, 20:43

Re: Keybind/Macrobased Navigation

Post by MeNameDark » 20 Mar 2023, 13:29

Edit: Managed to figure out the solution to that problem, and I additionally Figured out the whole script thanks to your support. Thank you very much.

off
Posts: 176
Joined: 18 Nov 2022, 21:54

Re: Keybind/Macrobased Navigation

Post by off » 20 Mar 2023, 20:12

@MeNameDark
Glad it worked, You're welcome :D
My Creations
IMG2HotString - Send image file easily with your hotstring!
CtrlSend - A small solution for sending keys to window in background that doesn't accept ControlSend's key
ControlProcess

Post Reply

Return to “Gaming Help (v1)”