_IsPressed() Help with keys

03/07/2014 13:42 mlukac89#1
I have this piece of code, so when i press CTRL is start to write in console but i cant stop it when i press CTRL again, i tried to change key for stop but dont works too it loop all time.

And can _IsPressed() keys can be custom made like CTRL a, CTRL v, CTRL s, CTRL v ?

Is they be counted like this 11 CTRL key + 41 A key = 52 (ctrl a) ? But i see in help file 52 R key

Code:
#include <Misc.au3>

Global $hDLL = DllOpen("user32.dll")

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit

	EndSwitch

		If _IsPressed(11, $hDLL) Then
			Do
				ConsoleWrite("test" & @CRLF)
				Sleep(800)
			Until _IsPressed(11, $hDLL)
		EndIf

WEnd

DllClose($hDLL)
03/07/2014 15:06 alpines#2
It will loop over and over again because you have some logic issues in there.
If _IsPressed(11, $hDLL) Then <-- here you jump into the if if your CTRL key is pressed.
So far so good but you only go out of the Do Until loop if you hit the CTRL key again.
The logic is pretty ok but the mistake you made is that these statements don't take a split of a ms to parse. You need to make a trigger for that I think. And to these combined codes you can use multiple If Statements.
Code:
If _IsPressed(11, $hDLL) and _IsPressed(1, $hDLL) Then
CTRL + LMOUSE
03/07/2014 18:05 mlukac89#3
Can't find good solution but this code need to be here i dont want to make func for it.

This example from help file is good but it works only while you hold key, but i need when i press key to run code untill i press it again. I can do it with new function and HotkeySet but then more code :P