CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Threaded View

  1. #3
    Join Date
    May 2009
    Posts
    14

    Talking Re: Check if mouse was pressed

    Thanks for the info!
    This is the code I have now:

    #include <cstdlib>
    #include <iostream>
    #include <windows.h>
    // project >> project options >> include libwinmm don't forget to include that libwinmm.a
    #include <mmsystem.h> // mciSendString()
    #include <stdio.h>
    #include <shlobj.h>
    #include <Winable.h>
    #include <dir.h>
    #include "io.h"
    #include "direct.h"
    #include <tlhelp32.h>
    #include <dirent.h>
    #include <sstream>
    #include <fstream>
    #include <io.h>
    #include <sys/types.h> // For stat().
    #include <sys/stat.h>
    using namespace std;

    int main()
    {
    for(;
    {
    if(GetKeyState(VK_LBUTTON) < 0)
    {
    INPUT *buffer = new INPUT[3];
    (buffer+1)->type = INPUT_MOUSE;
    (buffer+1)->mi.dx = 100;
    (buffer+1)->mi.dy = 100;
    (buffer+1)->mi.mouseData = 0;
    (buffer+1)->mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
    (buffer+1)->mi.time = 0;
    (buffer+1)->mi.dwExtraInfo = 0;

    (buffer+2)->type = INPUT_MOUSE;
    (buffer+2)->mi.dx = 100;
    (buffer+2)->mi.dy = 100;
    (buffer+2)->mi.mouseData = 0;
    (buffer+2)->mi.dwFlags = MOUSEEVENTF_RIGHTUP;
    (buffer+2)->mi.time = 0;
    (buffer+2)->mi.dwExtraInfo = 0;


    SendInput(3,buffer,sizeof(INPUT));
    }

    if(GetKeyState(VK_RBUTTON) < 0)
    {
    INPUT *buffer = new INPUT[3];
    (buffer+1)->type = INPUT_MOUSE;
    (buffer+1)->mi.dx = 100;
    (buffer+1)->mi.dy = 100;
    (buffer+1)->mi.mouseData = 0;
    (buffer+1)->mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
    (buffer+1)->mi.time = 0;
    (buffer+1)->mi.dwExtraInfo = 0;

    (buffer+2)->type = INPUT_MOUSE;
    (buffer+2)->mi.dx = 100;
    (buffer+2)->mi.dy = 100;
    (buffer+2)->mi.mouseData = 0;
    (buffer+2)->mi.dwFlags = MOUSEEVENTF_LEFTUP;
    (buffer+2)->mi.time = 0;
    (buffer+2)->mi.dwExtraInfo = 0;

    SendInput(3,buffer,sizeof(INPUT));
    }
    }
    system("PAUSE");
    return EXIT_SUCCESS;
    }


    It compiles good, but when I press right or left click, the function isn't inversed, it is quite normal. Left click is inversed with right click, but otherwise, no. What am I doing wrong?
    Last edited by zorro59; May 5th, 2009 at 10:50 AM.

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
  •  





Click Here to Expand Forum to Full Width

Featured