C# WinForm - Keyboard keys for mouse clicks outside Winform -


currently i'm trying make application simplifies commonly used action have do. want move mouse specific location on screen (manually) , press 1, 2, 3 x amount of times. keys 1, 2, 3 should following actions:

1 (d1) = right mouse button click.
2 (d2) = move mouses current y-axis 37 px downwards.
3 (d3) = left mouse button click.

with code below kind of behaviour doesn't work outside winform.

    [dllimport("user32.dll")]     public static extern void mouse_event(int dwflags, int dx, int dy, int cbuttons, int dwextrainfo);      public const int mouseeventf_leftdown = 0x02;     public const int mouseeventf_leftup = 0x04;     public const int mouseeventf_rightdown = 0x08;     public const int mouseeventf_rightup = 0x10;      private void main_keydown(object sender, keyeventargs e)     {         this._x = cursor.position.x;         this._y = cursor.position.y;          if (e.keycode == keys.d1)             mouse_event(mouseeventf_rightdown, this._x, this._y, 0, 0);         if (e.keycode == keys.d2)         {             this.cursor = new cursor(cursor.current.handle);             cursor.position = new point(this._x, this._y + 37);             cursor.clip = new rectangle(this.location, this.size);         }         if (e.keycode == keys.d3)             mouse_event(mouseeventf_leftdown, this._x, this._y, 0, 0);     } 

is there send me in right direction on performing this?


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -