Jump to content

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

Sending L/RWin down and up commands to trigger Win-key combinations


  • Please log in to reply
5 replies to this topic
lavalampan
  • Members
  • 2 posts
  • Last active: Feb 12 2015 08:41 AM
  • Joined: 08 Feb 2015

Hi there, 

i'm having a small problem with my current BT-keyboard which is made to be used with tablets or phone but currently i'm using it for my laptop and use AHK to remap keys that are missing for full windows functionality.

 

I'm having a 'Lang' -key on my keyboard that is received by my laptop as "Shit + Space"-press. Alright, i want to remap this key with AHK to behave just as the Win-key on a ordinary keyboard but having a bit of a struggle here. This is what I've got so far:

 

This simulates a ordinary Win-key press:

Shift & Space::
KeyWait Shift
KeyWait Space
Send {LWin}
return

That's cool but that doesn't give me the full functionality of the win-key such as the Win+d combination to show me the desktop. The following script let me send key combinations but in the wrong order which is quite irritating.

Shift & Space::
   If GetKeyState("d","P")
     Send {RWin down}d{RWin up}
return

And finally this script seems to hold the win-key pressed for ever which gives me the combination functionality but still sucks since it won't let me use my keyboard in any other way:

Shift & Space::
Send {LWin}
return

What i'm looking for is a way to just tell AHK to:

When holding my 'Lang'-key -> Press and hold the Win-key

If (pressing another key) -> Send win-key + pressed key -combination and release all.

if(releasing 'Lang'-key) -> just act as a Win-key.

 

Any Suggestions?



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

but still sucks since it won't let me use my keyboard in any other way:

 

What do you mean it can't be used in any other way?

 

Anyhow, either of these scripts should work fine:

 

+Space::Send {LWin}

 

or

 

+Space::
Send {LWin down}
KeyWait, Shift
KeyWait, Space
Send {LWin up}
return


lavalampan
  • Members
  • 2 posts
  • Last active: Feb 12 2015 08:41 AM
  • Joined: 08 Feb 2015

Sorry but your suggested script is not working. I guess it is in the way the 'Lang'-button sends the Shift & Space-command.

 

Replacing +Space with Shift & Space still isn't working though. But

Shift & Space::
KeyWait, Shift
KeyWait, Space
Send {LWin down}
Send {LWin up}
return

Works fine but it won't let me do any WIN-key combinations, just pressing the WIN-key. Removing Send {LWin up} lets me do key WIN-combinations but results in that the WIN-key is always pressed and that I can't use my keyboard since every time I press a character-key it results in a WIN-key combination.



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

Do you understand the purpose of {LWin down} and {LWin up}?

 

As soon as you send {LWin up}, it's of course going to release the LWin key. If the LWin key is not pressed, well, it's kind of hard to make a key combination.

 

Because this is a bluetooth keyboard, it sounds like your keyboard is taking the liberty to send down and up keystrokes together so that it doesn't result in your computer thinking that you are holding down a key when your battery dies. The alternative would be to continually send the key values to the computer, but that might wear down on battery quite fast.

 

Overall, this is a limitation of the bluetooth keyboard it sounds like. Using GetKeyState or KeyWait doesn't quite work.

 

So instead, let's use this simple approach:

 

+Space:: ; if you want Shift & Space, that's fine. But AFAIK that might lock up the Shift key with the way AHK interprets things combination hotkeys.
Send {LWin down}
Sleep 600
Send {LWin up}
return

 

Adjust the Sleep time to something that's comfortable for you. This won't be ideal for all purposes, but it can get the job done using shortcuts like #d.



manticore
  • Members
  • 6 posts
  • Last active: Feb 09 2015 10:31 PM
  • Joined: 08 Feb 2015

accidentialy double posted



manticore
  • Members
  • 6 posts
  • Last active: Feb 09 2015 10:31 PM
  • Joined: 08 Feb 2015

while looking trough the Forum i noticed ur Problem isnt so far off of the one i just resolved.

~Shift & Space::
while (GetKeyState("Shift & Space","P")
{
Send LWin Down
}
Loop
{
press := Getkeystate("Shift & Space","P")
If press = 0
{
Send {LWin Up}
break
}
}
 

im not shure if Shift & Space works as i worked with only one key and the whole script is just put together out of other Solutions i googled myself XD