Page 1 of 3
Order of pressing modifier keys affects the result
Posted: 31 Dec 2018, 09:43
by victorv
I am using this code to make Win + Right act like End. And Shift + Win + Right to act as Shift + End:
Code: Select all
LWin & Right::
; ss := GetKeyState("Shift")
; ToolTip %ss%
if GetKeyState("Shift") = 1
Send +{End}
Else
Send {End}
Return
If I press first Shift then Win then Right, the cursor moves to the end of line selecting the text.
But if I first press Win and then Shift then Right -- the text is not selected.
Is this the expected behaviour?
Re: Order of pressing modifier keys affects the result
Posted: 10 Jan 2019, 12:53
by victorv
Can anyone help with this?
Re: Order of pressing modifier keys affects the result
Posted: 10 Jan 2019, 13:12
by sinkfaze
Your hotkey works fine for me when I test it on text in the text box on this website and in Notepad. It also works when I change the keypress order as you describe. I suspect that this is not an AHK issue.
My hotkey code:
Code: Select all
LWin & Right::
if GetKeyState("SHIFT")
Send +{END}
else Send {END}
return
Re: Order of pressing modifier keys affects the result
Posted: 10 Jan 2019, 13:31
by IMEime
.
Re: Order of pressing modifier keys affects the result
Posted: 11 Jan 2019, 01:45
by victorv
Here is my full script:
Code: Select all
LWin & Left::
GetKeyState, state, Shift
If state = D
Send +{Home}
Else Send {Home}
Return
LWin & Right::
if GetKeyState("Shift") = 1
Send +{End}
Else
Send {End}
Return
LWin & Up::
if GetKeyState("Shift") = 1
Send +{PgUp}
Else
Send {PgUp}
Return
LWin & Down::
if GetKeyState("Shift") = 1
Send +{PgDn}
Else
Send {PgDn}
Return
LShift & BackSpace::
Send {Del}
return
LWin up::
return
LWin::
return
Shift & LWin::
return
LWin & Shift::
return
Alt & Space::
Send #{Space}
return
Re: Order of pressing modifier keys affects the result
Posted: 11 Jan 2019, 02:30
by IMEime
.
Re: Order of pressing modifier keys affects the result
Posted: 11 Jan 2019, 03:25
by rommmcek
For Get State try using: GetKeyState("Shift", "P"). Works for me!
Re: Order of pressing modifier keys affects the result
Posted: 11 Jan 2019, 04:56
by victorv
rommmcek wrote: ↑11 Jan 2019, 03:25
For Get State try using:
GetKeyState("Shift", "P"). Works for me!
This helps, but then the default Win behaviour is triggered -- Start menu is opened. Can this be avoided?
Re: Order of pressing modifier keys affects the result
Posted: 11 Jan 2019, 09:07
by sinkfaze
Exit all of your other running scripts, create a brand new script that contains just this hotkey:
Code: Select all
LWin & Right::
if GetKeyState("SHIFT")
Send +{END}
else Send {END}
return
Run just the new script and try to execute the hotkey. What happens?
Re: Order of pressing modifier keys affects the result
Posted: 11 Jan 2019, 10:22
by rommmcek
To prevent Start Menu I use Keywait, LWin before return. Listen to other members too!
Re: Order of pressing modifier keys affects the result
Posted: 12 Jan 2019, 12:05
by victorv
sinkfaze wrote: ↑11 Jan 2019, 09:07
Exit all of your other running scripts, create a brand new script that contains just this hotkey:
Code: Select all
LWin & Right::
if GetKeyState("SHIFT")
Send +{END}
else Send {END}
return
Run just the new script and try to execute the hotkey. What happens?
In both cases (first pressing Shift, then Win and first pressing Win then Shift) it works, except that the Start menu is opened after that.
Re: Order of pressing modifier keys affects the result
Posted: 12 Jan 2019, 12:09
by victorv
rommmcek wrote: ↑11 Jan 2019, 10:22
To prevent Start Menu I use
Keywait, LWin before
return. Listen to other members too!
Tried with only this code in the whole script:
Code: Select all
LWin & Right::
if GetKeyState("SHIFT")
Send +{END}
else Send {END}
Keywait, LWin
return
Didn't help. When I press just Win and Right it goes to the end of the line, no matter if Keywait command is present. When I use Shift -- the Start menu is opened in both cases.
Re: Order of pressing modifier keys affects the result
Posted: 12 Jan 2019, 12:53
by rommmcek
Two things:
- you forgot to include "physical" parameter.
- did you close all other AutoHotkey scripts?
P.s:: For me it works w/o problems.
Re: Order of pressing modifier keys affects the result
Posted: 12 Jan 2019, 15:31
by victorv
rommmcek wrote: ↑12 Jan 2019, 12:53
Two things:
- you forgot to include "physical" parameter.
- did you close all other AutoHotkey scripts?
P.s:: For me it works w/o problems.
"P" makes not difference for this simple script.
I have only one file. Editing it and reloading in SciTE4AutoHotkey.
I have no idea why it works for you. AutoHotkey version? Windows version?
I am using the latest Windows 10 with AutoHotkey v1.1.30.01
Code: Select all
001: Return (4.72)
002: if GetKeyState("SHIFT", "P")
003: Send,+{END} (0.02)
005: KeyWait,LWin (0.28)
006: Return (2.95)
002: if GetKeyState("SHIFT", "P")
003: Send,+{END} (0.03)
005: KeyWait,LWin (0.19)
006: Return (3.20)
002: if GetKeyState("SHIFT", "P")
003: Send,+{END} (0.03)
005: KeyWait,LWin (0.22)
006: Return (3.36)
002: if GetKeyState("SHIFT", "P")
003: Send,+{END} (0.03)
005: KeyWait,LWin (0.45)
006: Return (2.31)
002: if GetKeyState("SHIFT", "P")
003: Send,+{END} (0.02)
005: KeyWait,LWin (0.20)
006: Return (2.75)
002: if GetKeyState("SHIFT", "P")
003: Send,+{END} (0.03)
005: KeyWait,LWin (0.11)
006: Return (22.27)
Re: Order of pressing modifier keys affects the result
Posted: 12 Jan 2019, 16:28
by rommmcek
This is discouraging!
Try (Note first line
#NoEnv):
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
LWin & Right::
;~ #Right::
if GetKeyState("SHIFT", "P")
Send +{END}
else Send {END}
Keywait, LWin
Keywait, Shift
return
Try with
#Right:: too!
If you didn't already, consider restart OS running as less apps as possible.
Run the script from Explorer, Run or Command line. Not from Sci4Ahk via
F5 or
^+F5.
P.s.: My OS Win10 updated Oct 2018 or so, Ahk v1.1.29.01
Re: Order of pressing modifier keys affects the result
Posted: 14 Jan 2019, 11:27
by rommmcek
Try running the script as admin!
Namely I just got feedback it
might do the trick.
Re: Order of pressing modifier keys affects the result
Posted: 15 Jan 2019, 04:22
by victorv
I decided to switch to `Alt + Arrow` instead of using Win key. It works. Will see if any app uses Alt + Arrow for its purposes and it is inconvenient for me.
Thank you for your help!
Re: Order of pressing modifier keys affects the result
Posted: 15 Jan 2019, 04:54
by victorv
I started SciTE4AutoHotkey as administrator then started the script from there. The behaviour is the same.
Re: Order of pressing modifier keys affects the result
Posted: 15 Jan 2019, 06:18
by rommmcek
Beware! Win OS cache does sometimes strange things e.g. running app from memory which content is not necessarily the same as the one on the HD! So for testing while developing, starting the script form command line is very useful!
P.s.: Alt + Arrow in browser and explorer is Back and Forward respectively.
Re: Order of pressing modifier keys affects the result
Posted: 15 Jan 2019, 10:10
by victorv
Yes, it was a bad idea for Alt to be used for this purpose.