|
-
January 14th, 2015, 04:12 PM
#1
Mouse Input Coordinates Not Being Read in C++
Please take a look the code below, its not the complete thing obviously since that'd be too long.
Essentially the problem is that when I click the mouse, the program doesn't seem to record the coordinates. So the if statements are never executed.
One thing I noticed was that when the do while loop is running and the left mouse button is not pressed then X and Y of dwMousePosition are both 0. But then if I press the left mouse button then the coordinates become x = 1 and y = 0.
Any help is appreciated
NOTE Im on Windows 7, 64 bit, using Visual Studio Express 2013 for Windows Desktop
Code:
#include <iostream>
#include <windows.h>
#include <string>
#include <new>
#include <stdio.h>
using namespace std;
INPUT_RECORD ir[128];
DWORD nRead;
COORD pos;
UINT z;
POINTER_INFO pointerInfo = {};
POINT p;
HANDLE hStdInput = GetStdHandle(STD_INPUT_HANDLE);
HANDLE hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
HANDLE handles[2] = { hEvent, hStdInput };
FlushConsoleInputBuffer(hStdInput);
do
{
Sleep(1);
if (!wait_for_up)
{
if ((GetKeyState(VK_LBUTTON) & 0x100) != 0)
{
ReadConsoleInput(hStdInput, ir, 128, &nRead);
pos.X = 0, pos.Y = 0;
SetConsoleCursorPosition(hStdOutput, pos);
if (*login == false)
{
if ((ir[z].Event.MouseEvent.dwMousePosition.Y) == 0)
{
*choice = 1;
finished = true;
}
if ((ir[z].Event.MouseEvent.dwMousePosition.Y) == 4)
{
*choice = 2;
finished = true;
}
}
}
}
} while (!finished);
cout << *choice;
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|