Newsgroup: it.comp.programmare.win32
Titolo: Emulazione di mouse e tastiera

Dovrei creare un programma capace di emulare il movimento del mouse(click
compresi) e la tastiera in VB. Qualcuno puņ aiutarmi e magari postare un
listato?
Grazie

compresi) e la tastiera in VB.
Le API da utilizzare sono keybd_event() e mouse_event().
Entrambe sostituite da SendInput() sotto WinNT/2K.

Entrambe sostituite da SendInput() sotto WinNT/2K.
1- SendInput non mi risulta *esistere*. Vedo l'entry point in
   user32.dll, ma nel PSDK non risulta. Sarà che è vecchio, ma questo
   basta a dire che NT non lo supporta
2- Dall'help di mouse_event e keybd_event:
Windows NT      Yes
Windows 95      Yes
Win32s          No
Import library  user32.lib
Header file     winuser.h
Unicode         No
Platform notes  None
  Dato che non vedo la nota rossa "Now Supported on Windows NT" sono
  tentato di supporre che entrambi si trovino lì disponibili sin da
  Windows NT 3.1
-- 
Nato nel vizio, morto nel supplizio
Nato nel peccato, ad entrare sia invitato

1- SendInput non mi risulta *esistere*.
Tratto da MSDN (informati):
-----------------------------
Mouse_Event
The mouse_event function synthesizes mouse motion and button
clicks. 
Windows NT/2000: This function has been superseded. Use
SendInput instead.
-----------------------------
keybd_event
The keybd_event function synthesizes a keystroke. The system
can use such a synthesized keystroke to generate a WM_KEYUP
or WM_KEYDOWN message. The keyboard driver's interrupt
handler calls the keybd_event function. 
Windows NT/2000: This function has been superseded. Use
SendInput instead
-----------------------------
SendInput
The SendInput function synthesizes keystrokes, mouse
motions, and button clicks.
UINT SendInput(
  UINT nInputs,     // count of input events
  LPINPUT pInputs,  // array of input events to insert
  int cbSize        // size of structure
);
 
Parameters
nInputs 
Specifies the number of structures in the pInputs array. 
pInputs 
Pointer to an array of INPUT structures. Each structure
represents an event to be inserted into the keyboard or
mouse input stream. 
cbSize 
Specifies the size of an INPUT structure. If cbSize is not
the size of an INPUT structure, the function will fail. 
Return Values
The function returns the number of events that it
successfully inserted into the keyboard or mouse input
stream. If the function returns zero, the input was already
blocked by another thread.
To get extended error information, call GetLastError. 
Remarks
The SendInput function inserts the events in the INPUT
structures serially into the keyboard or mouse input stream.
These events aren't interspersed with other keyboard or
mouse input events inserted either by the user (with the
keyboard or mouse) or by calls to keybd_event, mouse_event,
or other calls to SendInput.
This function does not reset the keyboard's current state.
Any keys that are already pressed when the function is
called might interfere with the events that this function
generates. To avoid this problem, check the keyboard's state
with the GetAsyncKeyState function and correct as necessary.
QuickInfo 
  Windows NT/2000: Requires Windows NT 4.0 SP3 or later.
  Windows 95/98: Requires Windows 98.
  Windows CE: Requires version 2.0 or later.
  Header: Declared in winuser.h.
  Import Library: Use user32.lib.