Beschreibung
InputEx erlaubt es euch alle Tasten auf der Tastatur und Maus zu verwenden.
Dies wird ermöglicht durch das benutzen mehrerer Windows API funktionen, wie zum Beispiel MapVirtualKeyEx, welche uns erlaubt Virtual Scan Codes auf Virtual Key Codes umzuwandeln.
Zeitgleich prüft InputEx auch ob das Signal überhaupt für unser Programm bestimmt ist um nicht zufällig die Eingaben für andere Programme mit zuschneiden.
Fast vergessen: Mit InputEx habt Ihr auch Zugriff auf die Zeit wann eine Änderung bekannt wurde, und für wie viele Updates diese bekannt ist.
Funktionen
- InputEx_Init ()
Was: Initialisiert die benötigten variablen für spätere Verwendung.
Wo: Nach dem Programmstart, vor der Hauptschleife.
- InputEx_Update ()
Was: Hält die Werte für die tasten aktuell.
Wo: In der Hauptschleife, vor allem benutzen anderer Funktionen.
- InputEx_VKeyTime ( VirtualKey% )
Was: Liefert die Zeit seit der letzten Änderung von VirtualKey zurück.
- InputEx_VKeyDownEx ( VirtualKey% )
Was: Liefert die Anzahl an InputEx_Update's zurück die VirtualKey aktiv war (wert über 0) oder inaktiv war (wert unter 0).
- InputEx_VKeyDown ( VirtualKey% )
Was: Liefert zurück, ob VirtualKey aktiv ist.
- InputEx_VKeyHitEx ( VirtualKey% )
Was: Liefert zurück, wie oft VirtualKey gedrückt wurde.
- InputEx_VKeyHit ( VirtualKey% )
Was: Liefert zurück, wie oft VirtualKey seit dem letzen Aufruf gedrückt wurde.
- InputEx_KeyTime ( ScanCode% )
Was: Liefert die Zeit seit der letzten Änderung von ScanCode zurück.
- InputEx_KeyDownEx ( ScanCode% )
Was: Liefert die Anzahl an InputEx_Update's zurück die ScanCode aktiv war (wert über 0) oder inaktiv war (wert unter 0).
- InputEx_KeyDown ( ScanCode% )
Was: Liefert zurück, ob ScanCode aktiv ist.
- InputEx_KeyHitEx ( ScanCode% )
Was: Liefert zurück, wie oft ScanCode gedrückt wurde.
- InputEx_KeyHit ( ScanCode% )
Was: Liefert zurück, wie oft ScanCode seit dem letzen Aufruf gedrückt wurde.
- InputEx_MouseTime ( Button% )
Was: Liefert die Zeit seit der letzten Änderung von Button zurück.
- InputEx_MouseDownEx ( Button% )
Was: Liefert die Anzahl an InputEx_Update's zurück die Button aktiv war (wert über 0) oder inaktiv war (wert unter 0).
- InputEx_MouseDown ( Button% )
Was: Liefert zurück, ob Button aktiv ist.
- InputEx_MouseHitEx ( Button% )
Was: Liefert zurück, wie oft Button gedrückt wurde.
- InputEx_MouseHit ( Button% )
Was: Liefert zurück, wie oft Button seit dem letzen Aufruf gedrückt wurde.
- KeyTime ( Key% )
Was: Wrapper für InputEx_KeyTime.
- KeyDownEx ( Key% )
Was: Wrapper für InputEx_KeyDownEx.
- KeyDown ( Key% )
Was: Wrapper für InputEx_KeyDown.
- KeyHitEx ( Key% )
Was: Wrapper für InputEx_KeyHitEx.
- KeyHit ( Key% )
Was: Wrapper für InputEx_KeyHit.
- MouseTime ( Button% )
Was: Wrapper für InputEx_MouseTime.
- MouseDownEx ( Button% )
Was: Wrapper für InputEx_MouseDownEx.
- MouseDown ( Button% )
Was: Wrapper für InputEx_MouseDown.
- MouseHitEx ( Button% )
Was: Wrapper für InputEx_MouseHitEx.
- MouseHit ( Button% )
Was: Wrapper für InputEx_MouseHit.
Library Sourcecode inkl. Beispiel:
BlitzBasic: [AUSKLAPPEN] [EINKLAPPEN]
Type Point Field X,Y End Type
Global InputEx_Window = SystemProperty("AppHWND"), InputEx_ForMe = True Global InputEx_Mouse.Point = New Point Dim InputEx_State(256) Dim InputEx_StateTime(256) Dim InputEx_StateUpdates(256) Dim InputEx_Hits(256) Dim InputEx_VSCAsVK(256)
Function InputEx_Init(applicationTitle$="")
If Not InputEx_Window Then User32_FindWindow("Blitz Runtime Class", applicationTitle) User32_GetCursorPosition(InputEx_Mouse) User32_ScreenToClient(InputEx_Window, InputEx_Mouse) InputEx_ForMe = (User32_GetActiveWindow() = InputEx_Window) If Not ((InputEx_Mouse\X >= 0) And (InputEx_Mouse\Y >= 0) And (InputEx_Mouse\X < GraphicsWidth()) And (InputEx_MouseY < GraphicsHeight())) Then InputEx_ForMe = False For VSC = 0 To 255 InputEx_VSCAsVK(VSC) = User32_MapVirtualKeyEx(VSC, 1, 0) Next End Function
Function InputEx_Update()
Local InputEx_StateNew Local InputEx_Time = MilliSecs()
User32_GetCursorPosition(InputEx_Mouse) User32_ScreenToClient(InputEx_Window, InputEx_Mouse) InputEx_ForMe = (User32_GetActiveWindow() = InputEx_Window) If Not ((InputEx_Mouse\X >= 0) And (InputEx_Mouse\Y >= 0) And (InputEx_Mouse\X < GraphicsWidth()) And (InputEx_Mouse\Y < GraphicsHeight())) Then InputEx_ForMe = False If InputEx_ForMe Then For VK = 0 To 255 InputEx_StateNew = (User32_GetAsyncKeyState(VK) <> 0) If (InputEx_StateNew = 1) And (InputEx_State(VK) = 0) Then InputEx_Hits(VK) = InputEx_Hits(VK) + 1 InputEx_State(VK) = 1 InputEx_StateUpdates(VK) = 0 InputEx_StateTime(VK) = InputEx_Time ElseIf (InputEx_StateNew = 0) And (InputEx_State(VK) = 1) Then InputEx_State(VK) = 0 InputEx_StateUpdates(VK) = 0 InputEx_StateTime(VK) = InputEx_Time Else If (InputEx_State(VK) = 1) Then InputEx_StateUpdates(VK) = InputEx_StateUpdates(VK) + 1 Else InputEx_StateUpdates(VK) = InputEx_StateUpdates(VK) - 1 EndIf EndIf Next Else For VK = 0 To 255 InputEx_State(VK) = 0 InputEx_StateTime(VK) = InputEx_Time Next EndIf End Function
Function InputEx_VKeyTime(VirtualKey)
Return InputEx_StateTime(VirtualKey) End Function
Function InputEx_VKeyDownEx(VirtualKey)
Return InputEx_StateUpdates(VirtualKey) End Function
Function InputEx_VKeyDown(VirtualKey)
Return InputEx_State(VirtualKey) End Function
Function InputEx_VKeyHitEx(VirtualKey, Reduce=1)
Local Hits = InputEx_Hits(VirtualKey) InputEx_Hits(VirtualKey) = InputEx_Hits(VirtualKey) - Reduce Return Hits End Function
Function InputEx_VKeyHit(VirtualKey)
Local Hits = InputEx_Hits(VirtualKey) InputEx_Hits(VirtualKey) = 0 Return Hits End Function
Function InputEx_KeyTime(ScanCode)
Return InputEx_VKeyTime(InputEx_VSCAsVK(ScanCode)) End Function
Function InputEx_KeyDownEx(ScanCode)
Return InputEx_VKeyDownEx(InputEx_VSCAsVK(ScanCode)) End Function
Function InputEx_KeyDown(ScanCode)
Return InputEx_VKeyDown(InputEx_VSCAsVK(ScanCode)) End Function
Function InputEx_KeyHitEx(ScanCode)
Return InputEx_VKeyHitEx(InputEx_VSCAsVK(ScanCode)) End Function
Function InputEx_KeyHit(ScanCode)
Return InputEx_VKeyHit(InputEx_VSCAsVK(ScanCode)) End Function
Function InputEx_MouseTime(Button)
Select Button Case 1,2 Return InputEx_VKeyTime(Button) Case 3,4,5 Return InputEx_VKeyTime(Button+1) End Select End Function
Function InputEx_MouseDownEx(Button)
Select Button Case 1,2 Return InputEx_VKeyDownEx(Button) Case 3,4,5 Return InputEx_VKeyDownEx(Button+1) End Select End Function
Function InputEx_MouseDown(Button)
Select Button Case 1,2 Return InputEx_VKeyDown(Button) Case 3,4,5 Return InputEx_VKeyDown(Button+1) End Select End Function
Function InputEx_MouseHitEx(Button)
Select Button Case 1,2 Return InputEx_VKeyHitEx(Button) Case 3,4,5 Return InputEx_VKeyHitEx(Button+1) End Select End Function
Function InputEx_MouseHit(Button)
Select Button Case 1,2 Return InputEx_VKeyHit(Button) Case 3,4,5 Return InputEx_VKeyHit(Button+1) End Select End Function
Function MouseTime(Button) Return InputEx_MouseTime(Button) End Function
Function MouseDownEx(Button) Return InputEx_MouseDownEx(Button) End Function
Function MouseDown(Button) Return InputEx_MouseDown(Button) End Function
Function MouseHitEx(Button) Return InputEx_MouseHitEx(Button) End Function
Function MouseHit(Button) Return InputEx_MouseHit(Button) End Function
Function KeyTime(Key) Return InputEx_KeyTime(Key) End Function
Function KeyDownEx(Key) Return InputEx_KeyHitEx(Key) End Function
Function KeyDown(Key) Return InputEx_KeyDown(Key) End Function
Function KeyHitEx(Key) Return InputEx_KeyHitEx(Key) End Function
Function KeyHit(Key) Return InputEx_KeyHit(Key) End Function
|