[Frage] Hotkeyset und Input ?

11/06/2010 23:49 PenGuin :O#16
Quote:
Originally Posted by MagicDave View Post
*.* ehhhmm meinstu du ich poste was ohne dass ich was teste?
Ja, hat man schon des Öfteren gesehen.
11/06/2010 23:51 lolkop#17
Quote:
Originally Posted by ~Flow~ View Post
Wie genau mache ich das ?

Könntest du ein beispiel machen ?
Bitte...
ich würde dem user einfach ein fenster geben, in dem er irgend eine taste drücken kann, welche dann als hotkey gespeichert wird.

zb so:
Code:
Dim $keys_old, $keys_new, $sub=-1, $hotkey=-1
$gui = GUICreate('Gui', 200, 50)
$btn = GUICtrlCreateButton('Register Hotkey', 10, 10, 180, 30)
GUISetState()

While 1
	Switch GUIGetMsg()
		Case -3
			Exit
		Case $btn
			If Not WinExists($sub) Then
				$sub = GUICreate('Press Any Key', 50, 50, -1, -1, 0x10C00000)
				$keys_old = GetKeyboardState()
			EndIf
		Case Else
			If WinExists($sub) Then
				$keys_new = GetKeyboardState()
				For $i=0 To 255
					If $keys_old[$i] <> $keys_new[$i] Then
						$hotkey = $i
						TrayTip('Info', 'Hotkey Registred', 1)
						GUIDelete($sub)
						ExitLoop
					EndIf
				Next
			EndIf
			If _IsPressed($hotkey) Then	MsgBox(0, 'Info', 'Der von dir festgelegte HotKey wurde gedrückt')
	EndSwitch
WEnd

Func _IsPressed($key, $dll = 'user32.dll')
	Local $state = DllCall($dll, 'short', 'GetAsyncKeyState', 'int', $key)
	Return BitAND($state[0], 0x8000) <> 0
EndFunc

Func GetKeyboardState($dll = 'User32.dll')
	Local $state, $array[256], $struct = DllStructCreate('byte[256]')
	$state = DllCall($dll, 'int', 'GetKeyboardState', 'ptr', DllStructGetPtr($struct))
	For $i=1 To 256
		$array[$i-1] = BitAND(DllStructGetData($struct, 1, $i), 0x0F)
	Next
	Return $array
EndFunc
11/07/2010 19:26 ~Flow~#18
Quote:
Originally Posted by lolkop View Post
ich würde dem user einfach ein fenster geben, in dem er irgend eine taste drücken kann, welche dann als hotkey gespeichert wird.

zb so:
Code:
Dim $keys_old, $keys_new, $sub=-1, $hotkey=-1
$gui = GUICreate('Gui', 200, 50)
$btn = GUICtrlCreateButton('Register Hotkey', 10, 10, 180, 30)
GUISetState()

While 1
	Switch GUIGetMsg()
		Case -3
			Exit
		Case $btn
			If Not WinExists($sub) Then
				$sub = GUICreate('Press Any Key', 50, 50, -1, -1, 0x10C00000)
				$keys_old = GetKeyboardState()
			EndIf
		Case Else
			If WinExists($sub) Then
				$keys_new = GetKeyboardState()
				For $i=0 To 255
					If $keys_old[$i] <> $keys_new[$i] Then
						$hotkey = $i
						TrayTip('Info', 'Hotkey Registred', 1)
						GUIDelete($sub)
						ExitLoop
					EndIf
				Next
			EndIf
			If _IsPressed($hotkey) Then	MsgBox(0, 'Info', 'Der von dir festgelegte HotKey wurde gedrückt')
	EndSwitch
WEnd

Func _IsPressed($key, $dll = 'user32.dll')
	Local $state = DllCall($dll, 'short', 'GetAsyncKeyState', 'int', $key)
	Return BitAND($state[0], 0x8000) <> 0
EndFunc

Func GetKeyboardState($dll = 'User32.dll')
	Local $state, $array[256], $struct = DllStructCreate('byte[256]')
	$state = DllCall($dll, 'int', 'GetKeyboardState', 'ptr', DllStructGetPtr($struct))
	For $i=1 To 256
		$array[$i-1] = BitAND(DllStructGetData($struct, 1, $i), 0x0F)
	Next
	Return $array
EndFunc
wie baue ich das alles ein,
das es sich erst öffnet wenn ich auf einen bestimmten button gedrückt habe ?