Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C# / VB.NET - Simulare pressione tasti
Forum - C# / VB.NET - Simulare pressione tasti

Avatar
cyber (Normal User)
Rookie


Messaggi: 51
Iscritto: 03/11/2006

Segnala al moderatore
Postato alle 14:53
Mercoledì, 18/07/2007
Io vorrei simulare la pressione di un tasto sulla tastiera l' "1" accanto a "\"..

Per quello che devo fare non funziona sendkeys e questa altro codice nemmeno. Devo simulare la pressione per qualsiasi programma proprio come se lo premessi.
Ho provato anche questo

Codice sorgente - presumibilmente VB.NET

  1. Imports System.Runtime.InteropServices
  2.  
  3. Public Class Form1
  4.  
  5.     <DllImport("user32.dll", CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Unicode, EntryPoint:="keybd_event", ExactSpelling:=True, SetLastError:=True)> Public Shared Sub keybd_event(ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
  6.     End Sub
  7.  
  8.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  9.         Const KEYEVENTF_KEYUP As Byte = &H2
  10.  
  11.         keybd_event(AscW(Chr(49)), 0, 0, 0)               ' Generates a KEY_DOWN
  12.         keybd_event(AscW(Chr(49)), 0, KEYEVENTF_KEYUP, 0) ' Generates a KEY_UP
  13.  
  14.     End Sub
  15.  
  16.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  17.  
  18.     End Sub
  19. End Class



Che altro posso fare?:D questo nn va per il programma che uso nn mi spinge "1"

Ultima modifica effettuata da cyber il 18/07/2007 alle 14:54
PM Quote
Avatar
Il Totem (Admin)
Guru^2


Messaggi: 3635
Iscritto: 24/01/2006

Segnala al moderatore
Postato alle 10:09
Giovedì, 19/07/2007
Perchè non provi ad usare keybd_event(asc("1"),0,0,0)?

PM Quote