[Function] GetKeyState isn't working! Please, help!
-
- Posts: 22
- Joined: 17 Dec 2017, 13:09
Re: [Function] GetKeyState isn't working! Please, help!
Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:17, edited 2 times in total.
-
- Posts: 22
- Joined: 17 Dec 2017, 13:09
Re: [Function] GetKeyState isn't working! Please, help!
Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:17, edited 2 times in total.
-
- Posts: 22
- Joined: 17 Dec 2017, 13:09
Re: [Function] GetKeyState isn't working! Please, help!
Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:18, edited 1 time in total.
-
- Posts: 22
- Joined: 17 Dec 2017, 13:09
Re: [Function] GetKeyState isn't working! Please, help!
Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:18, edited 1 time in total.
Re: [Function] GetKeyState isn't working! Please, help!
why not use "D" instead of "P"?
![Image](https://joedf.github.io/assets/img/user/ahkneedhelp.gif)
![Image](https://joedf.github.io/assets/img/user/ahkfoundation.gif)
![Image](https://joedf.github.io/assets/img/user/mitlicense.gif)
![Image](https://joedf.github.io/assets/img/user/+greenpeace.gif)
![Image](https://joedf.github.io/assets/img/user/githubahkscript.gif)
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
-
- Posts: 22
- Joined: 17 Dec 2017, 13:09
Re: [Function] GetKeyState isn't working! Please, help!
Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:18, edited 1 time in total.
Re: [Function] GetKeyState isn't working! Please, help!
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?
DllCall("Sleep","UInt",3) instead of sleep, 3... I imagine for shorter wait times.... is 10ms not enough?
![Image](https://joedf.github.io/assets/img/user/ahkneedhelp.gif)
![Image](https://joedf.github.io/assets/img/user/ahkfoundation.gif)
![Image](https://joedf.github.io/assets/img/user/mitlicense.gif)
![Image](https://joedf.github.io/assets/img/user/+greenpeace.gif)
![Image](https://joedf.github.io/assets/img/user/githubahkscript.gif)
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
-
- Posts: 22
- Joined: 17 Dec 2017, 13:09
Re: [Function] GetKeyState isn't working! Please, help!
Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:18, edited 2 times in total.
Re: [Function] GetKeyState isn't working! Please, help!
Weird.... I tried the example, without the scroll-lock and everything works fine... ![Thinking :think:](./images/smilies/icon_think.gif)
Are you sure you're not running something else that might interfere?
![Thinking :think:](./images/smilies/icon_think.gif)
Are you sure you're not running something else that might interfere?
![Image](https://joedf.github.io/assets/img/user/ahkneedhelp.gif)
![Image](https://joedf.github.io/assets/img/user/ahkfoundation.gif)
![Image](https://joedf.github.io/assets/img/user/mitlicense.gif)
![Image](https://joedf.github.io/assets/img/user/+greenpeace.gif)
![Image](https://joedf.github.io/assets/img/user/githubahkscript.gif)
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
-
- Posts: 22
- Joined: 17 Dec 2017, 13:09
Re: [Function] GetKeyState isn't working! Please, help!
Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:18, edited 2 times in total.
-
- Posts: 22
- Joined: 17 Dec 2017, 13:09
Re: [Function] GetKeyState isn't working! Please, help!
Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:18, edited 2 times in total.
Re: [Function] GetKeyState isn't working! Please, help!
Maybe try settimer,
cheers.
Code: Select all
timerFn := func("pressKeys").bind([7,8,9], 4)
1::settimer, % timerFn, 0
1 up::settimer, % timerFn, off
pressKeys(keys, duration){
for k, key in keys
sendinput % "{" key " down}"
sleep duration
for k, key in keys
sendinput % "{" key " up}"
}
esc::exitapp
-
- Posts: 22
- Joined: 17 Dec 2017, 13:09
Re: [Function] GetKeyState isn't working! Please, help!
Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:19, edited 1 time in total.
-
- Posts: 22
- Joined: 17 Dec 2017, 13:09
Re: [Function] GetKeyState isn't working! Please, help!
Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:19, edited 2 times in total.
Re: [Function] GetKeyState isn't working! Please, help!
Should there be a % in front of duration
In your sleep?
In your sleep?
![Image](https://joedf.github.io/assets/img/user/ahkneedhelp.gif)
![Image](https://joedf.github.io/assets/img/user/ahkfoundation.gif)
![Image](https://joedf.github.io/assets/img/user/mitlicense.gif)
![Image](https://joedf.github.io/assets/img/user/+greenpeace.gif)
![Image](https://joedf.github.io/assets/img/user/githubahkscript.gif)
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: [Function] GetKeyState isn't working! Please, help!
You can try this.Can you make it faster?
Code: Select all
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}"
}
}
Sleep's parameter can be an expression, hence, sleep var is fine.joedf wrote:Should there be a % in front of duration In your sleep?
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,DllCall("Sleep","UInt",3) instead of sleep, 3.
Code: Select all
ahkSleep := true
settimer a, -200
if ahkSleep
sleep 4000
else
dllcall("Sleep", "uint", 4000)
msgbox % "end of script"
return
a:
msgbox % a_thislabel
return
Cheers,
-
- Posts: 22
- Joined: 17 Dec 2017, 13:09
Re: [Function] GetKeyState isn't working! Please, help!
Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:19, edited 2 times in total.
Re: [Function] GetKeyState isn't working! Please, help!
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.
Re: [Function] GetKeyState isn't working! Please, help!
The higher loop x, the faster it will be.But even using loop 1
Another version,
Code: Select all
#if GetKeyState("ScrollLock", "T")
1::
do := true
while do
pressKeys([7,8,9], 1)
return
#if do
1 up::do := false
pressKeys(keys, duration){
for k, key in keys
sendinput % "{" key " down}"
dllcall("Sleep", "uint", duration)
for k, key in keys
sendinput % "{" key " up}"
}
-
- Posts: 22
- Joined: 17 Dec 2017, 13:09
Re: [Function] GetKeyState isn't working! Please, help!
Solved.
Last edited by Rastahammer on 25 Jan 2018, 17:19, edited 2 times in total.