Using remapped key repeatedly

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mgnor
Posts: 4
Joined: 09 Jun 2023, 10:26

Using remapped key repeatedly

Post by mgnor » 09 Jun 2023, 10:43

Hi,

First time poster, but i've used a lot of help on this community to figure things out, but im stumped this time. So forgive me if im not clear or doing this right.

I'm a regular autoCAD user, and i do use autolisp alot too.

I can't write this code in autolisp as i want to use the {home} key to call the command.

so

Code: Select all

#IfWinActive ahk_exe acad.exe
$Home::
sleep,  100
sendinput TR
sendinput {enter}
sendinput {enter}
Input, SingleKey, L1, {LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}
sleep, 50
Send, {esc}
sleep, 50
send, e
sendinput, {enter}
Input, SingleKey, L1, {LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}
sendinput, {enter}
return
all I want to do is hit the {home} key and use it as an "any key" where the "input" command is. Is there a way to temporarily disable the script from starting over from the start every time i hit the {home} key?? i thought that was what the $ was for? The command works perfectly when i hit any other unmapped key, but a lot of the unmapped keys are in different places.

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Using remapped key repeatedly

Post by mikeyww » 09 Jun 2023, 12:16

Welcome to this AutoHotkey forum!

You described what the script should not do, but you did not describe what the script should do, in each circumstance.

Is this the entire script?
What happens when you run the script?
What should happen instead?

mgnor
Posts: 4
Joined: 09 Jun 2023, 10:26

Re: Using remapped key repeatedly

Post by mgnor » 09 Jun 2023, 13:00

basically:

the script makes the {home} key a hotkey.

but as i go through the script i have two instances where i have "hit any key to continue" and i'd simply like to hit that same {home} key without the hotkey script restarting.

i've tried to use the hotkey off function but it creates an interrupting error.

mgnor
Posts: 4
Joined: 09 Jun 2023, 10:26

Re: Using remapped key repeatedly

Post by mgnor » 09 Jun 2023, 13:13

theres other parts to the larger script i have but they don't relate to this one and work stable to themselves.

the script works exactly as i want it to, except when i press {home} as one of the "any keys" that i want to use during the process of the script.

i would basically want to only have the hotkey action of pressing {home} happen on the first press of the {home} button, and not the subsequent two times i'll expect to hit it during the process of the running of the script.

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Using remapped key repeatedly

Post by mikeyww » 09 Jun 2023, 13:19

Have you changed the maximum number of threads per hotkey?

Are you referring to pressing the hotkey while the subroutine is executing, or after it completes?

mgnor
Posts: 4
Joined: 09 Jun 2023, 10:26

Re: Using remapped key repeatedly

Post by mgnor » 09 Jun 2023, 14:31

you'll have to explain what you mean by maximum number of threads per hotkey means.

i am trying to get it to change while the subroutine is running, and then changing it back once that subroutine finishes.

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Using remapped key repeatedly

Post by mikeyww » 09 Jun 2023, 20:41

I see. An example is below.

Code: Select all

#Requires AutoHotkey v1.1.33
ih := InputHook(), ih.VisibleNonText := False, ih.KeyOpt("{All}", "E")

#If !ih.InProgress
Home::
SoundBeep 1500
key := keyWaitAny(ih)
MsgBox % key
Return
#If

keyWaitAny(ih) {
 ih.Start(), ih.Wait()
 Return ih.EndKey
}

Post Reply

Return to “Ask for Help (v1)”