_IsPressed acting strange

06/25/2015 09:41 LiveLong23#1
Hi

I have this piece of script, but _IsPressed dont work normal or its problem in game, problem is when i press and hold SHIFT it send keys, but after send every key its like i released SHIFT but i still hold it

Here is record on video im holding SHIFT all time [Only registered and activated users can see links. Click Here To Register...]

Edit : i made it works its seems that its problem with game and shift key, now my other problem how i made it to toogle pause / run with ^y key and its seems like its in endless loop i pause it with F3 but i cant turn off on X button :(

Code:
#RequireAdmin
#include <Misc.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $run = False
Local $hDLL = DllOpen("user32.dll")

HotKeySet("^y", "_go")
HotKeySet("{F3}", "_pause")
HotKeySet("{ESC}", "_end")

GUICreate("Form1", 275, 155, -1, -1)
GUICtrlCreateGroup(" Bar 1 ", 8, 8, 257, 65)
$bar1keys = GUICtrlCreateInput("", 24, 36, 225, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup(" Bar 2 ", 9, 79, 257, 65)
$bar2keys = GUICtrlCreateInput("", 25, 107, 225, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

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

	EndSwitch
WEnd

Func _go()
	$run = True
While True

	If $run Then
		If _IsPressed ("12", $hDLL) Then
				Send("{SHIFTDOWN}")
				Sleep(10)
					While _IsPressed ("12", $hDLL)
						Send(GUICtrlRead($bar2keys))
						Sleep(100)
					WEnd
				Send("{SHIFTUP}")
				Sleep(10)
		Else
			Send(GUICtrlRead($bar1keys))
			Sleep(100)
		EndIf

	EndIf

WEnd

DllClose($hDLL) ; close dll

EndFunc

Func _end()
	Exit
EndFunc

Func _pause()
	$run = False
EndFunc
06/25/2015 12:59 alpines#2
If you want to turn it off with the X Button switch to OnEventMode and register an exit function.
Code:
GUISetOnEvent(-3, "ExitFunction")

Func ExitFunction()
	;Pause or Exit whatever
EndFunc
06/25/2015 19:05 LiveLong23#3
And what about endless loop or sending keys ?
And it send me key like plain text but i need it to send key by key with sleep between.