Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[Issue] #If GetKeyState("LWin","P"), unexpected behavior



  • Please log in to reply
2 replies to this topic
Seidenweber
  • Moderators
  • 638 posts
  • Last active: Sep 06 2015 01:51 PM
  • Joined: 10 May 2011

works

While !GetKeyState("Escape","P") {
    ToolTip % "physical state:`t" GetKeyState("LWin","P") "`n" 
            . "toggle state:`t" GetKeyState("LWin","T")
    Sleep, 100
}

doesn't work

#If GetKeyState("LWin","P") 
    x::MsgBox, 4160,% A_Space, You pressed 'x' while LWin was down!
#If 

works

$LWin::Send, {LWin}

#If GetKeyState("LWin","P") 
    x::MsgBox, 4160,% A_Space, You pressed 'x' while LWin was down!
#If 

All questions & answers are related to AHK 1.1.19.03 x64 Unicode

 


Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
✓  Best Answer

This behaviour is intended.  x:: triggers when you press x without modifiers.  With your third code, the LWin key is physically down but logically up (because Send {LWin} presses and instantly releases the key).  You need to use either #x:: or *x:: if LWin is logically down.



Seidenweber
  • Moderators
  • 638 posts
  • Last active: Sep 06 2015 01:51 PM
  • Joined: 10 May 2011

Thanks for your answer.


All questions & answers are related to AHK 1.1.19.03 x64 Unicode