ich würde dem user einfach ein fenster geben, in dem er irgend eine taste drücken kann, welche dann als hotkey gespeichert wird.Quote:
Wie genau mache ich das ?
Könntest du ein beispiel machen ?
Bitte...
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,Quote:
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