Wenfang Du
Wenfang Du

Reputation: 11397

How to trigger an action if there's only one key being pressed?

Here's my current script:

Shift::Send ^{Space}

It doesn't only trigger ^{Space} on pressing Shift alone, it also triggers on Alt+Shift (just these two keys) and Ctrl+Shift (just these two keys) if Shift is the last released, is there a way to trigger ^{Space} if Shift is the only key being pressed?

AutoHotkey Version: 1.1.33.09.

Upvotes: 2

Views: 819

Answers (5)

Wenfang Du
Wenfang Du

Reputation: 11397

Here's my working script:

~*Alt::
~*Ctrl::
~*Shift::return

Shift::SendEvent ^{Space}

Upvotes: 0

SteveMylo
SteveMylo

Reputation: 13

try this:

Shift::
SendEvent, foo
return
Ctrl & Shift::return
Alt & Shift::return

This doesn't work with Numpad keys though for some reason. And again, this script will have to be Context-sensitive.

Upvotes: 0

SteveMylo
SteveMylo

Reputation: 13

This works for me.

~Shift::return
#If, A_PriorHotkey = "~Shift"
Shift Up::SendEvent, foo
!*c::SendEvent, foo
#If
return

Upvotes: 0

SteveMylo
SteveMylo

Reputation: 13

I have your answer and to think I only learned this today.

  ~Shift::return
    #If, A_PriorHotkey = "~Shift"
    Shift Up::
    SendEvent, ^{space}
    #If
    return

Worked for me. The ' ~ ' symbol will let you still type capitals although it will still send the ^{space} still. Either delete it (it still works) and/or You will have to make this script Context-sensitive right?

P.s. I learned it from another code and just adapted it to my and your needs. I needed almost the same thing as you today :-)

Here is the old code I found which I adapted

^k::return

#If, A_PriorHotkey = "^k"
^a::ToolTip, % A_ThisHotkey " pressed with ^k"
^b::ToolTip, % A_ThisHotkey " pressed with ^k"
^c::ToolTip, % A_ThisHotkey " pressed with ^k"
^d::ToolTip, % A_ThisHotkey " pressed with ^k"

^k up::SendInput, ^k
#If

Upvotes: 0

SteveMylo
SteveMylo

Reputation: 13

Yup Simple, Put the '~ Tilda' key next to it.

~Shift::
SendEvent, ^{Space}
return

Upvotes: -1

Related Questions