Poker-AI.org Poker AI and Botting Discussion Forum 2016-12-09T09:21:54+00:00 http://poker-ai.org/phpbb/feed.php?f=22&t=3002 2016-12-09T09:21:54+00:00 2016-12-09T09:21:54+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=3002&p=7046#p7046 <![CDATA[Simulating mouseclick in the PokerStars UI]]>
Just trying to get a simple command working.
I've tried mouse_event, SendInput, and strangely even SetCursorPos doesn't work. If I grab the window Rect before I focus, I can set the mouse, but if I Activate the window, it won't work.

// PokerMoneyC.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


void LeftClick();

// Forward declaration of the MouseMove function
void MouseMove(int x, int y);

int main()
{
//MouseMove(100, 100);
//LeftClick();
HWND hWnd = FindWindow(NULL, L"PokerStars Lobby");
RECT r;
GetWindowRect(hWnd, &r);
SetCursorPos(r.left + 880, r.top + 70);


SetForegroundWindow(hWnd);
Sleep(1000);
//LeftClick();

//for (int x = 20; x < 880; ++x)
//{
//Sleep(2);
//SetCursorPos(r.left + x, r.top + 70);
//}

mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
Sleep(200);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);

return 0;
}

// LeftClick function
void LeftClick()
{
INPUT Input = { 0 };
// left down
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
::SendInput(1, &Input, sizeof(INPUT));

// left up
::ZeroMemory(&Input, sizeof(INPUT));
Input.type = INPUT_MOUSE;
Sleep(200);
Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
::SendInput(1, &Input, sizeof(INPUT));
}

// MouseMove function
void MouseMove(int x, int y)
{
double fScreenWidth = ::GetSystemMetrics(SM_CXSCREEN) - 1;
double fScreenHeight = ::GetSystemMetrics(SM_CYSCREEN) - 1;
double fx = x*(65535.0f / fScreenWidth);
double fy = y*(65535.0f / fScreenHeight);
INPUT Input = { 0 };
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
Input.mi.dx = fx;
Input.mi.dy = fy;
::SendInput(1, &Input, sizeof(INPUT));
}

Statistics: Posted by bluebaron — Fri Dec 09, 2016 9:21 am


]]>