Page 1 of 1

Using remapped key repeatedly

Posted: 09 Jun 2023, 10:43
by mgnor
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.

Re: Using remapped key repeatedly

Posted: 09 Jun 2023, 12:16
by mikeyww
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?

Re: Using remapped key repeatedly

Posted: 09 Jun 2023, 13:00
by mgnor
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.

Re: Using remapped key repeatedly

Posted: 09 Jun 2023, 13:13
by mgnor
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.

Re: Using remapped key repeatedly

Posted: 09 Jun 2023, 13:19
by mikeyww
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?

Re: Using remapped key repeatedly

Posted: 09 Jun 2023, 14:31
by mgnor
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.

Re: Using remapped key repeatedly

Posted: 09 Jun 2023, 20:41
by mikeyww
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
}