Thread: My first foray into windows programming

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    32

    My first foray into windows programming

    I am familiar with C and C++ but everything that I have done to this point has been on Unix in an academic setting.

    I have a problem at work that I think a simple program would fix, but I could use a push in the right direction.

    Basically, I want to write a program that right clicks a certain spot, then left clicks a 2nd spot twice. That needs to be repeated about 30,000 times.

    It seems like an easy program, but I have never done anything for Windows, so a starting point would be nice.

    Thanks.

  2. #2
    Registered User
    Join Date
    Dec 2002
    Posts
    221
    why not just get a macroing program to do that for you?

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Try using SetCursorPos and mouse_event.
    Code:
    #include <windows.h>
    
    int main(void)
    {
    	int i;
    
    	for (i = 0; i < 30000; i++)
    	{
    		/* Move cursor to screen position 10, 10 */
    		SetCursorPos(10, 10);
    
    		/* Right mouse click. */
    		mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
    		mouse_event(MOUSEEVENTF_RIGHTUP,   0, 0, 0, 0);
    
    		/* Move cursor to screen position 20, 20 */
    		SetCursorPos(20, 20);
    
    		/* Left mouse click. */
    		mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
    		mouse_event(MOUSEEVENTF_LEFTUP,   0, 0, 0, 0);
    
    		/* Pause so mouse clicks are not interpreted as a double click. */
    		Sleep( GetDoubleClickTime() + 100 );
    
    		/* Left mouse click. */
    		mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
    		mouse_event(MOUSEEVENTF_LEFTUP,   0, 0, 0, 0);
    
    		/* Pause for action to be processed. */
    		Sleep(500);
    	}
    
    	return 0;
    }

  4. #4
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    the above program is evil btw.. the only way to stop it was to reboot me' pc... :P
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  5. #5
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    Heehee, I made a program like that once...with a bit of rand thrown in there......and basically, if you run it on windows XP or one of the windows OS's that don't halt when you press control-alt-delete, your puter's screwed. I then put this program in one of my friends' computer's startup directory and it uber screwed up his puter. Good times....good times.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Windows 98/2000 programming in Windows XP
    By Bill83 in forum Windows Programming
    Replies: 3
    Last Post: 07-22-2005, 02:16 PM
  2. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 05:48 PM
  3. dual boot Win XP, win 2000
    By Micko in forum Tech Board
    Replies: 6
    Last Post: 05-30-2005, 02:55 PM
  4. SDL and Windows
    By nickname_changed in forum Windows Programming
    Replies: 14
    Last Post: 10-24-2003, 12:19 AM
  5. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 05:31 PM