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

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

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

25 Jan 2018, 15:46

Hello.
So many trys and no solution? Okay, here is my suggestion. I just have modified the first post, without knowing the requirements.

Code: Select all

$1::
{
	if (GetKeyState("ScrollLock", "T") && GetKeyState("1", "P"))
	{
		SendInput {7 Down}{8 Down}{9 Down}
		DllCall("Sleep","UInt",4)
		SendInput {7 Up}{8 Up}{9 Up}
		DllCall("Sleep","UInt",4)
	}
}
Instead of if you can even use while too.
I don't know why you use

Code: Select all

SendInput {7 Down}{8 Down}{9 Down}
instead of

Code: Select all

SendInput 789
So if it fails, it will be your fail. :mrgreen: :mrgreen:
Einfach nur ein toller Typ. :mrgreen:
geekgarage
Posts: 22
Joined: 17 Dec 2017, 11:03
Contact:

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

25 Jan 2018, 16:06

divanebaba wrote:Hello.
So many trys and no solution? Okay, here is my suggestion. I just have modified the first post, without knowing the requirements.

Code: Select all

$1::
{
	if (GetKeyState("ScrollLock", "T") && GetKeyState("1", "P"))
	{
		SendInput {7 Down}{8 Down}{9 Down}
		DllCall("Sleep","UInt",4)
		SendInput {7 Up}{8 Up}{9 Up}
		DllCall("Sleep","UInt",4)
	}
}
Instead of if you can even use while too.
I don't know why you use

Code: Select all

SendInput {7 Down}{8 Down}{9 Down}
instead of

Code: Select all

SendInput 789
So if it fails, it will be your fail. :mrgreen: :mrgreen:
Some of my first script versions trying to help the user is using while but it seems like i've made the script too fast for his computer to handle and it's causing the issue. too many tweaks :)
geekgarage
Posts: 22
Joined: 17 Dec 2017, 11:03
Contact:

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

25 Jan 2018, 16:11

From all the lines above the hotkeys (those are kind of important to get it running really fast)
Only these I can see would cause any issue, but you asked for it to be fast ;)

#HotkeyInterval 99000000
SetBatchLines, -1
SetKeyDelay, -1, -1 (most likely this)

Having these in a script is a must
#Persistent ; does not close the script in case code gets to EOF
#SingleInstance force ; forcing only one instance of the scrip so you don't get fe'd up errors from running two or more instances
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.

This one
Process, Priority, , H is just simply the priority of the process to use the CPU (do not ever in any form set this to realtime as i've experienced that i can fuck shit up really fast

The rest is just tweaks. but they could ofc. be messing your system up because it's not fast enough to handle all the instructions.

Rastahammer wrote:Sometimes it gets stuck in the loop after I release the key and continuously sends the hotkeys until I press the key 1 again or reload the script.
Now to another note, and it is pissing me off a lot! I had been away for some time and just now had a chance to jump on and see if there was any response, so i tried to read up on what we had done and all, and then i find NINE of your fuc**** comments all changed to the obnoxious red bold text stating that you can't get out of the loop. STOP THAT SH** RIGHT NOW! You are removing valuable information that others might be able to use in some form. I didn't spend time JUST to help you. I try to help you... and others down the road, and you removing that information is making that help more or less useless because they have NO chance to know what I or others was responding to. Listen, we get it when you said it the first time, but you can't just go act like an obnoxious spoiled brat who's not getting the help they want. Be patient or experienced users will stop help you simply because the way you act, you are the one with the problem... not us! Act like it!
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

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

25 Jan 2018, 16:18

Hmmm.
This gives same results:

Code: Select all

$1::
{
	if GetKeyState("ScrollLock", "T")
	{
		SendInput {7 Down}{8 Down}{9 Down}
		DllCall("Sleep","UInt",4)
		SendInput {7 Up}{8 Up}{9 Up}
		DllCall("Sleep","UInt",4)
	}
}
Checking the state of 1 isn't necessary. If 1 is released, the hotkey will not be triggered. A query for state of 1 is in this case not necessary.
geekgarage wrote:... Now to another note, and it is pissing me off a lot! ...
I've seen his red postings too. I gave support to end this thread. :D :D
Einfach nur ein toller Typ. :mrgreen:
geekgarage
Posts: 22
Joined: 17 Dec 2017, 11:03
Contact:

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

25 Jan 2018, 16:33

divanebaba wrote:Hmmm.
This gives same results:

Code: Select all

$1::
{
	if GetKeyState("ScrollLock", "T")
	{
		SendInput {7 Down}{8 Down}{9 Down}
		DllCall("Sleep","UInt",4)
		SendInput {7 Up}{8 Up}{9 Up}
		DllCall("Sleep","UInt",4)
	}
}
Checking the state of 1 isn't necessary. If 1 is released, the hotkey will not be triggered. A query for state of 1 is in this case not necessary.
geekgarage wrote:... Now to another note, and it is pissing me off a lot! ...
I've seen his red postings too. I gave support to end this thread. :D :D

No clue who have added the check for 1 lol. it's like yelling the question if you are yelling right now. I think some one thought it was needed looking at my "while 1 is pressed"-loop at the bottom of page 1 in this thread, and not understanding when to use a test for it :) But hey we all started some where right :D
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

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

25 Jan 2018, 16:39

geekgarage wrote:... No clue who have added the check for 1 lol. ...
Making mistakes is human right. :crazy: :crazy:
The query for 1 was in Rastahammer's original post. My intention was to combine the two querys into one without overloading my head. :lol: :lol:
Einfach nur ein toller Typ. :mrgreen:
Rastahammer
Posts: 22
Joined: 17 Dec 2017, 13:09

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

25 Jan 2018, 17:12

In honor of @geekgarage... Solved.

@Joedf, @Helgef and @Nextron. Thank you very much!
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

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

25 Jan 2018, 17:33

This thread is terrible.
Rastahammer, you have delete your question and even not marked any solution.
This is not meaning of this forum. Goal is, if someone has same issue, he must be able to find a solution here.
Now, if somebody read this thread, he will only waste his time.
Perfect job :trollface: :trollface:
Last edited by divanebaba on 25 Jan 2018, 17:38, edited 1 time in total.
Einfach nur ein toller Typ. :mrgreen:
geekgarage
Posts: 22
Joined: 17 Dec 2017, 11:03
Contact:

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

25 Jan 2018, 17:38

divanebaba wrote:This thread is terrible.
Rastahammer, you have delete your question and even not marked any solution.
This is not meaning of this forum. Goal is, if someone has same issue, he must be able to find a solution here.
It's not the thread that is the issue.. it's the user so i encourage anyone who read this to report him so he can get banned. This behaviour should not be welcomed or condoned.
geekgarage
Posts: 22
Joined: 17 Dec 2017, 11:03
Contact:

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

25 Jan 2018, 17:38

Rastahammer wrote:In honor of @geekgarage... Solved.

@Joedf, @Helgef and @Nextron. Thank you very much!
reported... in honor of you :)
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

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

25 Jan 2018, 17:43

geekgarage wrote:... it's the user so i encourage anyone who read this to report him so he can get banned. This behaviour should not be welcomed or condoned.
He is apparently new here.
divanebaba wrote:Making mistakes is human right. :crazy: :crazy:
Main thing is, he does not repeat it again and again.
Einfach nur ein toller Typ. :mrgreen:
geekgarage
Posts: 22
Joined: 17 Dec 2017, 11:03
Contact:

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

25 Jan 2018, 17:51

divanebaba wrote:
geekgarage wrote:... it's the user so i encourage anyone who read this to report him so he can get banned. This behaviour should not be welcomed or condoned.
He is apparently new here.
divanebaba wrote:Making mistakes is human right. :crazy: :crazy:
Main thing is, he does not repeat it again and again.
I'm open for making mistakes, but after he is told not to do it, as a common courtesy to other users and was explained why, he just went full retard and changed all his comments to "solved" just to provoke and nothing else. The first time was making a mistake, but after he is told why not to do it he kept going, that is being an asshole, not making a mistake. Only reason he did this is because he got his problem solved, and now he couldn't care less about any one else, he is what i call forum cancer and he should be removed. He discourage any one who is skilled enough to help, from helping because no one wants to waste their time on a person like that.
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

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

25 Jan 2018, 17:58

I think he just wanted to clear his crap and messed it up. :mrgreen: :mrgreen:
Einfach nur ein toller Typ. :mrgreen:
geekgarage
Posts: 22
Joined: 17 Dec 2017, 11:03
Contact:

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

25 Jan 2018, 18:02

divanebaba wrote:I think he just wanted to clear his crap and messed it up. :mrgreen: :mrgreen:
Lol that is one big fuckup xD

But joking aside, he should be reported for this behavior. It is forum cancer, nothing less :)
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

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

25 Jan 2018, 19:24

I still had the unedited page open, so I restored some of the content. Good that the issue is solved, but I did issue a warning to Rastahammer that this undesirable behavior or clearing his posts is against forum rules.
User avatar
joedf
Posts: 8960
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

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

25 Jan 2018, 22:45

@Nextron +1
Maintaining integrity of the forum is crucial!
Image Image Image Image Image
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]
GreatGazoo
Posts: 69
Joined: 28 Dec 2017, 02:53

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

26 Jan 2018, 01:06

I don't know if anyone's ping is good enough to register that many actions per second, it's probably stuck because his cpu is trying to catch up and has Queued thousands of keystrokes in advance

I've noticed that when I made a rapid clicker send like 2000 clicks per second, after I turned it off it was still clicking for about 2 minutes after

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, Joey5, ShatterCoder, Xaucy and 194 guests