HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Programming/Scripts (http://www.howtoforge.com/forums/forumdisplay.php?f=7)
-   -   Handling keyboard and mouse with C# (http://www.howtoforge.com/forums/showthread.php?t=4991)

ColdDoT 18th June 2006 13:46

Handling keyboard and mouse with C#
 
Hello

i really wanna send key strokes to a programm. So i've used the C# send command for keystorkes. But the programm that i wanna send the keystrokes to is heavely garded.

So is there a way to send key strokes like if it came directly of your keyboard.

and for the mouse is the same way does some 1 has a function like
mouse(X,Y);
and then you can use
(then it clicks where you sets the mouse first, on the X and Y)
mouse_click("LEFT");
or
mouse_click("D_LEFT"); <--duble click

thx in advice

greets ColdDoT
the programm where i wanna send to is called MapleStory global.
site = www.mapleglobal.com
Protection by GameGuard nProtect <- REV 770

sbovisjb1 4th July 2006 06:22

Sorry for bringing this up

This is C++, i do not recall the quick way of doing this in C#, sorry. Here is the original forum topic, i just pieced together this
http://www.criticalsecurity.net/inde...howtopic=13336

Code:

#include <windows.h>
#include <iostream>

#define _WIN32_WINNT 0x0500

int main()
{
  hide();
  GetAsyncKeyState(VK_LMENU);
    std::cin.get();
    return 0; 
}

void hide()
{
    HWND h;
   
    AllocConsole();
   
    h = FindWindowA("ConsoleWindowClass", NULL);
   
    ShowWindow(h, 0);
}


sebart7 14th August 2006 03:23

mouse_event, keybd_event, SetCursorPos
 
Not really.
GetAsyncKeyState is to check if certain key is pressed.

----------------------------------------------------------------------
example in assembly (masm32) to push space bar

FUNCTION

VOID keybd_event(
BYTE bVk, // virtual-key code
BYTE bScan, // hardware scan code
DWORD dwFlags, // flags specifying various function options
DWORD dwExtraInfo // additional data associated with keystroke
);


EXAMPLE PRESS SPACE BAR

invoke keybd_event,VK_SPACE,0,0,0 ; key down
invoke Sleep,50 ; wait a moment
invoke keybd_event,VK_SPACE,0,KEYEVENTF_KEYUP,0 ; key up

to push other keys use VK_A for "a" key VK_1 for "1" ect

----------------------------------------------------------------------
example in assembly (masm32) to push mouse key

FUNCTION

VOID mouse_event(
DWORD dwFlags, // flags specifying various motion/click variants
DWORD dx, // horizontal mouse position or position change
DWORD dy, // vertical mouse position or position change
DWORD dwData, // amount of wheel movement
DWORD dwExtraInfo // 32 bits of application-defined information
);


EXAMPLE PRESS LEFT MOUSE KEY

invoke mouse_event,MOUSEEVENTF_LEFTDOWN ,0,0,0,0 ; key down
invoke Sleep,50 ; wait a moment
invoke mouse_event,MOUSEEVENTF_LEFTUP,0,0,0,0 ; key up

Remark Touse dx and dy set flag as MOUSEEVENTF_MOVE MOUSEEVENTF_ABSOLUTE

invoke mouse_event,MOUSEEVENTF_LEFTDOWN or MOUSEEVENTF_MOVE or MOUSEEVENTF_ABSOLUTE,1000,1000,0,0 ; key down and move to 1000,1000

----------------------------------------------------------------------
example in assembly (masm32) to set mouse in x y position

FUNCTION

BOOL SetCursorPos(
int X, // horizontal position
int Y // vertical position
);


EXAMPLE

invoke SetCursorPos,100,100 ; set mouse pos to 100,100





You may be interested to check details for functions mentioned above.
Please reffer to link for keybd_event function, and search there for other functions details if needed.


All times are GMT +2. The time now is 07:48.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.