DllImport

DllImport

[DllImport( " user32.dll " , EntryPoint  =   " FindWindow " , SetLastError  =   true )]
private   static   extern  IntPtr FindWindow( string  lpClassName,  string  lpWindowName);

 

[DllImport(
" user32.dll " )]
private   static   extern   bool  SetForegroundWindow(IntPtr hWnd);

 

[DllImport(
" user32.dll " )]
private   static   extern   bool  SetCursorPos( int  X,  int  Y);


[DllImport(
" user32.dll " , EntryPoint  =   " mouse_event " )]
private   static   extern   int  mouse_event( int  dwFlags,  int  dx,  int  dy,  int  cButtons,  int  dwExtraInfo);

 

[DllImport(
" user32.dll " , EntryPoint  =   " ShowWindow " , SetLastError  =   true )]
private   static   extern   bool  ShowWindow(IntPtr hWnd,  uint  nCmdShow);

 

IntPtr hwnd 
=  FindWindow( null " Microsoft Excel " );
ShowWindow(hwnd, 
3 );
SetForegroundWindow(hwnd);
SetCursorPos(
500 300 );
mouse_event(
6 0 0 0 0 );

 

 

你可能感兴趣的:(import)