void RightClick(int x,int y)
{
	//ÓÒ¼üµ¥»÷
	SetCursorPos(x,y);
	mouse_event(MOUSEEVENTF_RIGHTDOWN,x,y,0,0);
	mouse_event(MOUSEEVENTF_RIGHTUP,x,y,0,0);
}
Example #2
1
// http://forum.cockos.com/showthread.php?p=612065
void SimulateMouseClick(COMMAND_T* _ct)
{
    POINT p;
    GetCursorPos(&p);
    mouse_event(MOUSEEVENTF_LEFTDOWN, p.x, p.y, 0, 0);
    mouse_event(MOUSEEVENTF_LEFTUP, p.x, p.y, 0, 0);
    WinWaitForEvent(WM_LBUTTONUP);
}
Example #3
0
void MoveButton()
{
	if(movebutton == 1)
	{
		keybd_event(49, 0,0,0);
		keybd_event(49, 0,KEYEVENTF_KEYUP,0);
	}
	else if(movebutton == 2)
	{
		keybd_event(50, 0,0,0);
		keybd_event(50, 0,KEYEVENTF_KEYUP,0);
	}
	else if(movebutton == 3)
	{
		keybd_event(51, 0,0,0);
		keybd_event(51, 0,KEYEVENTF_KEYUP,0);
	} 
	else if(movebutton == 4)
	{
		keybd_event(52, 0,0,0);
		keybd_event(52, 0,KEYEVENTF_KEYUP,0);
	}
	else if(movebutton == 5)
	{
		mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); // нажали левую кнопку мыши
		mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); // отпустили левую кнопку мыши ( Ќ≈ «јЅџ¬ј“№ )
	}
	else if(movebutton == 6)
	{
		mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0); // нажали левую кнопку мыши
		mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0); // отпустили левую кнопку мыши ( Ќ≈ «јЅџ¬ј“№ )
	}
}
Example #4
0
void BotClickFollowArea()
{


    //—юды

	int ypos = 0;
	int xpos = 1;

	generator.seed(std::time(0)); // seed with the current time 

	NumberDistribution distributiony(-50, 50);
	Generator numberGeneratory(generator, distributiony); 
	int randomy = numberGeneratory();

	NumberDistribution distributionx(-30, 30);
	Generator numberGeneratorx(generator, distributionx); 
	int randomx = numberGeneratorx();

	NumberDistribution distributionsleep(-280, 100);
	Generator numberGeneratorSleep(generator, distributionsleep); 
	int randomsleep = numberGeneratorSleep();

	if(ypos + randomy > 680)
	{
		randomy = 0;
	}

	SetCursorPosition(xpos + randomx, ypos + randomy);
	mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); // нажали левую кнопку мыши
	mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); // отпустили левую кнопку мыши ( Ќ≈ «јЅџ¬ј“№ )
	BotSleep(0,0,0,0,0,0,0,0,0,0,0,0,300 + randomsleep);
}
DWORD WINAPI WorkThread(LPVOID lpParameter)
{
	WorkParam *wParam = (WorkParam *)lpParameter;
	HWND hWnd = FindWindow("Bison_Click", NULL);
	unsigned long TempTimes = 1;
	if (wParam->MouseFlag == 0){
		while (true)
		{
			mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, NULL, NULL);			
			if (TempTimes == wParam->ClickTimes){
				::PostMessage(hWnd, WM_STOP_CLICK, NULL, NULL); break;
			}
			Sleep(wParam->ClickInterval);
			TempTimes+=wParam->HaveTimes;
		}
	}
	else if (wParam->MouseFlag == 1)
	{
		while (true)
		{
			mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, NULL, NULL);
			if (TempTimes == wParam->ClickTimes){
				::PostMessage(hWnd, WM_STOP_CLICK, NULL, NULL); break;
			}
			Sleep(wParam->ClickInterval);
			TempTimes += wParam->HaveTimes;
		}
	}
	return 0;
}
Example #6
0
DWORD WINAPI BotThread(LPVOID param)
{
	while (true) {
		mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0x1337);
		// Sleep(100); // ensure that this finishes; use alternate method (might not be nec)
		for (int i=0; i < 10; i++) {
			//mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0x1337);
			Sleep(10);
			//mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0x1337);
			if (quitLoop)
				break;
		}
		mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0x1337);

		/*
		keybd_event(0x41, MapVirtualKey(0x41, 0), 0, 0); // A key
		Sleep(40);
		keybd_event(0x41, MapVirtualKey(0x41, 0), KEYEVENTF_KEYUP, 0);
		keybd_event(0x44, MapVirtualKey(0x44, 0), 0, 0); // D key
		Sleep(40);
		keybd_event(0x44, MapVirtualKey(0x44, 0), KEYEVENTF_KEYUP, 0);
		*/

		// Use W and S   seems to be better
		
		keybd_event(0x57, MapVirtualKey(0x57, 0), 0, 0); // W key
		Sleep(40);
		keybd_event(0x57, MapVirtualKey(0x57, 0), KEYEVENTF_KEYUP, 0);
		keybd_event(0x53, MapVirtualKey(0x53, 0), 0, 0); // S key
		Sleep(40);
		keybd_event(0x53, MapVirtualKey(0x53, 0), KEYEVENTF_KEYUP, 0);
		
	}
	return 0;
}
Example #7
0
static void __fastcall KillDialog(HWND hh) {
//-------------------------------------------------------------------------------
//          Убивает диалоговое окно автокада - с целью его продвижения          |
//-------------------------------------------------------------------------------
//    DestroyWindow(hh);

//    DWORD CurId, DlgId;
//    CurId = ::GetCurrentThreadId();
//    DlgId = ::GetWindowThreadProcessId(hh, NULL);
//    ::AttachThreadInput(CurId, DlgId, TRUE);
//    ::SetFocus(hh);

    RECT wr;
    int x, y;

    ::GetWindowRect(hh, &wr);
    x = (wr.left + wr.right) / 2; y = wr.top + 5;
    ::SetCursorPos(x, y);
    mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); aWait(20);
    mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); aWait(20);

    aWait(100);
    if (SpecCatcherMode) {
        keybd_event(VK_RETURN, 0, 0, 0); aWait(30);
        keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0); aWait(30);
    } else {
        keybd_event(VK_ESCAPE, 0, 0, 0); aWait(30);
        keybd_event(VK_ESCAPE, 0, KEYEVENTF_KEYUP, 0); aWait(30);
    }
}
bool	Win32Explorer::generateClickEvent(short int buttonID)
{
    //     mouse_event(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE|MOUSEEVENTF_LEFTDOWN,x,y,0,0);
    switch (buttonID)
    {
    case LeftClick:
        mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
        mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
        break;
    case MiddleClick:
        mouse_event(MOUSEEVENTF_MIDDLEDOWN,0,0,0,0);
        mouse_event(MOUSEEVENTF_MIDDLEUP,0,0,0,0);
        break;
    case RightClick:
        mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);
        mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);
        break;
    case LeftDbClick:
        mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
        mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
        mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
        mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
        break;
    default:
        break;
    }
    return (true);
}
void LeftClick(int x,int y)
{
	//×ó¼üµ¥»÷
	SetCursorPos(x,y);
	mouse_event(MOUSEEVENTF_LEFTDOWN,x,y,0,0);
	mouse_event(MOUSEEVENTF_LEFTUP,x,y,0,0);
}
Example #10
0
void startGame()
{
	//获取游戏窗口句柄
	gameh=::FindWindowA(NULL,g_ChessInfo.caption);
	::GetWindowRect(gameh,&r1); 
 
	//保存当前鼠标指针
	//取得当前鼠标位置
	GetCursorPos(&p);
	
	//设置鼠标指针位置  取开局所在坐标:x=655;y=577 //lparam 0x0241028f
	SetCursorPos(g_ChessInfo.start_xoffset + r1.left, g_ChessInfo.start_yoffset + r1.top);
	
	//模拟鼠标的 单击(鼠标按下/鼠标抬起)
	//MOUSEEVENTF_LEFTDOWN Specifies that the left button is down. 
    //MOUSEEVENTF_LEFTUP 
	//鼠标在当前位置按下
	mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
	mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
	
	//鼠标在当前位置抬起
	mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
	
	//还原鼠标位置
	Sleep(200);//过一段时间 再执行后边的代码
    SetCursorPos(p.x,p.y);
}
// Called whenever user presses a keyboard key.
// Checks whether poe is running, if so checks item on hotkey pressed and evaluates it.
LRESULT CALLBACK LowLevelKeyboardProc( int nCode, WPARAM wParam, LPARAM lParam ){
	char pressedKey;
	// Declare a pointer to the KBDLLHOOKSTRUCTdsad
	KBDLLHOOKSTRUCT *pKeyBoard = (KBDLLHOOKSTRUCT *)lParam;
	switch( wParam )
	{
	case WM_KEYDOWN: // When the key has been pressed down
		{
		//get the key code
		pressedKey = (char)pKeyBoard->vkCode;
		if ((pressedKey == -94) || (pressedKey == -93)){	//Ctrl
			CtrlPressed = TRUE;
		}
		}
		break;
	case WM_KEYUP: 
       {
		//get the key code
        pressedKey = (char)pKeyBoard->vkCode;
		if ((pressedKey == -94) || (pressedKey == -93)){	//Ctrl
			CtrlPressed = FALSE;
		}else if (pressedKey == 68){	//d){
			if (CtrlPressed && IsPoEActive()){
				POINT p;
				GetCursorPos(&p);
				//Copy item to clipboard
				ItemToClipboard();
				//Read from Clipboard
				Sleep(5);
				HANDLE h;
				if (!OpenClipboard(NULL)){
					return CallNextHookEx( NULL, nCode, wParam, lParam);
				}
				h = GetClipboardData(CF_TEXT);
				const char* output = evaluateItem((char*)h);
				const size_t len = strlen(output) + 1;
				HGLOBAL hMem =  GlobalAlloc(GMEM_MOVEABLE, len);
				memcpy(GlobalLock(hMem), output, len);
				GlobalUnlock(hMem);
				EmptyClipboard();
				SetClipboardData(CF_TEXT, hMem);
				CloseClipboard();
				if (len > 1) {
					PressKeyboardKey(VK_RETURN);
					PressKeyboardKey(65);	//ctrl+a
					PressKeyboardKey(86);	//ctrl+v
					PressKeyboardKey(VK_RETURN);
				}else if (UseDoubleclick){
					mouse_event(MOUSEEVENTF_LEFTDOWN, p.x, p.y, 0, 0);
					mouse_event(MOUSEEVENTF_LEFTUP, p.x, p.y, 0, 0);
				}
			}
		}
		}
		break;
	}
    //
	return CallNextHookEx( NULL, nCode, wParam, lParam);
}
Example #12
0
void BotFollowFlag()
{

	srand ( time(NULL) );
	int followflagtype = rand() % 4 + 1;
	
	if(StartLevel == 0)
	{
		if(followflagtype == 1)
		{
			SetCursorPosition(rx + 20,ry + 20);
		}
		else if(followflagtype == 2)
		{
			SetCursorPosition(rx - 20,ry + 20);
		}
		else if(followflagtype == 3)
		{
			SetCursorPosition(rx - 20,ry - 20);
		}
		else if(followflagtype == 4)
		{
			SetCursorPosition(rx + 20,ry - 20);
		}
	}
	else
	{
		if(followflagtype == 1)
		{
			SetCursorPosition(367,228);
		}
		else if(followflagtype == 2)
		{
			SetCursorPosition(649,253);
		}
		else if(followflagtype == 3)
		{
			SetCursorPosition(346,450);
		}
		else if(followflagtype == 4)
		{
			SetCursorPosition(674,451);
		}
	}

	BotSleep(0,0,0,0,0,0,0,0,0,0,0,0,800);
	CaptureScreen(&globalscreengrab);

	if(BotGetFlagStatus(&globalscreengrab) == 1)
	{
		StartLevel = 0;
		mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); // нажали левую кнопку мыши
		mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); // отпустили левую кнопку мыши ( Ќ≈ «јЅџ¬ј“№ )
		BotSleep(1,0,0,0,0,0,0,0,0,0,0,0,1000);
	}
}
Example #13
0
static void do_click(HWND window, DWORD down, DWORD up)
{
    WINDOWINFO window_info;
    long x, y;

    SetForegroundWindow(GetParent(window));
    window_info.cbSize=sizeof(window_info);
    GetWindowInfo(window, &window_info);

    /* The calculations below convert the coordinates so they are absolute
     * screen coordinates in 'Mickeys' as required by mouse_event.
     * In mickeys the screen size is always 65535x65535.
     */
    x=window_info.rcWindow.left+g_x;
    if (x<window_info.rcWindow.left || x>=window_info.rcWindow.right)
        x=(window_info.rcWindow.right+window_info.rcWindow.left)/2;
    x=(x << 16)/GetSystemMetrics(SM_CXSCREEN);

    y=window_info.rcWindow.top+g_y;
    if (y<window_info.rcWindow.top || y>=window_info.rcWindow.bottom)
        y=(window_info.rcWindow.bottom+window_info.rcWindow.top)/2;
    y=(y << 16)/GetSystemMetrics(SM_CYSCREEN);

    mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, x, y, 0, 0);
    if (down) {
        mouse_event(MOUSEEVENTF_ABSOLUTE | down, x, y, 0, 0);
        if ((g_dragto_x > 0) && (g_dragto_y > 0)) {
            int i;
            long dx, dy;
            long step_per_x, step_per_y;
            long dragto_x, dragto_y;

            dragto_x=window_info.rcWindow.left+g_dragto_x;
            if (dragto_x<window_info.rcWindow.left || dragto_x>=window_info.rcWindow.right)
                dragto_x=(window_info.rcWindow.right+window_info.rcWindow.left)/2;
            dragto_x=(dragto_x << 16)/GetSystemMetrics(SM_CXSCREEN);

            dragto_y=window_info.rcWindow.top+g_dragto_y;
            if (dragto_y<window_info.rcWindow.top || dragto_y>=window_info.rcWindow.bottom)
                dragto_y=(window_info.rcWindow.bottom+window_info.rcWindow.top)/2;
            dragto_y=(dragto_y << 16)/GetSystemMetrics(SM_CYSCREEN);

            dx = g_dragto_x - g_x;
            dy = g_dragto_y - g_y;
            step_per_x = dx / 4;
            step_per_y = dy / 4;
            for (i = 0; i < 4; i++) {
                mouse_event(MOUSEEVENTF_MOVE, step_per_x, step_per_y, 0, 0);
            }
            x=dragto_x;
            y=dragto_y;
        }
    }
    if (up)
       mouse_event(MOUSEEVENTF_ABSOLUTE | up, x, y, 0, 0);
}
/***************************************************************************************************\
*	‘унка ClickLBM; 
*	кликаем по заданной области в окне (1 раз); 
*	¬ход:
*		hWnd		-	хэндл окна, по области которого будем кликать мышкой;  
*		x			-	x-координата дл¤ щелчка (экранна¤);
*		y			-	y-координата дл¤ щелчка (экранна¤); 
*	¬ыход:
*		(+)
\***************************************************************************************************/
void ClickLBM(HWND hWnd, int x, int y)
{
	POINT pt;
	
	GetCursorPos(&pt);	//получаем позицию курсора в экранных координатах; 
	SetCursorPos(x, y);	//ставим мышь в нужную позицию
	mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);	//нажимаем левую кнопку мыши по заданным координатам; 
	mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);	//отпускаем левую кнопку мыши 
	SetCursorPos(pt.x, pt.y);	//ставим мышь обратно на место; 
}
Example #15
0
static void test_device_input(IDirectInputDevice8A *lpdid, DWORD event_type, DWORD event, DWORD expected)
{
    HRESULT hr;
    DIDEVICEOBJECTDATA obj_data;
    DWORD data_size = 1;
    int i;

    hr = IDirectInputDevice8_Acquire(lpdid);
    ok (SUCCEEDED(hr), "Failed to acquire device hr=%08x\n", hr);

    if (event_type == INPUT_KEYBOARD)
        keybd_event( event, DIK_SPACE, 0, 0);

    if (event_type == INPUT_MOUSE)
        mouse_event( event, 0, 0, 0, 0);

    flush_events();
    IDirectInputDevice8_Poll(lpdid);
    hr = IDirectInputDevice8_GetDeviceData(lpdid, sizeof(obj_data), &obj_data, &data_size, 0);

    if (data_size != 1)
    {
        win_skip("We're not able to inject input into Windows dinput8 with events\n");
        IDirectInputDevice_Unacquire(lpdid);
        return;
    }

    ok (obj_data.uAppData == expected, "Retrieval of action failed uAppData=%lu expected=%d\n", obj_data.uAppData, expected);

    /* Check for buffer owerflow */
    for (i = 0; i < 17; i++)
        if (event_type == INPUT_KEYBOARD)
        {
            keybd_event( VK_SPACE, DIK_SPACE, 0, 0);
            keybd_event( VK_SPACE, DIK_SPACE, KEYEVENTF_KEYUP, 0);
        }
        else if (event_type == INPUT_MOUSE)
        {
            mouse_event(MOUSEEVENTF_LEFTDOWN, 1, 1, 0, 0);
            mouse_event(MOUSEEVENTF_LEFTUP, 1, 1, 0, 0);
        }

    flush_events();
    IDirectInputDevice8_Poll(lpdid);

    data_size = 1;
    hr = IDirectInputDevice8_GetDeviceData(lpdid, sizeof(obj_data), &obj_data, &data_size, 0);
    ok(hr == DI_BUFFEROVERFLOW, "GetDeviceData() failed: %08x\n", hr);
    data_size = 1;
    hr = IDirectInputDevice8_GetDeviceData(lpdid, sizeof(obj_data), &obj_data, &data_size, 0);
    ok(hr == DI_OK && data_size == 1, "GetDeviceData() failed: %08x cnt:%d\n", hr, data_size);

    IDirectInputDevice_Unacquire(lpdid);
}
void setMouse(intf x,intf y)
{	if (winVars.factive!=WA_ACTIVE) return;
	if (winVars.isWindowMode)	
		mouse_event( MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 
				 ((x+winVars.winPosX)*65536+32768)/desktopMetrics->width, ((y+winVars.winPosY)*65536+32768)/desktopMetrics->height,
				 0, GetMessageExtraInfo() );
	else
		mouse_event( MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 
				 ((x)*65536+32768)/screenWidth, ((y)*65536+32768)/screenHeight,
				 0, GetMessageExtraInfo() );

}
Example #17
0
	Bed_2D(wxWindow* parent) 
	{
		Create(parent, wxID_ANY, wxDefaultPosition, wxSize(250, -1), wxTAB_TRAVERSAL);
//		m_user_drawn_background = $^O ne 'darwin';
		m_user_drawn_background = true;
		Bind(wxEVT_PAINT, ([this](wxPaintEvent e) { repaint(); }));
//		EVT_ERASE_BACKGROUND($self, sub{}) if $self->{user_drawn_background};
//		Bind(EVT_MOUSE_EVENTS, ([this](wxMouseEvent  event){/*mouse_event()*/; }));
		Bind(wxEVT_LEFT_DOWN, ([this](wxMouseEvent  event){ mouse_event(event); }));
		Bind(wxEVT_MOTION, ([this](wxMouseEvent  event){ mouse_event(event); }));
		Bind(wxEVT_SIZE, ([this](wxSizeEvent e) { Refresh(); }));
	}
Example #18
0
void Window::iconActivated(QSystemTrayIcon::ActivationReason reason)
{
    switch(reason){
    case QSystemTrayIcon::Trigger:
#ifdef Q_OS_WIN
        mouse_event(MOUSEEVENTF_RIGHTDOWN,0, 0, 0, 0);
        mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
#endif
        break;
    default:
        ;
    }
}
void EmulMouse::LeftMouseClick(long _mouseX, long _mouseY)
{
	int screenX = GetSystemMetrics(SM_CXVIRTUALSCREEN);
	int screenY = GetSystemMetrics(SM_CYVIRTUALSCREEN);

	int propX = 65535 / screenX;
	int propY = 65535 / screenY;

	mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, propX * _mouseX, propY * _mouseY, 0, 0);

	mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE, propX * _mouseX, propY * _mouseY, 0, 0);
	mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE, propX * _mouseX, propY * _mouseY, 0, 0);
}
Example #20
0
void JMouseBtnObj::engine(int n, JLinkObj& link) {
  if (focusOn) return;
#if defined(WIN32)
  POINT pt;
  GetCursorPos(&pt);
  if (JComponent::getJComponent((int)WindowFromPoint(pt))) return;
  if (!n) {
    int click;
    link.access(JIntegerData(click));
    if (click && !state) {
      switch (type) {
        case LEFT:
          mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0L, 0L);
          mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0L, 0L);
	  break;
        case RIGHT:
          mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0L, 0L);
          mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0L, 0L);
	  break;
        case MIDDLE:
          mouse_event(MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0L, 0L);
          mouse_event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0L, 0L);
	  break;
      }
    }
  } else {
    int olds = state;
    link.access(JIntegerData(state));
    state = (state != 0) ? mask : 0;
    if (state != olds) {
      switch (type) {
        case LEFT:
          mouse_event(
	    (state) ? MOUSEEVENTF_LEFTDOWN : 
	    MOUSEEVENTF_LEFTUP, 
	    0, 0, 0L, 0L);
	  break;
        case RIGHT:
          mouse_event(
	    (state) ? MOUSEEVENTF_RIGHTDOWN : 
	    MOUSEEVENTF_RIGHTUP, 
	    0, 0, 0L, 0L);
	  break;
        case MIDDLE:
          mouse_event(
	    (state) ? MOUSEEVENTF_MIDDLEDOWN : 
	    MOUSEEVENTF_MIDDLEUP, 
	    0, 0, 0L, 0L);
	  break;
      }
    }
  }
#endif
}
Example #21
0
void XN_CALLBACK_TYPE Kinect::GestureRecognized( xn::GestureGenerator& generator,const XnChar* strGesture,
	const XnPoint3D* pIDPosition,const XnPoint3D* pEndPosition,void* pCookie )
{
	Kinect * kinect = ((Kinect *)pCookie);
	if( strcmp( strGesture, "Wave" ) == 0 )
	{
		mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
		mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
	}
	else if( strcmp( strGesture, "RaiseHand" ) == 0 )
	{
		generator.RemoveGesture(strGesture);
		kinect->m_HandsGenerator.StartTracking( *pEndPosition );
	}
}
Example #22
0
//处理热键消息
void dealWithHotKey( HWND hwnd, WPARAM wParam )
{
	POINT ptCorPos;
	GetCursorPos( &ptCorPos );

	switch( wParam )
	{
	case ID_HOT_UP:			ptCorPos.y -= 40;	break;			//移动, 上	
	case ID_HOT_DOWN:		ptCorPos.y += 40;	break;			//移动, 下
	case ID_HOT_LEFT:		ptCorPos.x -= 40;	break;			//移动, 左
	case ID_HOT_RIGHT:		ptCorPos.x += 40;	break;			//移动, 右
	case ID_HOT_SL_UP:		ptCorPos.y -= 10;	break;			//微调, 上
	case ID_HOT_SL_DOWN:	ptCorPos.y += 10;	break;			//微调, 下
	case ID_HOT_SL_LEFT:	ptCorPos.x -= 10;	break;			//微调, 左
	case ID_HOT_SL_RIGHT:	ptCorPos.x += 10;	break;			//微调, 右
		
	case ID_HOT_TOPLEFT:		//移动, 左上
		ptCorPos.x -= 40;	ptCorPos.y -= 40;	break;

	case ID_HOT_TOPRIGHT:		//移动, 右上
		ptCorPos.x += 40;	ptCorPos.y -= 40;	break;

	case ID_HOT_BOTLEFT:		//移动, 左下
		ptCorPos.x -= 40;	ptCorPos.y += 40;	break;

	case ID_HOT_BOTRIGHT:		//移动, 右下
		ptCorPos.x += 40;	ptCorPos.y += 40;	break;

	case ID_HOT_LEFT_CLICK:		//左击
		mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 );
		mouse_event( MOUSEEVENTF_LEFTUP,   0, 0, 0, 0 );
		break;

	case ID_HOT_RIGHT_CLICK:	//右击
		mouse_event( MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0 );
		mouse_event( MOUSEEVENTF_RIGHTUP,   0, 0, 0, 0 );
		break;

	case ID_HOT_MIDDLE_UP:		//滚轮向上
		mouse_event( MOUSEEVENTF_WHEEL, 0, 0, (DWORD)50, 0 );	break;

	case ID_HOT_MIDDLE_DOWN:	//滚轮向下
		mouse_event( MOUSEEVENTF_WHEEL, 0, 0, (DWORD)-50, 0 );	break;

	case ID_HOT_MIDDLE_PRESS:	//中键击键
		mouse_event( MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0 );
		mouse_event( MOUSEEVENTF_MIDDLEUP,   0, 0, 0, 0 );
		break;

	case ID_HOT_WND_HIDE:		//呼出主界面
		ShowWindow( hwnd, SW_SHOWNORMAL );
		SetForegroundWindow(hwnd);	break;

	case ID_HOT_PAUSE:			//暂停\继续热键
		SendMessage( hwnd, WM_COMMAND, ID_BTN_PAUSE | BN_CLICKED, 0 );	break;
	}
	SetCursorPos( ptCorPos.x, ptCorPos.y );
}
Example #23
0
LRESULT CALLBACK MouseHookLL (int nCode, WPARAM wParam, LPARAM lParam)
{
	if (nCode < 0 || (!isOn)) {
		return CallNextHookEx(0, nCode, wParam, lParam);
	} else {
		// check origin of click
		PMSLLHOOKSTRUCT hs = (PMSLLHOOKSTRUCT) lParam;
		if (hs->dwExtraInfo == 0x1337) // simulated, let pass
			return CallNextHookEx(0, nCode, wParam, lParam);

		// start/stop macro
		if (wParam == WM_LBUTTONDOWN) { // start
			quitLoop = false;
			ResumeThread(bot);
			return 1;
		} else if (wParam == WM_LBUTTONUP) { // stop
			quitLoop = true;
			Sleep(10);
			SuspendThread(bot);
			mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0x1337);
			//keybd_event(0x41, MapVirtualKey(0x41, 0), KEYEVENTF_KEYUP, 0);
			//keybd_event(0x44, MapVirtualKey(0x44, 0), KEYEVENTF_KEYUP, 0);
			keybd_event(0x57, MapVirtualKey(0x57, 0), KEYEVENTF_KEYUP, 0);
			keybd_event(0x53, MapVirtualKey(0x53, 0), KEYEVENTF_KEYUP, 0);
			return 1;
		} else {
			return CallNextHookEx(0, nCode, wParam, lParam);
		}
	}
}
Example #24
0
int SetMousPos(const CKBehaviorContext& behcontext)
{
	

	CKBehavior* beh = behcontext.Behavior;
  	CKContext* ctx = behcontext.Context;

	if( beh->IsInputActive(0) ){
		beh->ActivateInput(0,FALSE);

 DWORD data = 0;
 DWORD flags = MOUSEEVENTF_ABSOLUTE;
 
 // - Has the pointer moved since the last event?
 
 
 flags |= MOUSEEVENTF_MOVE;

 mouse_event(flags, 100,100, data, 0);
 

		beh->ActivateOutput(0);
	

	}

	return 0;

}
Example #25
0
bool
render_surface::on_button_release_event( GdkEventButton* event)
{
	python::gil_lock L;
	mouse_event( event, 1 << (event->button-1) );
	return true;
}
Example #26
0
bool
render_surface::on_motion_notify_event( GdkEventMotion* event)
{
	python::gil_lock L;
	mouse_event( event );
	return true;
}
Example #27
-1
void MouseDown(TMouseButton button)
{


#ifndef USESENDINPUT
	if(button==mbLeft)
	{
		mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
	}
	else
	if(button==mbRight)
	{
		mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);
	}
	else
	if(button==mbMiddle)
	{
		mouse_event(MOUSEEVENTF_MIDDLEDOWN,0,0,0,0);
	}
#else
	INPUT    input;
	::ZeroMemory(&input, sizeof(input));

	if(button==mbLeft)
	{
		if(IsKeyPressed(VK_LBUTTON)) return;

		input.type      = INPUT_MOUSE;
		input.mi.dwFlags  = MOUSEEVENTF_LEFTDOWN;
		::SendInput(1,&input,sizeof(INPUT));
	}
	else
	if(button==mbRight)
	{
		if(IsKeyPressed(VK_RBUTTON)) return;

		input.type      = INPUT_MOUSE;
		input.mi.dwFlags  = MOUSEEVENTF_RIGHTDOWN;
		::SendInput(1,&input,sizeof(INPUT));

	}
	else
	if(button==mbMiddle)
	{
		if(IsKeyPressed(VK_MBUTTON)) return;

		input.type      = INPUT_MOUSE;
		input.mi.dwFlags  = MOUSEEVENTF_MIDDLEDOWN;
		::SendInput(1,&input,sizeof(INPUT));

	}


#endif


//	if(sleepsec) Sleep(sleepsec);

}
Example #28
-1
int CautooDlg::domouseclick(int v_x, int v_y, int v_sleepms=0)
{
	SetCursorPos(v_x, v_y);
	mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
	mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
	Sleep(v_sleepms);
	return(TRUE);
}
Example #29
-1
	//Emulate a mouse click with given float delays
	void LibraryManager::mouse_click(float delay_before, float delay_between, float delay_after)
	{
		Sleep(delay_before);
		mouse_event(MOUSEEVENTF_LEFTDOWN,NULL,NULL,NULL,NULL);
		Sleep(delay_between);
		mouse_event(MOUSEEVENTF_LEFTUP,NULL,NULL,NULL,NULL);
		Sleep(delay_after);
	}
Example #30
-1
int m_exec(wchar_t* app, int param_count, wchar_t* param[]) 
{
	if (param_count <= 0) {
		return 0;
	} 

	bool valid = false;
	std::wstring action ;
	long x, y;
	std::wstring win_name;
	std::wstring btn_event;
	
	for (int i = 0; i < param_count; i++) {
		if (i == 1) {
			action = param[0];
		}
		else {
			if (action == L"m"
				|| action == L"to"
				) {
				wchar_t* end;
				x = std::wcstol(param[1], &end, 10);
				y = std::wcstol(param[2], &end, 10);
				if (param_count == 4) {
					btn_event = param[3];
				}
				break;
			}
			else if (action == L"w") {
				win_name = param[1];
				if (param_count == 3) {
					btn_event = param[2];
				}
				break;
			}
		}

	}

	if (action== L"m") {
		int ret = mouse_move(x, y);
		mouse_event(btn_event);
	} 
	else if (action == L"to") {
		int ret = mouse_move(x, y);
		mouse_event(btn_event);
	}
	else if (action == L"w") {
		int ret = mouse_to_window(win_name);
		mouse_event(btn_event);
	}
	else {
		print_usage(app);
	}

	
}