Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
Skip Navigation LinksHome » Code Library » Winapi

Public general use code classes and xml files that we've compiled and used over the years:

WINAPI click events support class.

   1:  #if WINDOWS_FORM
   2:  using System;
   3:  using System.Runtime.InteropServices;
   4:   
   5:  namespace Ia.Cl.Model
   6:  {
   7:      /// <summary publish="true">
   8:      /// WINAPI click events support class.
   9:      /// </summary>
  10:      /// <remarks> 
  11:      /// Copyright � 2001-2015 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  12:      ///
  13:      /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
  14:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  15:      ///
  16:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  17:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  18:      /// 
  19:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  20:      /// 
  21:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  22:      /// </remarks> 
  23:      public class Winapi
  24:      {
  25:          [DllImport("user32.dll")]
  26:          private static extern void mouse_event(UInt32 dwFlags, UInt32 dx, UInt32 dy, UInt32 dwData, IntPtr dwExtraInfo);
  27:   
  28:          //DWORD dwData; // amount of wheel movement
  29:   
  30:          private const UInt32 MouseEventLeftDown = 0x0002;
  31:          private const UInt32 MouseEventLeftUp = 0x0004;
  32:   
  33:          private const UInt32 MouseEventRightDown = 0x0008;
  34:          private const UInt32 MouseEventRightUp = 0x0010;
  35:   
  36:          private const UInt32 MouseEventWheelUp = 128;
  37:   
  38:          ////////////////////////////////////////////////////////////////////////////
  39:   
  40:          /// <summary>
  41:          ///
  42:          /// </summary>
  43:          public static void SendDoubleClick()
  44:          {
  45:              mouse_event(MouseEventLeftDown, 0, 0, 0, new System.IntPtr());
  46:              mouse_event(MouseEventLeftUp, 0, 0, 0, new System.IntPtr());
  47:              mouse_event(MouseEventLeftDown, 0, 0, 0, new System.IntPtr());
  48:              mouse_event(MouseEventLeftUp, 0, 0, 0, new System.IntPtr());
  49:          }
  50:   
  51:          ////////////////////////////////////////////////////////////////////////////
  52:   
  53:          /// <summary>
  54:          ///
  55:          /// </summary>
  56:          public static void SendRightClick()
  57:          {
  58:              mouse_event(MouseEventRightDown, 0, 0, 0, new System.IntPtr());
  59:              mouse_event(MouseEventRightUp, 0, 0, 0, new System.IntPtr());
  60:          }
  61:   
  62:          ////////////////////////////////////////////////////////////////////////////
  63:   
  64:          /// <summary>
  65:          ///
  66:          /// </summary>
  67:          public static void SendLeftClick()
  68:          {
  69:              mouse_event(MouseEventLeftDown, 0, 0, 0, new System.IntPtr());
  70:              mouse_event(MouseEventLeftUp, 0, 0, 0, new System.IntPtr());
  71:          }
  72:   
  73:          ////////////////////////////////////////////////////////////////////////////
  74:   
  75:          /// <summary>
  76:          ///
  77:          /// </summary>
  78:          public static void SendLeftDownClick()
  79:          {
  80:              mouse_event(MouseEventLeftDown, 0, 0, 0, new System.IntPtr());
  81:          }
  82:   
  83:          ////////////////////////////////////////////////////////////////////////////
  84:   
  85:          /// <summary>
  86:          ///
  87:          /// </summary>
  88:          public static void SendLeftUpClick()
  89:          {
  90:              mouse_event(MouseEventLeftUp, 0, 0, 0, new System.IntPtr());
  91:          }
  92:   
  93:          ////////////////////////////////////////////////////////////////////////////
  94:   
  95:          /// <summary>
  96:          ///
  97:          /// </summary>
  98:          public static void SendWheelUpClick()
  99:          {
 100:              mouse_event(MouseEventWheelUp, 0, 0, 1, new System.IntPtr());
 101:          }
 102:   
 103:          ////////////////////////////////////////////////////////////////////////////
 104:          ////////////////////////////////////////////////////////////////////////////
 105:      }
 106:  }
 107:  #endif