GetKeyState functionality not working Version 1.1.30.03

Get help with using AutoHotkey and its commands and hotkeys
GusNoFear-
Posts: 2
Joined: 23 Sep 2019, 23:13

GetKeyState functionality not working Version 1.1.30.03

28 Sep 2019, 18:58

I've spend so many hours today finding out how getkeystate() works. I've finished writing the following piece of code to simulate Ctrl + Shift + {right or left}.

Code: Select all

#If GetKeyState("Alt", "P")
~Capslock & [::
    SendInput, +^{Left}
    Sleep, 50
Return

~Capslock & ]::
    SendInput, +^{Right}
    Sleep, 50
Return
#If
The goal of this script would be to highlight the upcoming or preceding words in a text editor. My code highlights the upcoming words but not the preceding words. Any helpful tips are greatly appreciated.
User avatar
jeeswg
Posts: 6828
Joined: 19 Dec 2016, 01:58
Location: UK

Re: GetKeyState functionality not working Version 1.1.30.03

28 Sep 2019, 19:19

This worked for me:

Code: Select all

#If GetKeyState("Alt", "P") && GetKeyState("CapsLock", "P")
;~Capslock & [::
*[::
    SendInput, +^{Left}
    Sleep, 50
Return

;~Capslock & ]::
*]::
    SendInput, +^{Right}
    Sleep, 50
Return
#If
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
submeg
Posts: 23
Joined: 14 Apr 2017, 20:39
GitHub: submeg

Re: GetKeyState functionality not working Version 1.1.30.03

28 Sep 2019, 19:21

I just grabbed your code and added it to a blank ahk file; running it by itself, the code works as you explained.

Do you have any other codes that could be conflicting?
GusNoFear-
Posts: 2
Joined: 23 Sep 2019, 23:13

Re: GetKeyState functionality not working Version 1.1.30.03

28 Sep 2019, 19:29

This code doesn't do anything on my end. I think it's something with my computer because the getkeystate doesn't always work. I've tried it in other keys.
lexikos
Posts: 6653
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: GetKeyState functionality not working Version 1.1.30.03

28 Sep 2019, 19:52

You should update to v1.1.31.00. I don't think I've fixed anything specifically relating to your issue, but there were a bunch of bug fixes relating to hotkeys.

Return to “Ask For Help”

Who is online

Users browsing this forum: flyingDman, Google [Bot], grimboto, Gully, hlywine, kyuuuri, TheMainEvent and 67 guests