Least used Keys

Get help with using AutoHotkey and its commands and hotkeys
medwatt
Posts: 20
Joined: 27 Nov 2018, 13:02

Least used Keys

30 Nov 2018, 11:58

I have a new mouse with 4 extra buttons on the sides. I can use the mouse's software to map some these buttons to keyboard keys. I have written a script that functions well except that except that since I'm using standard keyboard keys with a modifier key, some software recognize these as inbuilt hotkeys and so there's a collision of keys. I've tried looking for a way to create virtual keys but that doesn't seem possible. I've also read that it's possible to use functions keys 13-24. While my keyboard doesn't have those keys, I've tried inputting them through autohotkey, but my mouse doesn't recognize them. What can I do in this situation ? I just need 4 buttons that no software uses.
User avatar
Scr1pter
Posts: 1069
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Least used Keys

30 Nov 2018, 13:20

Which mouse - which Software?

It does not matter that your keyboard doesn't have F13 - F24.
You can use these keys anyway.

If you want to avoid collision, using these keys is generally a good idea.
(I make the same.)

Do you mostly want to execute AHK scripts with these extra mouse buttons?
(For different applications).

I, for example, have the Logitech gaming software.
My mouse is the G502.

I have different profiles.
For each profile my buttons get remapped.
In some cases I execute AHK scripts, in others I just assigned key combos like Alt+F4.

Regards
Please use code tags when posting code!
Keyboard: Logitech G15 FE - Mice: Logitech G9 FE, G502 FE, G602 - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.29.00
medwatt
Posts: 20
Joined: 27 Nov 2018, 13:02

Re: Least used Keys

02 Dec 2018, 15:39

Scr1pter wrote:
30 Nov 2018, 13:20
Which mouse - which Software?

It does not matter that your keyboard doesn't have F13 - F24.
You can use these keys anyway.

If you want to avoid collision, using these keys is generally a good idea.
(I make the same.)

Do you mostly want to execute AHK scripts with these extra mouse buttons?
(For different applications).

I, for example, have the Logitech gaming software.
My mouse is the G502.

I have different profiles.
For each profile my buttons get remapped.
In some cases I execute AHK scripts, in others I just assigned key combos like Alt+F4.

Regards
Sorry for replying late. I have tried using F13-F24 by passing these keys (since they are not present on my keyboard) to the mouse's software using autohotkey. For instance I mapped F1 to F13 (F1::F13) so that when I press F1, F13 is sent. The mouse's software doesn't recognize F13; it shows garbage data. Look at the attached image below where I had just pressed F1 (which was mapped to F13) followed by F2. The mouse simply doesn't recognize F13 or any key from F13-F24.
Attachments
Mouse.png
Mouse.png (884.14 KiB) Viewed 1134 times
Noesis
Posts: 299
Joined: 26 Apr 2014, 07:57

Re: Least used Keys

02 Dec 2018, 23:55

I'm not sure what brand or software the screenshot represents, and it could be somewhat important. Like Scr1pter said you can do this in LGS (Logitech gaming software, albeit not the way you are attempting to, more on this later) however some software won't recognize these keys, like for example Razer's earlier software (not sure about their newer stuff). So it is possible the software won't allow it (perhaps if you said what brand & software it actually is it could be researched).

Having said that, doing it the way you are attempting to do it could be the issue. With LGS for example it won't work the way you are doing it, you can't map a key to send the key directly, as the software sees two keys and gets confused. (This remapping software is often low level, usually at the driver or just above it so AHK isn't always capable of blocking the "real" key/input early enough and/or what it sends may be ignored or seen as a fake key by the software).

What you need to do with LGS (as an example) is delay the key press, so you press a key, and it will send the remapped key after say 1000ms, and during that time you select the button to remap, and make sure the relevant section has focus for when the key is sent (so you are forcing the software to start looking for a key after you have pressed the physical remapped key), so it only ever "sees" one key.

Another option that may work is don't use the keyboard to send the key, this depends on the software as if it picks up a mouse button as keyboard input (i.e if it uses a generic input & doesn't look for "keys" specifically) then it definitely won't work but if it ignores mouse buttons as entries you could try mapping to a mouse button instead or perhaps a joystick/gamepad button. (Again this last method won't work for LGS, despite not accepting buttons as keys, it requires the delayed input, if memory serves me correctly, but with the software you are using it may work ? I, don't know).

Oh yeah and remember to run you're script as admin, odds are good the remapping software has elevated rights, and will completely ignore ahk if it doesn't have those rights as well. (do this first if you didn't already)
Buzzerb
Posts: 3
Joined: 21 Jan 2018, 01:34

Re: Least used Keys

03 Dec 2018, 00:01

As stated above, in most mouse software, if you press a key first it will be instantly recognized and ignore autohotkey inputs. For my mouse software, I had to make a work around that clicked the "Add new key" button for me, waited a second, then sent F13-24.

You are welcome to try this for yourself

The code is here

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

F1::
  Sleep 250
  Click
  Sleep 250
  Send {F13}
return

F2::
  Sleep 250
  Click
  Sleep 250
  Send {F14}
return

F3::
  Sleep 250
  Click
  Sleep 250
  Send {F15}
return

F4::
  Sleep 250
  Click
  Sleep 250
  Send {F16}
return

F5::
  Sleep 250
  Click
  Sleep 250
  Send {F17}
return

F6::
  Sleep 250
  Click
  Sleep 250
  Send {F18}
return

F7::
  Sleep 250
  Click
  Sleep 250
  Send {F19}
return

F8::
  Sleep 250
  Sleep 250
  Click
  Sleep 250
  Send {F20}
return

F9::
  Sleep 250
  Click
  Sleep 250
  Send {F21}
return

F10::
  Sleep 250
  Click
  Sleep 250
  Send {F22}
return

F11::
  Sleep 250
  Click
  Sleep 250
  Send {F23}
return

F12::
  Sleep 250
  Click
  Sleep 250
  Send {F24}
return
To use it, place your mouse cursor above the "Add new key" button or equivalent, and press F1 through to F12. Enjoy :).
medwatt
Posts: 20
Joined: 27 Nov 2018, 13:02

Re: Least used Keys

03 Dec 2018, 12:17

Noesis wrote:
02 Dec 2018, 23:55
I'm not sure what brand or software the screenshot represents, and it could be somewhat important. Like Scr1pter said you can do this in LGS (Logitech gaming software, albeit not the way you are attempting to, more on this later) however some software won't recognize these keys, like for example Razer's earlier software (not sure about their newer stuff). So it is possible the software won't allow it (perhaps if you said what brand & software it actually is it could be researched).

Having said that, doing it the way you are attempting to do it could be the issue. With LGS for example it won't work the way you are doing it, you can't map a key to send the key directly, as the software sees two keys and gets confused. (This remapping software is often low level, usually at the driver or just above it so AHK isn't always capable of blocking the "real" key/input early enough and/or what it sends may be ignored or seen as a fake key by the software).

What you need to do with LGS (as an example) is delay the key press, so you press a key, and it will send the remapped key after say 1000ms, and during that time you select the button to remap, and make sure the relevant section has focus for when the key is sent (so you are forcing the software to start looking for a key after you have pressed the physical remapped key), so it only ever "sees" one key.

Another option that may work is don't use the keyboard to send the key, this depends on the software as if it picks up a mouse button as keyboard input (i.e if it uses a generic input & doesn't look for "keys" specifically) then it definitely won't work but if it ignores mouse buttons as entries you could try mapping to a mouse button instead or perhaps a joystick/gamepad button. (Again this last method won't work for LGS, despite not accepting buttons as keys, it requires the delayed input, if memory serves me correctly, but with the software you are using it may work ? I, don't know).

Oh yeah and remember to run you're script as admin, odds are good the remapping software has elevated rights, and will completely ignore ahk if it doesn't have those rights as well. (do this first if you didn't already)
Thanks for replying. The mouse I'm using is this one: https://www.amazon.com/dp/B01FZ3BR5S/
I've tried all of the things you mentioned, but the mouse just doesn't recognize it. I've even opened the configuration file that the mouse uses with a HEX editor and pinpointed the exact HEX code for a given button. If I remember, the HEX code for F1 is 60, F2 is 61, and so on. I inputted 7C for F13, but it didn't work.
User avatar
Scr1pter
Posts: 1069
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Least used Keys

03 Dec 2018, 17:02

Are you able to set key combos like F1+F2?
Or can you only use modifiers + keys?

In the LGS for example I use key combos like F13+F14.
Even F1+F2 would be fine, because you could still use those keys alone.

Regards
Please use code tags when posting code!
Keyboard: Logitech G15 FE - Mice: Logitech G9 FE, G502 FE, G602 - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.29.00
User avatar
Nextron
Posts: 1368
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win7 x64 AHK: Unicode x32

Re: Least used Keys

03 Dec 2018, 17:53

You could check if any of these are supported by your software: https://docs.microsoft.com/en-us/window ... -key-codes

LGS also didn't always support F13-F24. And when they finally added support , they only added F13-F23. :trollface:
Noesis
Posts: 299
Joined: 26 Apr 2014, 07:57

Re: Least used Keys

04 Dec 2018, 00:46

It seems to me the software doesn't support the F13-F24 keys. Like Nextron said LGS didn't always, and still doesn't support F24, and I know the Razer software I have doesn't support it so it's possibly more the exception to recognise these keys rather than the rule.

I see the software your mouse uses supports macros, so you should be able to do combos like Sc1pter mentioned. Just pick a key to start you're combos with (one you don't mind only being recognized on release instead of when pressed) and you can use AHK to remap the combos to something useful on a per program basis.

If you don't want to use a F1+key combo, the apps key (apps+key) is quite a good candidate if the software accepts it, as it pretty much does the same thing as a single right mouse button click, and most software & games ignore it by default, since it's not on all keyboards, and I suspect you (like many others) don't really use it. Capslock, is another key I often see referred to as never used and hence kinda useless to some people too. Basically you can use whatever key you want (just don't use ctrl, alt or win since they are the default keys used by software with key combos).
User avatar
Scr1pter
Posts: 1069
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Least used Keys

04 Dec 2018, 06:42

Maybe you guys use an older version of the LGS, because for me it works perfectly!
lua code:

Code: Select all

	
	if event == "MOUSE_BUTTON_PRESSED" and arg == 9 and current_mkey == 3 then
		--Test
		PressAndReleaseKey("F24")
	end
ahk code:

Code: Select all

F24::
MsgBox, F24 was pressed by LGS
return
I receive both the MessageBox and when testing the profile in LGS, it correctly shows F24.
Image

My LGS version is 8.9.6

Regards
Please use code tags when posting code!
Keyboard: Logitech G15 FE - Mice: Logitech G9 FE, G502 FE, G602 - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.29.00
Noesis
Posts: 299
Joined: 26 Apr 2014, 07:57

Re: Least used Keys

05 Dec 2018, 00:41

Ok thanks, Yeah I should of tested it before I said it still doesn't support it. I was basing it on ages ago and assumed (incorrectly, based on my memory and Nextron's comment) it was still like that.

Also in case you're interested there is a subtle historical difference between assignments & using the scripting engine. Doing it via scripting, as you show, actually always did work even before scripting was was implemented in the gui, but involved manually editing a profiles xml file. Assignments however didn't work for the high Function keys at that point in time (via gui or xml edit). Not sure exactly what version it came in, but yeah it was added.

Of course the only point I was trying to make with what I said originally is, that it needs to be supported by the software to work. The OP also mentioned he edited the config files manually and it failed to work, so I think it's a pretty safe bet the software for his mouse doesn't support it.

FYI: current version of LGS is 9.02.65 (you watch, now I posted this, they'll release a new version ;) )

Return to “Ask For Help”

Who is online

Users browsing this forum: aifritz, Bing [Bot], broly, flyingDman, ilhom, john68, KHA, Odlanir, redrum, zhainv2013 and 208 guests