Wie kann ich die Zahlen vom NUmpad zusammenfassen? Also damit ich nicht 10 Funktionen habe. Ist bisschen unübersichtlich.
mfG
Charlie
Wie kann ich die Zahlen vom NUmpad zusammenfassen? Also damit ich nicht 10 Funktionen habe. Ist bisschen unübersichtlich.
mfG
Charlie
Poste mal bitte deinen SC (Sourcecode)
Da ist:^^
HotKeySet("{/}", "_divi")
HotKeySet("{*}", "_multi")
HotKeySet("{+}", "_addi")
HotKeySet("{-}", "_subt")
HotKeySet("{ENTER}", "_gleich")
HotKeySet("{NUMPAD1}", "_nummer1")
HotKeySet("{NUMPAD2}", "_nummer2")
HotKeySet("{NUMPAD3}", "_nummer3")
HotKeySet("{NUMPAD4}", "_nummer4")
HotKeySet("{NUMPAD5}", "_nummer5")
HotKeySet("{NUMPAD6}", "_nummer6")
HotKeySet("{NUMPAD7}", "_nummer7")
HotKeySet("{NUMPAD8}", "_nummer8")
HotKeySet("{NUMPAD9}", "_nummer9")
HotKeySet("{NUMPAD0}", "_nummer0")
HotKeySet("{NUMPADMULT}", "_multi")
HotKeySet("{NUMPADADD}", "_addi")
HotKeySet("{NUMPADSUB}", "_subt")
HotKeySet("{NUMPADDIV}", "_divi")
HotKeySet("{NUMPADENTER}", "_gleich")
#include <GUIConstants.au3>
[/autoit] [autoit][/autoit] [autoit]#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Taschenrechner", 289, 319, 189, 121)
$Label1 = GUICtrlCreateLabel("", 24, 24, 244, 28)
$Button1 = GUICtrlCreateButton("1", 32, 72, 41, 41, 0)
$Button2 = GUICtrlCreateButton("2", 96, 72, 41, 41, 0)
$Button3 = GUICtrlCreateButton("3", 160, 72, 41, 41, 0)
$Button4 = GUICtrlCreateButton("4", 32, 136, 41, 41, 0)
$Button5 = GUICtrlCreateButton("5", 96, 136, 41, 41, 0)
$Button6 = GUICtrlCreateButton("6", 160, 136, 41, 41, 0)
$Button7 = GUICtrlCreateButton("7", 32, 200, 41, 41, 0)
$Button8 = GUICtrlCreateButton("8", 96, 200, 41, 41, 0)
$Button9 = GUICtrlCreateButton("9", 160, 200, 41, 41, 0)
$Button10 = GUICtrlCreateButton("0", 32, 264, 41, 41, 0)
$Button11 = GUICtrlCreateButton("+", 224, 72, 41, 41, 0)
$Button12 = GUICtrlCreateButton("-", 224, 136, 41, 41, 0)
$Button13 = GUICtrlCreateButton("*", 224, 200, 41, 41, 0)
$Button14 = GUICtrlCreateButton("/", 224, 264, 41, 41, 0)
$Button15 = GUICtrlCreateButton("=", 160, 264, 41, 41, 0)
$Button16 = GUICtrlCreateButton("C", 96, 264, 41, 41, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "1")
Case $Button2
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "2")
Case $Button3
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "3")
Case $Button4
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "4")
Case $Button5
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "5")
Case $Button6
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "6")
Case $Button7
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "7")
Case $Button8
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "8")
Case $Button9
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "9")
Case $Button10
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "0")
Case $Button11
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "+")
Case $Button12
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "-")
Case $Button13
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "*")
Case $Button14
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "/")
Case $Button15
GUICtrlSetData($label1, Execute(GUICtrlRead($label1)))
Case $Button16
GUICtrlSetData($Label1, "")
EndSwitch
WEnd
Func _nummer1()
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "1")
EndFunc
Func _nummer2()
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "2")
EndFunc
Func _nummer3()
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "3")
EndFunc
Func _nummer4()
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "4")
EndFunc
Func _nummer5()
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "5")
EndFunc
Func _nummer6()
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "6")
EndFunc
Func _nummer7()
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "7")
EndFunc
Func _nummer8()
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "8")
EndFunc
Func _nummer9()
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "9")
EndFunc
Func _nummer0()
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "0")
EndFunc
Func _divi()
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "/")
EndFunc
Func _multi()
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "*")
EndFunc
Func _addi()
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "+")
EndFunc
Func _subt()
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "-")
EndFunc
Func _gleich()
GUICtrlSetData($label1, Execute(GUICtrlRead($label1)))
EndFunc
Ich schreibe es mal kurz um Mom ...
So Klappt Es ...:
#include <GUIConstants.au3>
#include <Misc.au3>
AdLibEnable("_Ziffern", 100)
[/autoit] [autoit][/autoit] [autoit]#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Taschenrechner", 289, 319, 189, 121)
$Label1 = GUICtrlCreateLabel("", 24, 24, 244, 28)
$Button1 = GUICtrlCreateButton("1", 32, 72, 41, 41, 0)
$Button2 = GUICtrlCreateButton("2", 96, 72, 41, 41, 0)
$Button3 = GUICtrlCreateButton("3", 160, 72, 41, 41, 0)
$Button4 = GUICtrlCreateButton("4", 32, 136, 41, 41, 0)
$Button5 = GUICtrlCreateButton("5", 96, 136, 41, 41, 0)
$Button6 = GUICtrlCreateButton("6", 160, 136, 41, 41, 0)
$Button7 = GUICtrlCreateButton("7", 32, 200, 41, 41, 0)
$Button8 = GUICtrlCreateButton("8", 96, 200, 41, 41, 0)
$Button9 = GUICtrlCreateButton("9", 160, 200, 41, 41, 0)
$Button10 = GUICtrlCreateButton("0", 32, 264, 41, 41, 0)
$Button11 = GUICtrlCreateButton("+", 224, 72, 41, 41, 0)
$Button12 = GUICtrlCreateButton("-", 224, 136, 41, 41, 0)
$Button13 = GUICtrlCreateButton("*", 224, 200, 41, 41, 0)
$Button14 = GUICtrlCreateButton("/", 224, 264, 41, 41, 0)
$Button15 = GUICtrlCreateButton("=", 160, 264, 41, 41, 0)
$Button16 = GUICtrlCreateButton("C", 96, 264, 41, 41, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "1")
Case $Button2
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "2")
Case $Button3
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "3")
Case $Button4
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "4")
Case $Button5
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "5")
Case $Button6
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "6")
Case $Button7
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "7")
Case $Button8
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "8")
Case $Button9
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "9")
Case $Button10
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "0")
Case $Button11
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "+")
Case $Button12
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "-")
Case $Button13
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "*")
Case $Button14
GUICtrlSetData($Label1, GUICtrlRead($Label1) & "/")
Case $Button15
GUICtrlSetData($label1, Execute(GUICtrlRead($label1)))
Case $Button16
GUICtrlSetData($Label1, "")
EndSwitch
WEnd
Func _Ziffern()
Global $Label = GUICtrlRead($Label1)
If _IsPressed("60") Then GUiCtrlSetData($Label1, $Label & "0")
If _IsPressed("61") Then GUiCtrlSetData($Label1, $Label & "1")
If _IsPressed("62") Then GUiCtrlSetData($Label1, $Label & "2")
If _IsPressed("63") Then GUiCtrlSetData($Label1, $Label & "3")
If _IsPressed("64") Then GUiCtrlSetData($Label1, $Label & "4")
If _IsPressed("65") Then GUiCtrlSetData($Label1, $Label & "5")
If _IsPressed("66") Then GUiCtrlSetData($Label1, $Label & "6")
If _IsPressed("67") Then GUiCtrlSetData($Label1, $Label & "7")
If _IsPressed("68") Then GUiCtrlSetData($Label1, $Label & "8")
If _IsPressed("69") Then GUiCtrlSetData($Label1, $Label & "9")
If _IsPressed("6A") Then GUiCtrlSetData($Label1, $Label & "*")
If _IsPressed("6B") Then GUiCtrlSetData($Label1, $Label & "+")
If _IsPressed("6D") Then GUiCtrlSetData($Label1, $Label & "-")
If _IsPressed("6F") Then GUiCtrlSetData($Label1, $Label & "/")
If _IsPressed("0D") Then GUiCtrlSetData($Label1, Execute($Label))
EndFunc
Danke vielmal^^
Kein Problem
Das geht aber auch noch kürzer (und mit GUISetAccelerators):
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
Opt('GUIOnEventMode', 1)
Global $aButtons[17] = ['7', '8', '9', '+', '4', '5', '6', '-', '1', '2', '3', '*', 'C', '0', '.', '/', '=']
Global $aKeys[17] = [ _
'{NUMPAD7}', '{NUMPAD8}', '{NUMPAD9}', '{NUMPADADD}', _
'{NUMPAD4}', '{NUMPAD5}', '{NUMPAD6}', '{NUMPADSUB}', _
'{NUMPAD1}', '{NUMPAD2}', '{NUMPAD3}', '{NUMPADMULT}', _
'{DEL}', '{NUMPAD0}', '{NUMPADDOT}', '{NUMPADDIV}', _
'{ENTER}']
Global $aAccelKeys[17][2], $ahButtons[17]
$hGui = GUICreate('Taschenrechner', 290, 380)
GUISetOnEvent($GUI_EVENT_CLOSE, '_End')
$hOutput = GUICtrlCreateLabel('', 32, 20, 234, 28, $SS_RIGHT, $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 18)
GUICtrlSetBkColor(-1, 0xFFFFAA)
For $i = 0 To 16
If $i = 16 Then
$ahButtons[$i] = GUICtrlCreateButton($aButtons[$i], 96, 72 + Int($i / 4) * 64, 106, 32)
Else
$ahButtons[$i] = GUICtrlCreateButton($aButtons[$i], 32 + Mod($i, 4) * 64, 72 + Int($i / 4) * 64, 42, 42)
EndIf
GUICtrlSetFont(-1, 16, 600)
GUICtrlSetOnEvent(-1, '_Input')
$aAccelKeys[$i][0] = $aKeys[$i]
$aAccelKeys[$i][1] = $ahButtons[$i]
Next
GUISetAccelerators($aAccelKeys, $hGui)
GUISetState()
While True
Sleep(50)
WEnd
Func _End()
Exit
EndFunc ;==>_End
Func _Input()
Local $iPressed = @GUI_CtrlId - $ahButtons[0]
Switch $iPressed
Case 16 ; "=" gedrückt
GUICtrlSetData($hOutput, Execute(GUICtrlRead($hOutput)))
Case 12 ; "C" gedrückt
GUICtrlSetData($hOutput, '')
Case Else ; restliche Tasten
GUICtrlSetData($hOutput, GUICtrlRead($hOutput) & $aButtons[$iPressed])
EndSwitch
EndFunc ;==>_Input