Poker-AI.org

Poker AI and Botting Discussion Forum
It is currently Mon Nov 13, 2023 12:13 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Fri Dec 09, 2016 9:21 am 
Offline
New Member

Joined: Fri Dec 09, 2016 9:16 am
Posts: 1
Sorry if this is not the appropriate venue for this. I was wondering if PokerStars is somehow blocking winapi stuff.

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));
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group