Advertisement
1_2002 Windows API Call/ Explanation #104535

A mouse module, FINALLY!!! Move,click, +more

This module has the following functions (pretty self explanitory): GetX, GetY, LeftClick, LeftDown, LeftUp, RightClick, RightUp, RightDown, MiddleClick, MiddleDown, MiddleUp, MoveMouse, SetMousePos

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Public Function GetX() As Long
 Dim n As POINTAPI
 GetCursorPos n
 GetX = n.x
End Function
Public Function GetY() As Long
 Dim n As POINTAPI
 GetCursorPos n
 GetY = n.y
End Function
Public Sub LeftClick()
 LeftDown
 LeftUp
End Sub
Public Sub LeftDown()
 mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
End Sub
Public Sub LeftUp()
 mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
Public Sub MiddleClick()
 MiddleDown
 MiddleUp
End Sub
Public Sub MiddleDown()
 mouse_event MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0
End Sub
Public Sub MiddleUp()
 mouse_event MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0
End Sub
Public Sub MoveMouse(xMove As Long, yMove As Long)
 mouse_event MOUSEEVENTF_MOVE, xMove, yMove, 0, 0
End Sub
Public Sub RightClick()
 RightDown
 RightUp
End Sub
Public Sub RightDown()
mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0
End Sub
Public Sub RightUp()
 mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
End Sub
Public Sub SetMousePos(xPos As Long, yPos As Long)
 SetCursorPos xPos, yPos
End Sub
/*
	One line bubble sort
	www.PlanetCPP.com
*/
#include <iostream>
using std::cout;
using std::endl;
using std::cin;

int main()
{
  	int i,x,arraysize=0,tmp=0;
  	int arry[50]={0};	//initiate array of 50 integers
  	cout<<"Enter in integer values, use negative # to stop\n";
  	cin>>tmp;
  	while(tmp>=0)	//loop till # is negative
    	{
    		arry[arraysize]=tmp;
    		arraysize+=1;	//increment counter
    		cin>>tmp;
    }
    	//start bubble sort code
    	for(i=0,x=1;i<arraysize,x<arraysize;i++,x++){if(arry[i]>arry[x]){arry[x]^=arry[i];arry[i]^=arry[x];arry[x]^=arry[i];}if(x<(arraysize-1)){i--;}else{x=i+1;}}
    	//end bubble sort code
    	for(i=0;i<arraysize;i++)	//show array after sorted
    		cout<<arry[i]<<endl;
	return 0;
}
  /*
  	what allows you to do this is that c++ allows you to
  	use more than one counter in its 'for' loop, by having 
  	i and x counters going through the array at the same time
  	we can have x go through the whole array before i increments
  	by restricting i until x has finished looking through the array
  	The other aspect that is smaller is the exchanging of values,
  	normally you would set up a temp value and hold one of the values
  	in that temp variable, then copy the second value to the first and 
  	finally copy the tempo variable to the second value, an easy way to
  	exchange two values is to XOR the values 3 times, this is why it works:
  	Values (5 and 10)
  	In binary they are 0101 and 1010, to switch we xor them 3 times:
  	*remember ^= in c++ = XOR and i^=x stors the return value in i x
  	remains unchanged*
  		0101	i= 0101, x = 1010 here
  	XOR	1010	xor them together
  	=	1111	then you get 1111 in i, x is still 1010
  		1010	now xor x and i storing new val in x
  	XOR	1111	-this is i
  	=	0101	then x = 0101 (5), i still = 1111 (15)
  		1111	now xor i against x one more time
  	XOR	0101	-this is x it still = 5 since we are xoring i with x, i will change only
  	=	1010	-now i = 1010 (10)
  				-now i = 10 and x = 5 they are switched
  */
Original Comments (3)
Recovered from Wayback Machine