Basic hotkey translation?

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
Dazzer123
Posts: 5
Joined: 14 May 2024, 04:29

Basic hotkey translation?

14 May 2024, 04:38

Hi folks,

I'm completely new to AutHotKey so please be gentle!

I'd like to achieve the following hotkey transformations:

When i press Numpad1, i want to be transformed into the ALT key.

Also, how can i make AHK transform Numpad2 into middle mouse button down (obviously also MMB release when i release Numpad2)?

I have a couple of questions relating to this:

Is it possible to instruct AHK to only do these conversions when i'm using certain program?

If not, how do you turn AHK on and off?

Because i only want this conversion to happen when i'm in a certain program.

Thanks in advance!
Rohwedder
Posts: 7732
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Basic hotkey translation?

14 May 2024, 05:43

Hallo,
try:

Code: Select all

#Requires AutoHotkey v2.0
; instructs AHK to only do these conversions
; when an Notpad window is active
#HotIf WinActive("ahk_exe notepad.exe")
Numpad1::Alt
NumpadEnd::Alt
Numpad2::MButton
NumpadDown::MButton
#HotIf
Dazzer123
Posts: 5
Joined: 14 May 2024, 04:29

Re: Basic hotkey translation?

14 May 2024, 06:10

Thanks a lot, that's partly working for me!

Only, i can't get it to restrict to my application.

You wrote:

"ahk_exe notepad.exe"

I changed that to "ahk_exe Cubase13.exe"

Perhaps that's not correct?

Just to be sure i understand what i should be expecting: is that script?:

a) only going to be active in my chosen .exe
or
b) going to be active for all programs only when my chosen .exe is running?
User avatar
boiler
Posts: 17242
Joined: 21 Dec 2014, 02:44

Re: Basic hotkey translation?

14 May 2024, 06:22

It should restrict it to only when a window of that application is active. I don’t see how those key remappings could be active when other windows are active.
Dazzer123
Posts: 5
Joined: 14 May 2024, 04:29

Re: Basic hotkey translation?

14 May 2024, 06:35

Sorry, i meant that it's not working in the following respect:

If i close Cubase13.exe, then try to type text in any other app, numpad 1 & 2 are not writing a number, but 3 is.

So it seems that the restrictive part is not working.

Another question:

What do the
NumpadEnd::Alt
&
NumpadDown::MButton
doing?

I commented them out and it has not change on the effect of the script, at least the way i'm using it (i need the conversions to happen only while the key is pressed, not toggle action).
User avatar
boiler
Posts: 17242
Joined: 21 Dec 2014, 02:44

Re: Basic hotkey translation?

14 May 2024, 06:53

Dazzer123 wrote: Sorry, i meant that it's not working in the following respect:

If i close Cubase13.exe, then try to type text in any other app, numpad 1 & 2 are not writing a number, but 3 is.
That shouldn't be the case, and I can't reproduce the problem. Make sure you don't have any other scripts still running that you may have written to try to remap these keys.

Dazzer123 wrote: What do the
NumpadEnd::Alt
&
NumpadDown::MButton
doing?

I commented them out and it has not change on the effect of the script, at least the way i'm using it (i need the conversions to happen only while the key is pressed, not toggle action).
He did that so those same keys will have that effect no matter which state NumLock is in (they are the alternate action of the same physical keys).
Dazzer123
Posts: 5
Joined: 14 May 2024, 04:29

Re: Basic hotkey translation?

14 May 2024, 06:58

Thanks, i guess i was doing something wrong because now it's working!

I'm curious why AHK doesn't also have sort of user interface like X-Keys MacroWorks, that would open up the app to a lot more people who lack basic coding skills!?
User avatar
boiler
Posts: 17242
Joined: 21 Dec 2014, 02:44

Re: Basic hotkey translation?

14 May 2024, 07:05

Dazzer123 wrote: Thanks, i guess i was doing something wrong because now it's working!

I'm curious why AHK doesn't also have sort of user interface like X-Keys MacroWorks, that would open up the app to a lot more people who lack basic coding skills!?
Different target audience. This is a scripting language, and its roots are from another scripting language (AutoIt) that didn't have hotkeys, hence the name AutoHotkey. Many, or I would suspect most, who use it wouldn't want the bloat of that user interface. And what seems to be proof of that is the relative lack of use of Pulovers Macro Creator, which perhaps is what you're looking for. I would caution you that if you use it and need help, the author seems to have abandoned support for it, and the forum members don't really provide support for it because as I said, they have no interest in using it.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: FanaticGuru, teadrinker and 41 guests