Click here to Skip to main content
15,901,373 members
Home / Discussions / C#
   

C#

 
GeneralSendInput C# example Pin
Bog19-Oct-02 8:58
Bog19-Oct-02 8:58 
GeneralRe: SendInput C# example Pin
Stephane Rodriguez.19-Oct-02 9:34
Stephane Rodriguez.19-Oct-02 9:34 
GeneralRe: SendInput C# example Pin
Bog20-Oct-02 13:29
Bog20-Oct-02 13:29 
I saw that google link, and I've been working on it, but I still can't get it to work. I've reached the point where it neither throws errors, nor works.

My definitions are like this:
<br />
[System.Runtime.InteropServices.DllImportAttribute("user32.dll")]<br />
private static extern uint SendInput(<br />
	uint nInputs,     // count of input events<br />
	INPUT[] pInputs,  // array of input events<br />
	int cbSize        // size of structure<br />
);<br />
<br />
public struct INPUT {<br />
  public int type;<br />
  public short wVk;<br />
  public short wScan;<br />
  public int dwFlags;<br />
  public int time;<br />
  public UIntPtr dwExtraInfo;<br />
  private int _pad0, _pad1;<br />
}<br />
<br />
I call it like this:<br />
<br />
INPUT[] ipar=new INPUT[1];<br />
INPUT m=new INPUT();<br />
ipar[0]=m;<br />
m.type= 1; //this is INPUT_KEYBOARD<br />
m.wVk= 0x41;  //this is VK_A<br />
m.wScan= 0; <br />
m.dwFlags=0;<br />
m.time=0;<br />
uint u=0;<br />
m.dwExtraInfo=(System.UIntPtr)u;<br />
tbx.Focus(); //tbx is a TextBox I created. <br />
uint ui=SendInput(1,ipar,System.Runtime.InteropServices.Marshal.SizeOf(m));<br />
<br />


the result is that ui = 1. But the Textbox stays empty.

I also tried it by doing the union inside the INPUT and making structs for hardware and mouse input, and I got that to the same point, where ui=1 but the textbox stays empty. This always what happens to me with com interop I get to the point where there's no errors but doesn't work.




"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
GeneralRe: SendInput C# example Pin
leppie20-Oct-02 13:59
leppie20-Oct-02 13:59 
GeneralRe: SendInput C# example Pin
Bog20-Oct-02 14:10
Bog20-Oct-02 14:10 
GeneralRe: SendInput C# example Pin
leppie20-Oct-02 14:24
leppie20-Oct-02 14:24 
GeneralRe: SendInput C# example Pin
Bog20-Oct-02 14:51
Bog20-Oct-02 14:51 
Generalparsing HTML Pin
Jeremy Pullicino19-Oct-02 8:07
Jeremy Pullicino19-Oct-02 8:07 
GeneralRe: parsing HTML Pin
Stephane Rodriguez.19-Oct-02 9:28
Stephane Rodriguez.19-Oct-02 9:28 
GeneralRe: parsing HTML Pin
Jeremy Pullicino19-Oct-02 12:41
Jeremy Pullicino19-Oct-02 12:41 
Questionhow to release the COM server? Pin
CherezZaboro19-Oct-02 8:01
CherezZaboro19-Oct-02 8:01 
AnswerRe: how to release the COM server? Pin
Stephane Rodriguez.19-Oct-02 9:37
Stephane Rodriguez.19-Oct-02 9:37 
GeneralRe: how to release the COM server? Pin
CherezZaboro19-Oct-02 9:46
CherezZaboro19-Oct-02 9:46 
GeneralRe: how to release the COM server? Pin
CherezZaboro19-Oct-02 10:33
CherezZaboro19-Oct-02 10:33 
GeneralRe: how to release the COM server? Pin
Stephane Rodriguez.19-Oct-02 10:40
Stephane Rodriguez.19-Oct-02 10:40 
GeneralRe: how to release the COM server? Pin
CherezZaboro19-Oct-02 10:45
CherezZaboro19-Oct-02 10:45 
GeneralRe: how to release the COM server? Pin
Stephane Rodriguez.19-Oct-02 21:01
Stephane Rodriguez.19-Oct-02 21:01 
Generalcall a .Net exe from COM client Pin
Anonymous19-Oct-02 4:30
Anonymous19-Oct-02 4:30 
GeneralRe: call a .Net exe from COM client Pin
Stephane Rodriguez.19-Oct-02 5:23
Stephane Rodriguez.19-Oct-02 5:23 
GeneralRe: call a .Net exe from COM client Pin
Anonymous19-Oct-02 7:28
Anonymous19-Oct-02 7:28 
GeneralRe: call a .Net exe from COM client Pin
Stephane Rodriguez.19-Oct-02 7:34
Stephane Rodriguez.19-Oct-02 7:34 
GeneralFonts Pin
Substitute19-Oct-02 0:45
Substitute19-Oct-02 0:45 
GeneralRe: Fonts Pin
Nick Parker19-Oct-02 1:40
protectorNick Parker19-Oct-02 1:40 
GeneralRe: Fonts Pin
Substitute19-Oct-02 3:25
Substitute19-Oct-02 3:25 
GeneralManipulate Access DB Pin
Venet18-Oct-02 23:27
Venet18-Oct-02 23:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.