[Function] GetKeyState isn't working! Please, help!

Get help with using AutoHotkey and its commands and hotkeys
Rastahammer
Posts: 23
Joined: 17 Dec 2017, 13:09

Re: [Function] GetKeyState isn't working! Please, help!

27 Dec 2017, 12:40

Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:17, edited 2 times in total.
Rastahammer
Posts: 23
Joined: 17 Dec 2017, 13:09

Re: [Function] GetKeyState isn't working! Please, help!

18 Jan 2018, 12:50

Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:17, edited 2 times in total.
Rastahammer
Posts: 23
Joined: 17 Dec 2017, 13:09

Re: [Function] GetKeyState isn't working! Please, help!

19 Jan 2018, 15:19

Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:18, edited 1 time in total.
Rastahammer
Posts: 23
Joined: 17 Dec 2017, 13:09

Re: [Function] GetKeyState isn't working! Please, help!

20 Jan 2018, 23:23

Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:18, edited 1 time in total.
User avatar
joedf
Posts: 6240
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: [Function] GetKeyState isn't working! Please, help!

21 Jan 2018, 00:20

why not use "D" instead of "P"?
Rastahammer
Posts: 23
Joined: 17 Dec 2017, 13:09

Re: [Function] GetKeyState isn't working! Please, help!

22 Jan 2018, 10:30

Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:18, edited 1 time in total.
User avatar
joedf
Posts: 6240
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: [Function] GetKeyState isn't working! Please, help!

22 Jan 2018, 11:34

Whats the point of 3ms wait times??
DllCall("Sleep","UInt",3) instead of sleep, 3... I imagine for shorter wait times.... is 10ms not enough?
Rastahammer
Posts: 23
Joined: 17 Dec 2017, 13:09

Re: [Function] GetKeyState isn't working! Please, help!

22 Jan 2018, 13:33

Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:18, edited 2 times in total.
User avatar
joedf
Posts: 6240
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: [Function] GetKeyState isn't working! Please, help!

22 Jan 2018, 22:01

Weird.... I tried the example, without the scroll-lock and everything works fine... :think:
Are you sure you're not running something else that might interfere?
Rastahammer
Posts: 23
Joined: 17 Dec 2017, 13:09

Re: [Function] GetKeyState isn't working! Please, help!

23 Jan 2018, 09:48

Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:18, edited 2 times in total.
Rastahammer
Posts: 23
Joined: 17 Dec 2017, 13:09

Re: [Function] GetKeyState isn't working! Please, help!

23 Jan 2018, 10:01

Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:18, edited 2 times in total.
Helgef
Posts: 2897
Joined: 17 Jul 2016, 01:02
Contact:

Re: [Function] GetKeyState isn't working! Please, help!

23 Jan 2018, 13:05

Maybe try settimer,

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



cheers.
Rastahammer
Posts: 23
Joined: 17 Dec 2017, 13:09

Re: [Function] GetKeyState isn't working! Please, help!

24 Jan 2018, 08:11

Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:19, edited 1 time in total.
Rastahammer
Posts: 23
Joined: 17 Dec 2017, 13:09

Re: [Function] GetKeyState isn't working! Please, help!

24 Jan 2018, 16:15

Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:19, edited 2 times in total.
User avatar
joedf
Posts: 6240
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: [Function] GetKeyState isn't working! Please, help!

24 Jan 2018, 22:37

Should there be a % in front of duration
In your sleep?
Helgef
Posts: 2897
Joined: 17 Jul 2016, 01:02
Contact:

Re: [Function] GetKeyState isn't working! Please, help!

25 Jan 2018, 04:35

Can you make it faster?

You can try this.

Code: [Select all] [Download] GeSHi © Codebox Plus

pressKeys(keys, duration){
loop 5 {
for k, key in keys
sendinput % "{" key " down}"
dllcall("Sleep", "uint", duration)
for k, key in keys
sendinput % "{" key " up}"
}
}

Faster doesn't necessarily mean better.

joedf wrote:Should there be a % in front of duration In your sleep?

Sleep's parameter can be an expression, hence, sleep var is fine.
DllCall("Sleep","UInt",3) instead of sleep, 3.

Using dllcall("Sleep") can be more accurate. AHK's sleep does something more fancy than just calling Sleep() for the full duration. As a consequence, we can start new threads, via messages, timers and hotkeys when a thread is sleeping. Example,

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


The dllcall("Sleep") freezes the script, it is probably ok for short sleeps.

Cheers,
Rastahammer
Posts: 23
Joined: 17 Dec 2017, 13:09

Re: [Function] GetKeyState isn't working! Please, help!

25 Jan 2018, 10:50

Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:19, edited 2 times in total.
User avatar
Nextron
Posts: 1122
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win7 x64 AHK: Unicode x32

Re: [Function] GetKeyState isn't working! Please, help!

25 Jan 2018, 12:50

Do you also get in an infinite loop if you remove all the lines above the hotkey? You could try to add a line to the hotkey, displaying a tooltip with A_Now and the result of GetKeyState, to see if it keeps updating the time after you release the key, or that there's just still a lot of keys coming out of the buffer, even though they shouldn't.
The more I know:
The more I know,
I know nothing.
Helgef
Posts: 2897
Joined: 17 Jul 2016, 01:02
Contact:

Re: [Function] GetKeyState isn't working! Please, help!

25 Jan 2018, 13:20

But even using loop 1

The higher loop x, the faster it will be.

Another version,

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Rastahammer
Posts: 23
Joined: 17 Dec 2017, 13:09

Re: [Function] GetKeyState isn't working! Please, help!

25 Jan 2018, 13:47

Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:19, edited 2 times in total.

Return to “Ask For Help”

Who is online

Users browsing this forum: Exaskryz, TAC109 and 39 guests