Checkboxen mit Hotkeys anwählen

06/27/2013 19:50 AlvinX2#1
Moinsen. Ich sitz mal wieder an nem wahrscheinlich banalen Problem, find aber die Lösung nicht. Ich will die Hotkeys F1-F6 mit funktionen belegen, in denen dann Checkboxen angehakt und abgehakt werden. Hier ein Beispiel, denn den ganzen Code kann ich bzw will ich nicht posten da er 600 Zeilen lang ist. Post kommt wenn dann auf anfrage.

PHP Code:
Func _HKoff()
    
GUICtrlSetState($Checkbox1$GUI_UNCHECKED)
    
GUICtrlSetState($Checkbox2$GUI_UNCHECKED)
    
GUICtrlSetState($Checkbox3$GUI_UNCHECKED)
    
GUICtrlSetState($Checkbox4$GUI_UNCHECKED)
    
GUICtrlSetState($Checkbox5$GUI_UNCHECKED)
    
GUICtrlSetData($l1," ")
    
GUICtrlSetData($l2," ")
    
GUICtrlSetData($l3," ")
    
GUICtrlSetData($l4," ")
    
GUICtrlSetData($l5," ")
EndFunc

HotKeySet
("{F1}",_HK1())
HotKeySet("{F2}",_HK2())
HotKeySet("{F3}",_HK3())
HotKeySet("{F4}",_HK4())
HotKeySet("{F5}",_HK5())
HotKeySet("{F6}",_HKoff()) 
Ich sitz nun mehr seit 4 Stunden dran und hab halb Google durchforstet, komme aber auf keinen grünen Zweig.
06/27/2013 20:14 butter123#2
du brauchst für jeden hotkey eine funktion die _HK1(), _HK2() ... heißen. und in jeder einzelnen wird nur eine checkbox angesprochen. so wird nur was bei F6 passieren und da dann alle.
06/27/2013 20:17 AlvinX2#3
Quote:
Originally Posted by butter123 View Post
du brauchst für jeden hotkey eine funktion die _HK1(), _HK2() ... heißen. und in jeder einzelnen wird nur eine checkbox angesprochen. so wird nur was bei F6 passieren und da dann alle.
Das weiß ich, hab ich auch so :) Aber es geht nicht.
06/27/2013 22:09 butter123#4
PHP Code:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 GUICreate("Form1"355202192124)
$Checkbox1 GUICtrlCreateCheckbox("Checkbox1"56329717)
GUICtrlSetState(-10)
$Checkbox2 GUICtrlCreateCheckbox("Checkbox2"64889717)
GUICtrlSetState(-10)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

HotKeySet("a","_togglea")
HotKeySet("s","_toggles")

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

    EndSwitch
WEnd


Func _togglea
()
    If 
GUICtrlRead($Checkbox1)=$GUI_CHECKED Then
        GUICtrlSetState
($Checkbox1$GUI_UNCHECKED)
    Else
        
GUICtrlSetState($Checkbox1$GUI_CHECKED)
    EndIf
EndFunc


Func _toggles
()
    If 
GUICtrlRead($Checkbox2)=$GUI_CHECKED Then
        GUICtrlSetState
($Checkbox2$GUI_UNCHECKED)
    Else
        
GUICtrlSetState($Checkbox2$GUI_CHECKED)
    EndIf
EndFunc 
06/28/2013 01:29 lolkop#5
das ganze ist auch schön über GetAsyncKeyState lösbar...

hier mal ein beispiel:
Code:
Dim $p[255],$s[5]=[0,4,0,0,1],$cb[6],$gui=GUICreate('GUI', 150, 140, Default, Default, 0x10C80000)
For $i=0 To 5
	$cb[$i]=GUICtrlCreateCheckbox('Checkbox '&$i+1, 10, 10+$i*20, 130, 20)
Next

While True
	Switch GUIGetMsg()
		Case -3
			Exit
	EndSwitch
	For $i=0 To 5
		If _IsPressed(0x70+$i) Then
			If Not $p[0x70+$i] Then GUICtrlSetState($cb[$i],$s[GUICtrlRead($cb[$i])])
			$p[0x70+$i]=True
		Else
			$p[0x70+$i]=False
		EndIf
	Next
WEnd

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