Probleme mit ExamineKeyboard
Verfasst: 23.11.2014 17:53
Hallo Gemeinde,
soeben hatte ich vor eine Prozedur auszuprobieren, um zu sehen ob diese
wie gewollt arbeitet und ob noch irgendwelche Fehler enthalten sind.
Dabei handelt es sich um die Prozedur.s KeyCombo() welche mir
als Rückgabewert einen String der Gleichzeitig gedrückten Tasten liefern soll.
Leider tritt bei der Ausführung des Programms ein (für mich) nicht begründeter
Fehler auf. Da es immer beim ersten Aufruf von ExamineKeyboard()
zu einem Fehler kommt, welcher mir mittels meiner funktionierenden
Fehler-Abfang-Funktion CatchERROR() mitgeteilt wird.
Daher stellt sich mir nun die Frage, worin hier das Problem liegt das ich bei Ausführung
des Programms die Debug-Message "CatchERROR: KeyCombo.ExamineKeyboard Erfolglos"
erhalte, obwohl die Tastatur erfolgreich initialisiert wurde?
Ebenso Anzumerken wie verwunderlich ist für mich,
weshalb der Beispiel-Code Keyboard.pb einwandfrei funktioniert,
mein kleiner Test-Code jedoch nicht. Es kann ja wohl kaum sein
wegen der Verwendung von EnableExplicit nicht lauffähig ist.
soeben hatte ich vor eine Prozedur auszuprobieren, um zu sehen ob diese
wie gewollt arbeitet und ob noch irgendwelche Fehler enthalten sind.
Dabei handelt es sich um die Prozedur.s KeyCombo() welche mir
als Rückgabewert einen String der Gleichzeitig gedrückten Tasten liefern soll.
Leider tritt bei der Ausführung des Programms ein (für mich) nicht begründeter
Fehler auf. Da es immer beim ersten Aufruf von ExamineKeyboard()
zu einem Fehler kommt, welcher mir mittels meiner funktionierenden
Fehler-Abfang-Funktion CatchERROR() mitgeteilt wird.
Daher stellt sich mir nun die Frage, worin hier das Problem liegt das ich bei Ausführung
des Programms die Debug-Message "CatchERROR: KeyCombo.ExamineKeyboard Erfolglos"
erhalte, obwohl die Tastatur erfolgreich initialisiert wurde?
Ebenso Anzumerken wie verwunderlich ist für mich,
weshalb der Beispiel-Code Keyboard.pb einwandfrei funktioniert,
mein kleiner Test-Code jedoch nicht. Es kann ja wohl kaum sein
wegen der Verwendung von EnableExplicit nicht lauffähig ist.
Code: Alles auswählen
EnableExplicit
;{ STRUCTURE'S
;}
;{ DEFINE'S
;
Define b_exit_program = #False
;
Define i_counter.i = 0
Define i_num.i = 0
;
Define s_keycombo.s = ""
;}
;{ PROCEDURE'S
;
;{ Fängt einen Fehler ab und Beendet das Programm mit einem Error-Requester und Exit Code 255
Procedure CatchERROR( i_ergebnis.i, s_text.s )
If i_ergebnis = 0
Beep_( 3000, 100 )
Beep_( 1000, 100 )
Beep_( 2000, 100 )
Debug( "CatchERROR: "+s_text )
MessageRequester( "CatchERROR: ", s_text, #PB_MessageRequester_Ok )
Delay(3000)
End 255
EndIf
EndProcedure
;}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; gibt eine tastenkombinationen als string zurück
; Beispiel: [LCTRL][X]
; Beispiel: [LCTRL][RSHIFT][F3]
;
Procedure.s KeyCombo()
Define s_returnstring.s = ""
;If IsScreenActive()
CatchERROR( ExamineKeyboard(), "KeyCombo.ExamineKeyboard Erfolglos" )
;EndIf
If KeyboardPushed( #PB_Key_LeftControl )
s_returnstring = s_returnstring + "[LCTRL]"
EndIf
If KeyboardPushed( #PB_Key_LeftShift )
s_returnstring = s_returnstring + "[LSHIFT]"
EndIf
If KeyboardPushed( #PB_Key_LeftAlt )
s_returnstring = s_returnstring + "[LALT]"
EndIf
If KeyboardPushed( #PB_Key_RightControl )
s_returnstring = s_returnstring + "[RCTRL]"
EndIf
If KeyboardPushed( #PB_Key_RightShift )
s_returnstring = s_returnstring + "[RSHIFT]"
EndIf
If KeyboardPushed( #PB_Key_RightAlt )
s_returnstring = s_returnstring + "[RALT]"
EndIf
If KeyboardPushed( #PB_Key_F1 )
s_returnstring = s_returnstring + "[F1]"
EndIf
If KeyboardPushed( #PB_Key_F2 )
s_returnstring = s_returnstring + "[F2]"
EndIf
If KeyboardPushed( #PB_Key_F3 )
s_returnstring = s_returnstring + "[F3]"
EndIf
If KeyboardPushed( #PB_Key_F4 )
s_returnstring = s_returnstring + "[F4]"
EndIf
If KeyboardPushed( #PB_Key_F5 )
s_returnstring = s_returnstring + "[F5]"
EndIf
If KeyboardPushed( #PB_Key_F6 )
s_returnstring = s_returnstring + "[F6]"
EndIf
If KeyboardPushed( #PB_Key_F7 )
s_returnstring = s_returnstring + "[F7]"
EndIf
If KeyboardPushed( #PB_Key_F8 )
s_returnstring = s_returnstring + "[F8]"
EndIf
If KeyboardPushed( #PB_Key_F9 )
s_returnstring = s_returnstring + "[F9]"
EndIf
If KeyboardPushed( #PB_Key_F10 )
s_returnstring = s_returnstring + "[F10]"
EndIf
If KeyboardPushed( #PB_Key_F11 )
s_returnstring = s_returnstring + "[F11]"
EndIf
If KeyboardPushed( #PB_Key_F12 )
s_returnstring = s_returnstring + "[F12]"
EndIf
If KeyboardPushed( #PB_Key_Scroll )
s_returnstring = s_returnstring + "[SCROLL]"
EndIf
If KeyboardPushed( #PB_Key_Pause )
s_returnstring = s_returnstring + "[PAUSE]"
EndIf
If KeyboardPushed( #PB_Key_Escape )
s_returnstring = s_returnstring + "[ESC]"
EndIf
If KeyboardPushed( #PB_Key_Back )
s_returnstring = s_returnstring + "[BACK]"
EndIf
If KeyboardPushed( #PB_Key_Tab )
s_returnstring = s_returnstring + "[TAB]"
EndIf
If KeyboardPushed( #PB_Key_Return )
s_returnstring = s_returnstring + "[RETURN]"
EndIf
If KeyboardPushed( #PB_Key_Space )
s_returnstring = s_returnstring + "[SPACE]"
EndIf
If KeyboardPushed( #PB_Key_1 )
s_returnstring = s_returnstring + "[1]"
EndIf
If KeyboardPushed( #PB_Key_2 )
s_returnstring = s_returnstring + "[2]"
EndIf
If KeyboardPushed( #PB_Key_3 )
s_returnstring = s_returnstring + "[3]"
EndIf
If KeyboardPushed( #PB_Key_4 )
s_returnstring = s_returnstring + "[4]"
EndIf
If KeyboardPushed( #PB_Key_5 )
s_returnstring = s_returnstring + "[5]"
EndIf
If KeyboardPushed( #PB_Key_6 )
s_returnstring = s_returnstring + "[6]"
EndIf
If KeyboardPushed( #PB_Key_7 )
s_returnstring = s_returnstring + "[7]"
EndIf
If KeyboardPushed( #PB_Key_8 )
s_returnstring = s_returnstring + "[8]"
EndIf
If KeyboardPushed( #PB_Key_9 )
s_returnstring = s_returnstring + "[9]"
EndIf
If KeyboardPushed( #PB_Key_0 )
s_returnstring = s_returnstring + "[0]"
EndIf
If KeyboardPushed( #PB_Key_A )
s_returnstring = s_returnstring + "[A]"
EndIf
If KeyboardPushed( #PB_Key_B )
s_returnstring = s_returnstring + "[B]"
EndIf
If KeyboardPushed( #PB_Key_C )
s_returnstring = s_returnstring + "[C]"
EndIf
If KeyboardPushed( #PB_Key_D )
s_returnstring = s_returnstring + "[D]"
EndIf
If KeyboardPushed( #PB_Key_E )
s_returnstring = s_returnstring + "[E]"
EndIf
If KeyboardPushed( #PB_Key_F )
s_returnstring = s_returnstring + "[F]"
EndIf
If KeyboardPushed( #PB_Key_G )
s_returnstring = s_returnstring + "[G]"
EndIf
If KeyboardPushed( #PB_Key_H )
s_returnstring = s_returnstring + "[H]"
EndIf
If KeyboardPushed( #PB_Key_I )
s_returnstring = s_returnstring + "[I]"
EndIf
If KeyboardPushed( #PB_Key_J )
s_returnstring = s_returnstring + "[J]"
EndIf
If KeyboardPushed( #PB_Key_K )
s_returnstring = s_returnstring + "[K]"
EndIf
If KeyboardPushed( #PB_Key_L )
s_returnstring = s_returnstring + "[L]"
EndIf
If KeyboardPushed( #PB_Key_M )
s_returnstring = s_returnstring + "[M]"
EndIf
If KeyboardPushed( #PB_Key_N )
s_returnstring = s_returnstring + "[N]"
EndIf
If KeyboardPushed( #PB_Key_O )
s_returnstring = s_returnstring + "[O]"
EndIf
If KeyboardPushed( #PB_Key_P )
s_returnstring = s_returnstring + "[P]"
EndIf
If KeyboardPushed( #PB_Key_Q )
s_returnstring = s_returnstring + "[Q]"
EndIf
If KeyboardPushed( #PB_Key_R )
s_returnstring = s_returnstring + "[R]"
EndIf
If KeyboardPushed( #PB_Key_S )
s_returnstring = s_returnstring + "[S]"
EndIf
If KeyboardPushed( #PB_Key_T )
s_returnstring = s_returnstring + "[T]"
EndIf
If KeyboardPushed( #PB_Key_U )
s_returnstring = s_returnstring + "[U]"
EndIf
If KeyboardPushed( #PB_Key_V )
s_returnstring = s_returnstring + "[V]"
EndIf
If KeyboardPushed( #PB_Key_W )
s_returnstring = s_returnstring + "[W]"
EndIf
If KeyboardPushed( #PB_Key_X )
s_returnstring = s_returnstring + "[X]"
EndIf
If KeyboardPushed( #PB_Key_Y )
s_returnstring = s_returnstring + "[Y]"
EndIf
If KeyboardPushed( #PB_Key_Z )
s_returnstring = s_returnstring + "[Z]"
EndIf
If KeyboardPushed( #PB_Key_Minus )
s_returnstring = s_returnstring + "[MINUS]"
EndIf
If KeyboardPushed( #PB_Key_Equals )
s_returnstring = s_returnstring + "[EQUALS]"
EndIf
If KeyboardPushed( #PB_Key_LeftBracket )
s_returnstring = s_returnstring + "[LBRACKET]"
EndIf
If KeyboardPushed( #PB_Key_RightBracket )
s_returnstring = s_returnstring + "[RBRACKET]"
EndIf
If KeyboardPushed( #PB_Key_Apostrophe )
s_returnstring = s_returnstring + "[APOSTROPHE]"
EndIf
If KeyboardPushed( #PB_Key_Grave )
s_returnstring = s_returnstring + "[GRAVE]"
EndIf
If KeyboardPushed( #PB_Key_BackSlash )
s_returnstring = s_returnstring + "[BACKSLASH]"
EndIf
If KeyboardPushed( #PB_Key_Comma )
s_returnstring = s_returnstring + "[COMMA]"
EndIf
If KeyboardPushed( #PB_Key_SemiColon )
s_returnstring = s_returnstring + "[SEMICOLON]"
EndIf
If KeyboardPushed( #PB_Key_Period )
s_returnstring = s_returnstring + "[PERIOD]"
EndIf
If KeyboardPushed( #PB_Key_Slash )
s_returnstring = s_returnstring + "[SLASH]"
EndIf
If KeyboardPushed( #PB_Key_Multiply )
s_returnstring = s_returnstring + "[MULTIPLY]"
EndIf
If KeyboardPushed( #PB_Key_Capital )
s_returnstring = s_returnstring + "[CAPITAL]"
EndIf
If KeyboardPushed( #PB_Key_NumLock )
s_returnstring = s_returnstring + "[NUMLOCK]"
EndIf
If KeyboardPushed( #PB_Key_Pad0 )
s_returnstring = s_returnstring + "[PAD0]"
EndIf
If KeyboardPushed( #PB_Key_Pad1 )
s_returnstring = s_returnstring + "[PAD1]"
EndIf
If KeyboardPushed( #PB_Key_Pad2 )
s_returnstring = s_returnstring + "[PAD2]"
EndIf
If KeyboardPushed( #PB_Key_Pad3 )
s_returnstring = s_returnstring + "[PAD3]"
EndIf
If KeyboardPushed( #PB_Key_Pad4 )
s_returnstring = s_returnstring + "[PAD4]"
EndIf
If KeyboardPushed( #PB_Key_Pad5 )
s_returnstring = s_returnstring + "[PAD5]"
EndIf
If KeyboardPushed( #PB_Key_Pad6 )
s_returnstring = s_returnstring + "[PAD6]"
EndIf
If KeyboardPushed( #PB_Key_Pad7 )
s_returnstring = s_returnstring + "[PAD7]"
EndIf
If KeyboardPushed( #PB_Key_Pad8 )
s_returnstring = s_returnstring + "[PAD8]"
EndIf
If KeyboardPushed( #PB_Key_Pad9 )
s_returnstring = s_returnstring + "[PAD9]"
EndIf
If KeyboardPushed( #PB_Key_PadEnter )
s_returnstring = s_returnstring + "[PADENTER]"
EndIf
If KeyboardPushed( #PB_Key_PadComma )
s_returnstring = s_returnstring + "[PADCOMMA]"
EndIf
If KeyboardPushed( #PB_Key_Add )
s_returnstring = s_returnstring + "[PADADD]"
EndIf
If KeyboardPushed( #PB_Key_Subtract )
s_returnstring = s_returnstring + "[PADSUBSTRACT]"
EndIf
If KeyboardPushed( #PB_Key_Decimal )
s_returnstring = s_returnstring + "[PADDECIMAL]"
EndIf
If KeyboardPushed( #PB_Key_Divide )
s_returnstring = s_returnstring + "[PADDIVIDE]"
EndIf
If KeyboardPushed( #PB_Key_Insert )
s_returnstring = s_returnstring + "[INS]"
EndIf
If KeyboardPushed( #PB_Key_Delete )
s_returnstring = s_returnstring + "[DEL]"
EndIf
If KeyboardPushed( #PB_Key_Home )
s_returnstring = s_returnstring + "[POS1]"
EndIf
If KeyboardPushed( #PB_Key_End )
s_returnstring = s_returnstring + "[ENDE]"
EndIf
If KeyboardPushed( #PB_Key_PageUp )
s_returnstring = s_returnstring + "[PGUP]"
EndIf
If KeyboardPushed( #PB_Key_PageDown )
s_returnstring = s_returnstring + "[PGDOWN]"
EndIf
If KeyboardPushed( #PB_Key_Up )
s_returnstring = s_returnstring + "[CSRUP]"
EndIf
If KeyboardPushed( #PB_Key_Down )
s_returnstring = s_returnstring + "[CSRDOWN]"
EndIf
If KeyboardPushed( #PB_Key_Left )
s_returnstring = s_returnstring + "[CSRLEFT]"
EndIf
If KeyboardPushed( #PB_Key_Right )
s_returnstring = s_returnstring + "[CSRRIGHT]"
EndIf
ProcedureReturn s_returnstring
EndProcedure
;
;}
;{ MAIN_PROGRAM
;
CatchError( InitKeyboard(), "InitKeyboard Erfolglos" )
CatchError( InitSprite(), "InitSprite Erfolglos" )
CatchError( OpenWindow ( 0, 0, 0, 800, 600, "ICH BIN EIN FENSTER", #PB_Window_Minimize ), "OpenWindow Erfolglos" )
CatchError( OpenWindowedScreen( WindowID(0) , 10, 10, 100, 100, #False, 10, #PB_Screen_WaitSynchronization ), "OpenWindowedScreen Erfolglos" )
s_keycombo = KeyCombo()
Repeat
Debug ( s_keycombo )
Delay(1)
ForEver
;
;}