Multiple options with one Hotkey.
Multiple options with one Hotkey.
Hello,
I'm trying to make an unusual hotkey. I have asasigned some actions for F1. If I hold down and release F2 and then press F1, can I make the F1 do some other actions?
I'm trying to make an unusual hotkey. I have asasigned some actions for F1. If I hold down and release F2 and then press F1, can I make the F1 do some other actions?
Last edited by BoBo on 14 Jun 2022, 22:34, edited 1 time in total.
Reason: Changed subject line from "Is it possible?” to a more specific "Multiple options with one Hotkey".
Reason: Changed subject line from "Is it possible?” to a more specific "Multiple options with one Hotkey".
Re: Is it possible?
Code: Select all
#InstallKeybdHook
F1::
If (A_PriorKey = "F2")
Send x
Else Send y
Return
Re: Is it possible?
Thank you for your help, Mikey. I just found out that I can't use the F2 anyway. Is it possible to hold down the F1 and make then the F1 behave differently?mikeyww wrote: ↑13 Jun 2022, 19:32Code: Select all
#InstallKeybdHook F1:: If (A_PriorKey = "F2") Send x Else Send y Return
Re: Is it possible?
Code: Select all
F1::
KeyWait, F1, T.3
If ErrorLevel ; Held
Send Held `
Else Send Normal `
KeyWait, F1
Return
Re: Is it possible?
It says Duplicate hotkey. I have already assigned some action for F1. I also tried to past the other actions for F1 after elsemikeyww wrote: ↑13 Jun 2022, 19:47Code: Select all
F1:: KeyWait, F1, T.3 If ErrorLevel ; Held Send Held ` Else Send Normal ` KeyWait, F1 Return
Code: Select all
F1::
KeyWait, F1, T.3
If ErrorLevel { ; Held
ControlClick, x312 y227, ahk_class Qt5QWindowIcon,,Left,1,NA `
Sleep, 30
SendInput {Down} `
}
Else {
ControlClick, x1920 y240, ahk_class Qt5QWindowIcon,,Left,1,NA `
SendInput {Down 3} `
KeyWait, F1
}
Return
Last edited by fona on 13 Jun 2022, 20:28, edited 1 time in total.
Re: Is it possible?
Use my script, which already has two actions. You can change them to be whatever you like. Alternatively, use your script instead of mine.
Code: Select all
#IfWinExist ahk_class Qt5QWindowIcon
F1::
KeyWait, F1, T.3
If ErrorLevel { ; Held
ControlClick, x312 y227,,,,, NA
Sleep, 30
Send {Down}
SoundBeep, 1500
} Else {
ControlClick, x1920 y240,,,,, NA
Send {Down 3}
SoundBeep, 1000
}
KeyWait, F1
Return
#IfWinExist
Re: Is it possible?
Sorry , I just didn't formulate the second question well. As I wrote in the beginning, I would like to hold the F1 and release it and when I press again the F1, it should behave differently, while I already have F1 with some actionsfona wrote: ↑13 Jun 2022, 19:38Thank you for your help, Mikey. I just found out that I can't use the F2 anyway. Is it possible to hold down the F1 and make then the F1 behave differently?mikeyww wrote: ↑13 Jun 2022, 19:32Code: Select all
#InstallKeybdHook F1:: If (A_PriorKey = "F2") Send x Else Send y Return
Re: Is it possible?
Code: Select all
F1::
KeyWait, F1
KeyWait, F1, DT.25
If ErrorLevel ; Pressed once
Send Once `
Else Send Twice `
Return
Re: Is it possible?
Unfortunately, couldn't solve the problem. This code turns the F1 into single and double press hotkey. Indstead of the single one, I wished that I could hold down the F1 and release it and I when I press it again immediately after that it could do some stuff, while I also can keep the normal F1 with else. Anyway, thank you for your time, Mikeymikeyww wrote: ↑13 Jun 2022, 20:44Code: Select all
F1:: KeyWait, F1 KeyWait, F1, DT.25 If ErrorLevel ; Pressed once Send Once ` Else Send Twice ` Return
Re: Is it possible?
This seems to be an exercise in how to describe a goal. A detailed example would go a long way in helping.
Another flavor is below.
Another flavor is below.
Code: Select all
#InstallKeybdHook
F1::
If (A_PriorKey = "F1" && on) {
Send 2
on := False
} Else {
Send 1
on := True
}
Return
Re: Is it possible?
@mikeyww, I have to give you kudos for your patience.
When I see things like this, I usually just wonder, "WHY?!?"
A keyboard typically has 12 function keys. Add to that the standard modifier keys Ctrl, Alt, Shift, Ctrl-Alt, Ctrl-Shift, Alt-Shift, Ctrl-Alt-Shift and you have 96 possible function keys to choose from (and I didn't even mention the Windows key! Add those modifiers to all the rest of the keys on the keyboard and you have, well, I'm not going to do the math, but, A LOT of possible combinations!
And yet, some want to put a dozen functions on one key, depending on how many milliseconds it's held down, or how many times it's pressed in rapid succession, or if I hold my mouth just the right way when pressing it. Why not just have a keyboard with one key and learn Morse Code?
Climbing down off my soapbox now.
Russ
When I see things like this, I usually just wonder, "WHY?!?"
A keyboard typically has 12 function keys. Add to that the standard modifier keys Ctrl, Alt, Shift, Ctrl-Alt, Ctrl-Shift, Alt-Shift, Ctrl-Alt-Shift and you have 96 possible function keys to choose from (and I didn't even mention the Windows key! Add those modifiers to all the rest of the keys on the keyboard and you have, well, I'm not going to do the math, but, A LOT of possible combinations!
And yet, some want to put a dozen functions on one key, depending on how many milliseconds it's held down, or how many times it's pressed in rapid succession, or if I hold my mouth just the right way when pressing it. Why not just have a keyboard with one key and learn Morse Code?
Climbing down off my soapbox now.
Russ
Re: Is it possible?
You might want to consider that not everyone uses a keyboard like you do, and your approach isn’t right, it’s just your preference. Others have their own valid preferences.RussF wrote: ↑ When I see things like this, I usually just wonder, "WHY?!?"
…
And yet, some want to put a dozen functions on one key, depending on how many milliseconds it's held down, or how many times it's pressed in rapid succession, or if I hold my mouth just the right way when pressing it. Why not just have a keyboard with one key and learn Morse Code?
Your facepalm is directed at someone like me. I am one that really doesn’t like having to use modifier keys for most hotkeys, except perhaps the Shift key and the occasional Ctrl key (but not both together), and I really don’t like multiple-modifier keys. Especially for touch typists, these types of key combinations require removing one or both hands from home row, which is really disruptive compared to being able to press one key a bit longer or to double-tap it.
I personally don’t have a lot of hotkeys that I use while I’m typing, but if I did, I would much prefer to use one of the approaches you are so confounded by than one that requires performing all kinds of hand contortions to execute, then finding my fingers back to ASDF/JKL;
Your post comes off as ridiculing people who ask for strawberry ice cream when it doesn’t make sense for anyone to want to eat anything but chocolate because it’s your favorite.
Off my soapbox.
Re: Is it possible?
My favorite key is F3. Everyone should use it frequently! Down with F1!
Re: Is it possible?
My sincerest apologies. "In the moment", my post didn't seem so bad, but upon re-reading it and reflecting, it does seem a bit harsh. So sorry.
So, yes, as you stated, it is my preference to use modifiers, because by relocating Ctrl I DON'T have to move my fingers from the home row to reach any modifier or combination thereof.
Again, please accept my apologies - I never meant to ridicule anyone.
russ
Nor do I, but the ones I use all the time use modifiers. Before I even discovered AHK, I found a simple registry hack that swaps the CapsLock key with the Left-Ctrl key, effectively putting Ctrl back up where it belongs - next to the A key and very easy to reach. Early aftermarket keyboards even had a physical switch to swap those keys. @boiler, I think we are close in age, so you can probably relate when I tell you I wrote code for years in WordStar, where every command required the Ctrl key and I became accustomed to it's location next toA.boiler wrote: I personally don’t have a lot of hotkeys that I use while I’m typing, but if I did, I would much prefer to use one of the approaches you are so confounded by than one that requires performing all kinds of hand contortions to execute, then finding my fingers back to ASDF/JKL;
So, yes, as you stated, it is my preference to use modifiers, because by relocating Ctrl I DON'T have to move my fingers from the home row to reach any modifier or combination thereof.
Again, please accept my apologies - I never meant to ridicule anyone.
russ
Re: Is it possible?
I believe it would be too much time-consuming to make such a complicated hotkey. Than you for your efforts, Mikey.
As boiler pointed out, everyone has their own workflow. So it fits to my weird workflow .
Re: Is it possible?
Try the last one that I posted.
Re: Is it possible?
@fona
Part of the main workflow in this forum, creating a meaningful, problem-related subject line... so your potential supporters will have an idea of what's your main issue.
Your current subject line is fine in a forum discussing Area 51, a mail to your lottery agency after you've heard you've cracked the jackpot but can't find the ticket, the moment Paul Simon thought about leaving a lover, or the moment you stumbled over that Wikipedia article about gonorr...
So no, it's not the "Subject Line of the Week", and yes, please be more specific once you create a follow-up thread.
Thx for listening & happy scripting.
Part of the main workflow in this forum, creating a meaningful, problem-related subject line... so your potential supporters will have an idea of what's your main issue.
Your current subject line is fine in a forum discussing Area 51, a mail to your lottery agency after you've heard you've cracked the jackpot but can't find the ticket, the moment Paul Simon thought about leaving a lover, or the moment you stumbled over that Wikipedia article about gonorr...
So no, it's not the "Subject Line of the Week", and yes, please be more specific once you create a follow-up thread.
Thx for listening & happy scripting.
Re: Is it possible?
Should've done this ages ago
Code: Select all
#SingleInstance, force
shortPresses := 0, longPresses := 0, morse := ""
$F1::
if (A_TimeSincePriorHotkey > 2000)
shortPresses := 0, longPresses := 0, morse := ""
t1 := A_TickCount
KeyWait, F1
if (A_TickCount - t1 < 150) { ; short press
if ((longPresses == 0 && shortPresses < 3) || (longPresses == 3 && shortPresses < 6)) {
shortPresses++, morse .= "."
ToolTip, %morse%
SetTimer, RemoveToolTip, -2000
} Else {
shortPresses := 0, longPresses := 0, morse := ""
ToolTip
}
} else if (!shortPresses && !longPresses) {
Send, {F1}
ToolTip
} else { ; long press
if (shortPresses == 3 && longPresses < 3) {
longPresses++, morse .= "-"
ToolTip, %morse%
SetTimer, RemoveToolTip, -2000
}
}
if (shortPresses == 6 && longPresses == 3) {
ToolTip
Run, https://www.autohotkey.com/boards/viewforum.php?f=76
shortPresses := 0, longPresses := 0, morse := ""
}
return
RemoveToolTip:
ToolTip
return
Re: Is it possible?
Idk why but it acts like a toggle. I hear different soundbeeps (2000 and 1000) each time I press F1
Code: Select all
#InstallKeybdHook
F1::
If (A_PriorKey = "F1" && on) {
SoundBeep 2000
on := False
} Else {
SoundBeep 1000
on := True
}
Return