Hey
Is it possible to send something like "Alt & b" without blocking hotkeys like "^!b"?
Thanks for your help!
Edit: the "Alt &" is necessary for one of them and can't be changed to "!".
Using "&" Without Blocking?
-
- Posts: 296
- Joined: 07 Nov 2020, 08:37
Using "&" Without Blocking?
Last edited by hemsith14_ on 18 Nov 2020, 07:50, edited 1 time in total.
Re: Using "&" Without Blocking?
Hallo,
try:Why should this block any Hotkey?
try:
Code: Select all
Send, !b
-
- Posts: 296
- Joined: 07 Nov 2020, 08:37
Re: Using "&" Without Blocking?
Once I send ^!b in a script that contains Alt & b, the ^!b hotkey triggers the Alt & b one. This is what I'm trying to prevent.
I need them to be 2 sepereate hotkeys.
I need them to be 2 sepereate hotkeys.
Re: Using "&" Without Blocking?
When you say you send Alt & b, do you mean you are sending them using the Send command? Or you just have two separate hotkeys? Are you using !b as Rohwedder suggested? Can you post the exact lines from your script that are causing a problem?
Re: Using "&" Without Blocking?
Code: Select all
!b::Send x
^!b::Send y
Code: Select all
Alt & b::Send % GetKeyState("Ctrl") ? "x" : "y"
Code: Select all
^!b::Send y
#If !GetKeyState("Ctrl")
Alt & b::Send x
-
- Posts: 296
- Joined: 07 Nov 2020, 08:37
Re: Using "&" Without Blocking?
Code: Select all
; Test
Alt & b::
Send, hello world
Returb
^!b::
Send, 12345
Return
Sorry if I wasn't clear enough, let me know if it's understandable.
Last edited by hemsith14_ on 18 Nov 2020, 07:39, edited 1 time in total.
Re: Using "&" Without Blocking?
I provided three methods.
Code: Select all
!b::Send hello world
^!b::Send 12345
-
- Posts: 296
- Joined: 07 Nov 2020, 08:37
Re: Using "&" Without Blocking?
I can't use "!" as Alt in one of them since the "Alt &" is necessary for one of my hotkeys.
In the best case scenario, I'd like to add something to "Alt & b" in order to get it out of the way of ^!b. But still, the & function is necessary in Alt b.
In the best case scenario, I'd like to add something to "Alt & b" in order to get it out of the way of ^!b. But still, the & function is necessary in Alt b.
Re: Using "&" Without Blocking?
All three methods work, so you have a choice.
Code: Select all
^!b::Send 12345
#If !GetKeyState("Ctrl")
Alt & b::Send hello world
-
- Posts: 296
- Joined: 07 Nov 2020, 08:37
Re: Using "&" Without Blocking?
Could you briefly explain why would it work?
What is the "!" doing before the "GetKeyState"?
Thanks!
What is the "!" doing before the "GetKeyState"?
Thanks!
Re: Using "&" Without Blocking?
1. Have you tested it?
2. ! means "Not". If CTRL is not pressed, then all subsequent lines will apply.
#If enables the use of context-sensitive hotkeys and hotstrings.
2. ! means "Not". If CTRL is not pressed, then all subsequent lines will apply.
#If enables the use of context-sensitive hotkeys and hotstrings.
-
- Posts: 296
- Joined: 07 Nov 2020, 08:37
Re: Using "&" Without Blocking?
1. Not yet, I'll be able to do it soon.
2. I see. What if I'll have more shortcuts that using other modifiers and Alt+b in them? Would I have to insert more "ifs"?
Furthermore, it is possible to fix it so Alt & b would be the same as "!b" in terms of its activation (so it would be limited just to these 2 charecters)?
2. I see. What if I'll have more shortcuts that using other modifiers and Alt+b in them? Would I have to insert more "ifs"?
Furthermore, it is possible to fix it so Alt & b would be the same as "!b" in terms of its activation (so it would be limited just to these 2 charecters)?
Re: Using "&" Without Blocking?
Code: Select all
^!b::Send 12345
!+b::Send abc
#If !GetKeyState("Ctrl") && !GetKeyState("Shift")
Alt & b::Send hello world
-
- Posts: 296
- Joined: 07 Nov 2020, 08:37
Re: Using "&" Without Blocking?
So can I add && and just put all of the modifers there?
Re: Using "&" Without Blocking?
Yes, but there aren't many more modifiers left for you!
You can actually use any sort of condition or expression on the #If line. The documentation is below.
https://www.autohotkey.com/docs/commands/_If.htm
When you have more time, you can try these various things to see what works for you.
You can actually use any sort of condition or expression on the #If line. The documentation is below.
https://www.autohotkey.com/docs/commands/_If.htm
When you have more time, you can try these various things to see what works for you.
-
- Posts: 296
- Joined: 07 Nov 2020, 08:37
Re: Using "&" Without Blocking?
And what if I'm using the #if already in order to detact a certain window? Would it interrupt it if I put another if inside of it?
Example:
In case it's not possible to do it like that, how should I do it?
Example:
Code: Select all
#if WinActive ; define window
#If !GetKeyState("Ctrl")
Alt & b::Send hello world
#If ; stops get key state if?
# if ; stops defining window ?
Re: Using "&" Without Blocking?
As explained in the documentation, which I recommend reading, one statement at a time applies, but as I mentioned, you can combine expressions in any combination that you need.
Give it a whirl, and see what works.
Code: Select all
#If !GetKeyState("Ctrl") && WinActive("ahk_exe notepad.exe")
Alt & b::Send hello world
#If
There are other ways to organize the conditionals to meet your needs. You can have just one conditional statement, and then check for the other condition within the hotkey routine. My other examples above show other possibilities, such as not using the #If directive at all.#If and #IfWin are also mutually exclusive; that is, only the most recent #If or #IfWin will be in effect.
Give it a whirl, and see what works.
Re: Using "&" Without Blocking?
Code: Select all
Alt & b::gosub % GetKeyState("Ctrl") ? "ctrl_alt_b" : "alt_b"
return
alt_b:
MsgBox, You pressed Alt+b
return
ctrl_alt_b:
MsgBox, You pressed Ctrl+Alt+b
return
-
- Posts: 296
- Joined: 07 Nov 2020, 08:37
Re: Using "&" Without Blocking?
Thank you very much
Who is online
Users browsing this forum: downstairs, sebalotek and 186 guests