QB64 Phoenix Edition
Keyboard scancodes. - Printable Version

+- QB64 Phoenix Edition (https://staging.qb64phoenix.com)
+-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://staging.qb64phoenix.com/forumdisplay.php?fid=10)
+---- Thread: Keyboard scancodes. (/showthread.php?tid=1650)



Keyboard scancodes. - eoredson - 04-30-2023

Hi,

I have been using the following keyboard scancodes for awhile, but I can't get it to detect Ctrl-Alt-Delete at all:

Code: (Select All)
Print "Test keyboard scancodes. Press <Esc> to quit"

On Timer(1) CtrlBreak
Timer On
x = _Exit

Const KEY_RSHIFT& = 100303
Const KEY_LSHIFT& = 100304

Const KEY_RCTRL& = 100305
Const KEY_LCTRL& = 100306

Const KEY_RALT& = 100307
Const KEY_LALT& = 100308

Do
    _Limit 100
    x& = _KeyHit
    If x& > 0 Then
        If x& = KEY_RALT& Then
            Print "Right-Alt-"
        End If
        If x& = KEY_LALT& Then
            Print "Left-Alt-"
        End If
        If x& = KEY_RSHIFT& Then
            Print "Right-Shift-"
        End If
        If x& = KEY_LSHIFT& Then
            Print "Left-Shift-"
        End If
        If x& = KEY_RCTRL& Then
            Print "Right-Ctrl-"
        End If
        If x& = KEY_LCTRL& Then
            Print "Left-Ctrl-"
        End If
    End If
    If x& < 0 Then
        Select Case x&
            Case -12
                Print "Keypad-5"
            Case -108
                Print "Ctrl-KeyPad-5"
            Case -20
                Print "Caps lock"
            Case -144
                Print "Num lock"
            Case -145
                Print "Scroll lock"
            Case -44
                Print "Print-Screen"
                'Case Else
                '    Print x&
        End Select
    End If
    x$ = InKey$
    If Len(x$) Then
        If x$ = Chr$(27) Then
            Exit Do
        Else
            If Len(x$) = 2 Then
                Print Asc(Right$(x$, 1))
            Else
                Print Asc(x$)
            End If
        End If
    End If
Loop
Timer Off
End

Sub CtrlBreak
    x = _Exit
    If x Then
        Print "Ctrl-Break"
    End If
End Sub



RE: Keyboard scancodes. - SMcNeill - 04-30-2023

Ctrl-Alt-Delete is a system reserved key combo usually.


RE: Keyboard scancodes. - eoredson - 05-01-2023

Yes, Ctrl-Alt-Del is trapped by the SAS event which in turn calls the Gina.dll library.

The only way to trap your own event is by re-writing the Gina library.

Erik.

SAS is the secure attention sequence.
https://msdn.microsoft.com/en-us/library/aa375457(v=vs.85).aspx