Hi everyone. I'm trying to find a way to have several profiles for hotkeys that can be toggled with a key or key . For example, if I press '1', I want 'q' to output '1', if I press '2' - for 'q' to become '2' and so on. So far I've only got Duplicate hotkey errors with several approaches
edit: thanks, boiler, works flawlessly. I seemed to always forget to put # in front of 'if'
Hotkey profiles Topic is solved
-
- Posts: 1
- Joined: 31 Jan 2018, 07:04
Hotkey profiles
Last edited by strawberrysteel on 01 Feb 2018, 03:54, edited 1 time in total.
Re: Hotkey profiles Topic is solved
Use the Hotkey command to define/change your hotkeys.
Another approach would be to use the typical hotkey labels approach preceded by an #If directive, such as:
Another approach would be to use the typical hotkey labels approach preceded by an #If directive, such as:
Code: Select all
Profile := 1 ;default
$1::Profile := 1
$2::Profile := 2
#If Profile = 1
q::Send, 1
#If Profile = 2
q::Send, 2
-
- Posts: 78
- Joined: 15 Jun 2020, 04:22
Re: Hotkey profiles
Can just one hotkey cycle through multiple profiles, instead of assigning dedicated hotkey for each profile?
Re: Hotkey profiles
Sure. Like this:
Code: Select all
Profile := 1 ; default
Count := 3
^Tab:: ; Ctrl+Tab to cycle through the profiles
Profile := Profile = Count ? 1 : Profile + 1
ToolTip, % "Profile " Profile
SetTimer, ToolTipOff, -1000
return
ToolTipOff:
ToolTip
return
#If Profile = 1
q::Send, 1
#If Profile = 2
q::Send, 2
#If Profile = 3
q::Send, 3
-
- Posts: 78
- Joined: 15 Jun 2020, 04:22
Re: Hotkey profiles
Thank you so much! You're a legend
Can you help me with this, I wanted profile 2 behave as below:
When using Mozilla Firefox/Google Chrome
Volume Up ➡ "."
Volume Down ➡ ","
(these are the keys for next and previous frame for YouTube)
When using VLC Media Player
Volume Up ➡ "e"
Volume Down ➡ "Shift+Left"
(these are the keys for next and previous frame for VLC)
I have managed to achieve this with the following code:
It's working perfectly for now, but i'm not sure; do i need an IF contingency here (its working as expected outside these two apps as well so i'm guessing i don't.)
I wanted to add another condition here which is when using Firefox/Chrome the window title should contain " - YouTube".
Can you help me with this, I wanted profile 2 behave as below:
When using Mozilla Firefox/Google Chrome
Volume Up ➡ "."
Volume Down ➡ ","
(these are the keys for next and previous frame for YouTube)
When using VLC Media Player
Volume Up ➡ "e"
Volume Down ➡ "Shift+Left"
(these are the keys for next and previous frame for VLC)
I have managed to achieve this with the following code:
Code: Select all
#If Profile = 2
#IfWinActive, ahk_class MozillaWindowClass
Volume_Up::Send .
Volume_Down::Send ","
#IfWinActive, ahk_class Qt5QWindowIcon
Volume_Up::Send e
Volume_Down::Send +{Left}
I wanted to add another condition here which is when using Firefox/Chrome the window title should contain " - YouTube".
Re: Hotkey profiles
They should work only when the specified windows are active. What they wouldn't do is pay attention to the profile number because that gets wiped out by the #IfWinActive. To have it subject to both, you would do this:koolestani wrote: ↑ It's working perfectly for now, but i'm not sure; do i need an IF contingency here (its working as expected outside these two apps as well so i'm guessing i don't.)
Code: Select all
#If Profile = 2 && WinActive("ahk_class MozillaWindowClass")
Volume_Up::Send .
Volume_Down::Send ","
#If Profile = 2 && WinActive("ahk_class Qt5QWindowIcon")
Volume_Up::Send e
Volume_Down::Send +{Left}
To do this, the condition would be:koolestani wrote: ↑ I wanted to add another condition here which is when using Firefox/Chrome the window title should contain " - YouTube".
Code: Select all
#If Profile = 2 && WinActive(" - YouTube")
Code: Select all
SetTitleMatchMode, 2
-
- Posts: 78
- Joined: 15 Jun 2020, 04:22
Re: Hotkey profiles
Once again, worked perfectly. Thank you again.
Is there a way to change the profile name displayed in the tooltip (assuming profiles can be named in the first place)?
Is there a way to change the profile name displayed in the tooltip (assuming profiles can be named in the first place)?
Re: Hotkey profiles
You could do something like this:
Code: Select all
Profile := 1 ; default
ProfileName := ["Apple", "Banana", "Cherry"]
^Tab:: ; Ctrl+Tab to cycle through the profiles
Profile := Profile = ProfileName.Count() ? 1 : Profile + 1
ToolTip, % "Profile: " ProfileName[Profile]
SetTimer, ToolTipOff, -1000
return
ToolTipOff:
ToolTip
return
#If Profile = 1
q::Send, 1
#If Profile = 2
q::Send, 2
#If Profile = 3
q::Send, 3
-
- Posts: 78
- Joined: 15 Jun 2020, 04:22
Re: Hotkey profiles
Thank you for helping, much appreciated.
-
- Posts: 20
- Joined: 11 Feb 2018, 21:54
Re: Hotkey profiles
Hi, I know this is an old thread but it's exactly what I'm looking for and I would really appreciate it if someone can help me with my scenario.boiler wrote: ↑31 Jan 2018, 11:12Use the Hotkey command to define/change your hotkeys.
Another approach would be to use the typical hotkey labels approach preceded by an #If directive, such as:Code: Select all
Profile := 1 ;default $1::Profile := 1 $2::Profile := 2 #If Profile = 1 q::Send, 1 #If Profile = 2 q::Send, 2
So after pressing q to send 1, how do I make it switch to another profile without pressing key associate to that profile?
Thank you, hope to get some helps!
Re: Hotkey profiles
Do you mean that after pressing q, you want it to not only send 1 but also switch to a different profile number? Something like this?:flamingonion wrote: ↑ So after pressing q to send 1, how do I make it switch to another profile without pressing key associate to that profile?
Code: Select all
Profile := 1 ;default
$1::Profile := 1
$2::Profile := 2
#If Profile = 1
q::
Send, 1
Profile := 2
return
#If Profile = 2
q::
Send, 2
Profile := 1
return
-
- Posts: 20
- Joined: 11 Feb 2018, 21:54
Re: Hotkey profiles
Thank you for the response, I didn't know it was that straightforward lol, cheer!boiler wrote: ↑23 Jan 2023, 16:41Do you mean that after pressing q, you want it to not only send 1 but also switch to a different profile number? Something like this?:flamingonion wrote: ↑ So after pressing q to send 1, how do I make it switch to another profile without pressing key associate to that profile?Code: Select all
Profile := 1 ;default $1::Profile := 1 $2::Profile := 2 #If Profile = 1 q:: Send, 1 Profile := 2 return #If Profile = 2 q:: Send, 2 Profile := 1 return
Re: Hotkey profiles
Hello
I've been attempting to create a script similar to this
(for which, after having just now found your script, clarified quite a lot).
Although I've been having trouble with tooltips as they do not want to display/popup.
Even by copy/pasting to then executing this exact-provided script-example as-is, to yet still be facing this very problem.
(this trouble was also a present-factor withing own prior-script's version)
Although, if I create a separate hotkey to create a "non-relative to any variable/what-so-ever" generic-tooltip, then it works.
(a generic tooltip to display a basic direct-string entry).
I was wondering if something had changed since original-date of this provided-example?
Or if there's something else that I'm missing? maybe a "#persistent" or something?
To further elaborate:
My understanding of scripte-example; Ctrl+Tab switches profiles in concurrence of generating a profile-name tooltip.
Changing profile is successful although nothing is happening in terms of tooltip.
Side-Note:
My AHK v1 is configured via a "per-script's tasktray icon". (not sure if this would make a difference).
If anyone would have any ideas to share, it would be greatly appreciated.
Kind regards,
OrangeCat
---------------------------------------------------------------------------------------------------------------------------------------
I've been attempting to create a script similar to this
(for which, after having just now found your script, clarified quite a lot).
Although I've been having trouble with tooltips as they do not want to display/popup.
Even by copy/pasting to then executing this exact-provided script-example as-is, to yet still be facing this very problem.
(this trouble was also a present-factor withing own prior-script's version)
Although, if I create a separate hotkey to create a "non-relative to any variable/what-so-ever" generic-tooltip, then it works.
(a generic tooltip to display a basic direct-string entry).
I was wondering if something had changed since original-date of this provided-example?
Or if there's something else that I'm missing? maybe a "#persistent" or something?
To further elaborate:
My understanding of scripte-example; Ctrl+Tab switches profiles in concurrence of generating a profile-name tooltip.
Changing profile is successful although nothing is happening in terms of tooltip.
Side-Note:
My AHK v1 is configured via a "per-script's tasktray icon". (not sure if this would make a difference).
If anyone would have any ideas to share, it would be greatly appreciated.
Kind regards,
OrangeCat
---------------------------------------------------------------------------------------------------------------------------------------
boiler wrote: ↑10 Jan 2021, 11:09You could do something like this:Code: Select all
Profile := 1 ; default ProfileName := ["Apple", "Banana", "Cherry"] ^Tab:: ; Ctrl+Tab to cycle through the profiles Profile := Profile = ProfileName.Count() ? 1 : Profile + 1 ToolTip, % "Profile: " ProfileName[Profile] SetTimer, ToolTipOff, -1000 return ToolTipOff: ToolTip return #If Profile = 1 q::Send, 1 #If Profile = 2 q::Send, 2 #If Profile = 3 q::Send, 3
Re: Hotkey profiles
Nothing is missing, and #Persistent has nothing to do with it in a script that has a hotkey. Write a very simple script that displays a ToolTip. And write the simplest script possible that recreates the problem of not displaying a ToolTip. Post both scripts here if you can’t solve it via that exercise.OrangeCat wrote: ↑ Although I've been having trouble with tooltips as they do not want to display/popup.
Even by copy/pasting to then executing this exact-provided script-example as-is, to yet still be facing this very problem.
(this trouble was also a present-factor withing own prior-script's version)
Although, if I create a separate hotkey to create a "non-relative to any variable/what-so-ever" generic-tooltip, then it works.
(a generic tooltip to display a basic direct-string entry).
I was wondering if something had changed since original-date of this provided-example?
Or if there's something else that I'm missing? maybe a "#persistent" or something?