Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

code specifc; mouse move

Posted on 2007-11-28
1
Medium Priority
?
193 Views
Last Modified: 2010-04-01
#include <windows.h>
#include <iostream>
#include <vector>
#include <string.h>
using namespace std;

void mousemove( HWND hwnd1, POINT p);
void left_mouseclick( POINT p );
int main()
{
      POINT p;
      p.x = 200;
      p.y = 200;

      HWND hwnd1;  // placeholder
      
      mousemove ( hwnd1, &p );
      left_mouseclick ( p );

      
      
      return 0;
}


void mousemove( HWND hwnd1, POINT p)
{
      ClientToScreen(hwnd1, p);
      SetCursorPos(p.x, p.y);
}

void left_mouseclick( POINT p )
{
      mouse_event(MOUSEEVENTF_LEFTDOWN,   p.x, p.y, 0, 0); // Left Key Down
      mouse_event(MOUSEEVENTF_LEFTDOWN,   p.x, p.y, 0, 0); // Left Key Down

}





I don't why, I know that my use of hwnd is problematic, but i don't know how other things are wrong.
0
Comment
Question by:Troudeloup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 20368799
Well, you have to initialize the HWND to hold a valid handle. Otherwise, that looks OK, except that you should give a short delay between the two clickes, e.g.

void left_mouseclick( POINT p )
{
      mouse_event(MOUSEEVENTF_LEFTDOWN,   p.x, p.y, 0, 0); // Left Key Down
      Sleep(400);
      mouse_event(MOUSEEVENTF_LEFTDOWN,   p.x, p.y, 0, 0); // Left Key Down

}
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question