Tastendruck simulieren
- VB.NET
Sie verwenden einen veralteten Browser (%browser%) mit Sicherheitsschwachstellen und können nicht alle Funktionen dieser Webseite nutzen.
Hier erfahren Sie, wie einfach Sie Ihren Browser aktualisieren können.
Hier erfahren Sie, wie einfach Sie Ihren Browser aktualisieren können.
Es gibt 29 Antworten in diesem Thema. Der letzte Beitrag () ist von meikmenzel.
-
-
System.Windows.Forms.SendKeys.SendWait("{TAB}")
Liste von Sendkeys:
Spoiler anzeigen
{!} <-> !
{#} <-> #
{+} <-> +
{^} <-> ^
{{} <-> {
{}} <-> }
{SPACE} <-> SPACE
{ENTER} <-> ENTER key on the main keyboard
{ALT} <-> ALT
{BACKSPACE} or {BS} <-> BACKSPACE
{DELETE} or {DEL} <-> DELETE
{UP} <-> Up arrow
{DOWN} <-> Down arrow
{LEFT} <-> Left arrow
{RIGHT} <-> Right arrow
{HOME} <-> HOME
{END} <-> END
{ESCAPE} or {ESC} <-> ESCAPE
{INSERT} or {INS} <-> INS
{PGUP} <-> PGUP
{PGDN} <-> PGDN
{F1} - {F12} <-> Function keys
{TAB} <-> TAB
{PRINTSCREEN} <-> PRINTSCR
{LWIN} <-> Left Windows key
{RWIN} <-> Right Windows key
{NUMLOCK} <-> NUMLOCK
{CAPSLOCK} <-> CAPSLOCK
{SCROLLLOCK} <-> SCROLLLOCK
{BREAK} <-> for Ctrl+Break processing
{PAUSE} <-> PAUSEThere is no CLOUD - just other people's computers
Q: Why do JAVA developers wear glasses?
A: Because they can't C#
Daily prayer:
"Dear Lord, grand me the strength not to kill any stupid people today and please grant me the ability to punch them in the face over standard TCP/IP." -
-
Schau dir mal diesen Artikel auf PInvoke.Net an.
-
-
-
Ich vermute jetzt einfach mal das du auf in einem Anderen Element oder Prozess eine Funktione aufrufen möchtest.
Daher musst du wahrscheinlich dem Element noch den Fokus geben bzw. dem Prozess den Fokus gebenThere is no CLOUD - just other people's computers
Q: Why do JAVA developers wear glasses?
A: Because they can't C#
Daily prayer:
"Dear Lord, grand me the strength not to kill any stupid people today and please grant me the ability to punch them in the face over standard TCP/IP." -
Wer soll die Taste senden, wer soll die Taste empfangen?
Welches Fenster hat definitiv den Fokus / nicht den Fokus?Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch
Ein guter .NET-Snippetkonverter (der ist verfügbar).
Programmierfragen über PN / Konversation werden ignoriert! -
-
-
-
-
-
Artentus schrieb:
Funktioniert es nicht oder weißt du nicht wie du es anwenden sollst?
Eigentlich beides -
-
-
Mit
SendKeys.SendWait("{ENTER}")
drückst du beispielsweise die Entertaste. Übersicht aller Tasten hier. -
Ich hab es mal über die Win-API versucht.
So sollte es gehen:
VB.NET-Quellcode
- Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
- Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Integer) As Integer
- Private Const KEYEVENTF_KEYUP As Short = &H2S
- Sub SetCaps(ByVal Status As Boolean)
- keybd_event(System.Windows.Forms.Keys.CapsLock, 0, 0, 0)
- keybd_event(System.Windows.Forms.Keys.CapsLock, 0, KEYEVENTF_KEYUP, 0)
- End Sub
- Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
- If CBool(GetKeyState(System.Windows.Forms.Keys.CapsLock)) = True Then
- SetCaps(False)
- Else
- SetCaps(True)
- End If
- End Sub
There is no CLOUD - just other people's computers
Q: Why do JAVA developers wear glasses?
A: Because they can't C#
Daily prayer:
"Dear Lord, grand me the strength not to kill any stupid people today and please grant me the ability to punch them in the face over standard TCP/IP." -
So (der code funktioniert vielen dank!!!) nun wollte ich noch die num taste drücken:
VB.NET-Quellcode
- Public Class Form1
- Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
- Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Integer) As Integer
- Private Const KEYEVENTF_KEYUP As Short = &H2S
- Sub SetCaps(ByVal Status As Boolean)
- keybd_event(System.Windows.Forms.Keys.CapsLock, 0, 0, 0)
- keybd_event(System.Windows.Forms.Keys.CapsLock, 0, KEYEVENTF_KEYUP, 0)
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- If CBool(GetKeyState(System.Windows.Forms.Keys.CapsLock)) = True Then
- SetCaps(False)
- Else
- SetCaps(True)
- End If
- End Sub
- Sub Setnum(ByVal Status As Boolean)
- keybd_event(System.Windows.Forms.Keys.NumLock, 0, 0, 0)
- keybd_event(System.Windows.Forms.Keys.NumLock, 0, KEYEVENTF_KEYUP, 0)
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- If CBool(GetKeyState(System.Windows.Forms.Keys.NumLock)) = True Then
- Setnum(False)
- Else
- Setnum(True)
- End If
- End Sub
- End Class
Aber wenn ich button 1 drücke werden num und capslock gedrückt und wenn ich button 2 drücke passiert nichts... Wo liegt der fehler?
Sorry habe denn fehler gefunden... Habe
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click statt
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click geschrieben -
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
...
End Sub
Benutze Button2.click im Handles sonst wird das nix
_________
Edit:
OK warst schnellerThere is no CLOUD - just other people's computers
Q: Why do JAVA developers wear glasses?
A: Because they can't C#
Daily prayer:
"Dear Lord, grand me the strength not to kill any stupid people today and please grant me the ability to punch them in the face over standard TCP/IP."
-
Ähnliche Themen
-
Im einem Spiel eine Taste drücken
Wild-Life78 - - Sonstige Problemstellungen -
lugge2 - - Sonstige Problemstellungen
-
Frasch - - Sonstige Problemstellungen
-
5 Benutzer haben hier geschrieben
- Gast (14)
- Artentus (7)
- Schamash (5)
- Niko Ortner (3)
- RodFromGermany (1)