III,code,original,made,Visual,Basic,find,ther
Quick Search for: in language:   
III,code,original,made,Visual,Basic,find,ther
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
C/ C++ Stats

 Code: 342,436 lines
 Jobs: 945 postings

 

You are in:

 
Login


Latest Code Ticker for C/ C++
cryptsolver
By dhritimaan shukla on 3/17


Post - It
By Massimiliano Tomassetti on 3/17


JACKPOT GAME
By Gurjit Singh Wadhwa on 3/17


ROYAL COMPUTERS DATABASE
By Gurjit Singh Wadhwa on 3/17


istream iterator
By Erik Minkin on 3/16


Pixel Building
By Dan Anderson on 3/16


Simple Banking Porgram
By Prakash.Y on 3/16


Click here to see a screenshot of this code!A very COOL color pick dialog with a color dropper like Photoshop and Frontpage XP
By ucancode on 3/15

(Screen Shot)

encrypter/decry pter
By Nhuong on 3/15


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 

 
 

   

Mouse Hot Keys

Print
Email
 
VB icon
Submitted on: 2/24/2002 2:53:33 PM
By: Aidman 
Level: Intermediate
User Rating: By 1 Users
Compatibility:C++ (general), Microsoft Visual C++, Borland C++

Users have accessed this code 436 times.
 
(About the author)
 
     This code was or original made in Visual Basic, you can find it there too, but I rewrote the code to Visual C++ for better performance, VB is no match for C++! I made the program for my Pentium 90 MHz that had no mouse, because it needed serial port mouse which I didn’t have. So hope fully you will also have use for this code or you may learn from it, because it is an easy, very fast and well explained program. It let’s you control your mouse courser actions by custom keyboard keys and custom movements speed. Showing the easiest way of hotkeys and controlling your mouse cursor movements and button actions. It has been tested and works in all Windows platforms (95, 98, ME, NT, 2000, XP) and all games (Half-life, Counter-Strike, Quake III arena). There are many functions including: * Moving at all directions * Left, right and middle button press * Single clicking * Double clicking * Drag and drop * Several keys up and down at once. All in just one single small and very fast procedur, the Main procedur. Whit out anything else like form, dll or ocx. Read "Assumes" in the Source Code for using instructions and notes, I will gladly accept any comments, this is my first Program that I have published in C++, enjoy =)
 

INCLUDE files:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

//**************************************
//     
//INCLUDE files for :Mouse Hot Keys
//**************************************
//     
#include <windows.h> // Windows header file
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

//**************************************
//     
// Name: Mouse Hot Keys
// Description:This code was or original
//     made in Visual Basic, you can find it th
//     ere too, but I rewrote the code to Visua
//     l C++ for better performance, VB is no m
//     atch for C++! I made the program for my 
//     Pentium 90 MHz that had no mouse, becaus
//     e it needed serial port mouse which I di
//     dn’t have. So hope fully you will also h
//     ave use for this code or you may learn f
//     rom it, because it is an easy, very fast
//     and well explained program. It let’s you
//     control your mouse courser actions by cu
//     stom keyboard keys and custom movements 
//     speed. Showing the easiest way of hotkey
//     s and controlling your mouse cursor move
//     ments and button actions. It has been te
//     sted and works in all Windows platforms 
//     (95, 98, ME, NT, 2000, XP) and all games
//     (Half-life, Counter-Strike, Quake III ar
//     ena). There are many functions including
//     : * Moving at all directions * Left, rig
//     ht and middle button press * Single clic
//     king * Double clicking * Drag and drop *
//     Several keys up and down at once. All in
//     just one single small and very fast proc
//     edur, the Main procedur. Whit out anythi
//     ng else like form, dll or ocx. Read "Ass
//     umes" in the Source Code for using instr
//     uctions and notes, I will gladly accept 
//     any comments, this is my first Program t
//     hat I have published in C++, enjoy =)
// By: Aidman
//
// Assumes:All Keys are Numpad Keys, Num
//     lock must be toggled. When using the pro
//     gram in games, increase the MoveSpeed co
//     nstant.
//
//This code is copyrighted and has// limited warranties.Please see http://
//     www.Planet-Source-Code.com/xq/ASP/txtCod
//     eId.3356/lngWId.3/qx/vb/scripts/ShowCode
//     .htm//for details.//**************************************
//     

const int MoveSpeed = 5; // Move Mouse speed in pixels.
const int MoveUp = 0; // action number for move Mouse up.
const int MoveDown = 1; // action number for move Mouse down.
const int MoveLeft = 2; // action number for move Mouse left.
const int MoveRight = 3; // action number for move Mouse right.
const int ButtonLeft = 4; // action number for left Mouse button.
const int ButtonMiddle = 5; // action number for middle Mouse button.
const int ButtonRight = 6; // action number for right Mouse button.
const int EndProgram = 7; // action number for end Program.
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { // Main procedur.
	MSG Msg; // Message from Windows.
	POINT MousePos; // Windows Mouse position.
int KeyCode[7]; // Key numbers for all actions.
bool KeyState[7]; // Key press values for action.
bool OldKeyState[7]; // Old Key press values for move actions only.
bool MoveKeys = false; // Value of any pressed move action.
	bool EndLoop = false; // Value for continuation of do loop.
int Count; // for loop counter.
	// Remember Numlock key must be toggled.
KeyCode[MoveUp] = VK_NUMPAD8; // Use Numpad Key 8 as move Mouse up action.
KeyCode[MoveDown] = VK_NUMPAD5; // Use Numpad Key 5 as move Mouse down action.
KeyCode[MoveLeft] = VK_NUMPAD4; // Use Numpad Key 4 as move Mouse left action.
KeyCode[MoveRight] = VK_NUMPAD6; // Use Numpad Key 6 as move Mouse right action.
KeyCode[ButtonLeft] = VK_NUMPAD7; // Use Numpad Key 7 as left Mouse button action.
KeyCode[ButtonMiddle] = VK_NUMPAD2; // Use Numpad Key 2 as middle Mouse button action.
KeyCode[ButtonRight] = VK_NUMPAD9; // Use Numpad Key 9 as right Mouse button action.
KeyCode[EndProgram] = VK_DECIMAL; // Use Numpad Key "." as end Program action.
while (EndLoop == false) { // The Program do loop.
Sleep(1); // Pause program one millisecond.
PeekMessage(&Msg;, 0, 0, 0, PM_REMOVE); // Get message from Windows.
switch (Msg.message) { // Message Value.
case WM_CLOSE: // Abort Program.
case WM_QUIT: // Exit Program.
case WM_DESTROY: // Terminate Program.
				EndLoop = true; // End Program loop.
}

TranslateMessage(&Msg;); // Convert Message. DispatchMessage(&Msg;); // End Message. for (Count = MoveUp; Count <= EndProgram; Count++) { // For loop for Key press. GetAsyncKeyState(KeyCode[Count]); // Clear last Key press. if (Count >= ButtonLeft) { OldKeyState[Count] = KeyState[Count]; } // Old Key press for move actions. KeyState[Count] = false; // Clear last Key press. if (GetAsyncKeyState(KeyCode[Count]) != 0) { // Get current Key press. KeyState[Count] = true; // Key is pressed. if (Count <= MoveRight) { MoveKeys = true; } // Move action key is pressed. }
}
if (KeyState[EndProgram] == true) { EndLoop = true; } // End Program loop if end key is pressed. if (MoveKeys == true) { // do following if any move keys are pressed. GetCursorPos(&MousePos;); // Get current Mouse position. for (Count = MoveUp; Count <= MoveRight; Count++) { // For loop for move actions. if (KeyState[Count] == true) { // do following if move key is pressed. switch (Count) { // Choose Mouse position modification action. case MoveUp: MousePos.y = MousePos.y - MoveSpeed; break; // Move Mouse up action. case MoveDown: MousePos.y = MousePos.y + MoveSpeed; break; // Move Mouse down action. case MoveLeft: MousePos.x = MousePos.x - MoveSpeed; break; // Move Mouse left action. case MoveRight: MousePos.x = MousePos.x + MoveSpeed; // Move Mouse right action. }
}
}
SetCursorPos(MousePos.x, MousePos.y); // Update Mouse position. mouse_event(MOUSEEVENTF_MOVE, 0, 0, 0, 0); // Inform Windows of Mouse move action. }
for (Count = ButtonLeft; Count <= ButtonRight; Count++) { // For loop for Mouse button. if ((KeyState[Count] == true) && (OldKeyState[Count] == false)) { // do following if Key button is down. switch (Count) { // Choose Mouse button action for key button down. case ButtonLeft: mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); break; // Left Mouse button down. case ButtonMiddle: mouse_event(MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0); break; // Middle Mouse button down. case ButtonRight: mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0); // Right Mouse button down. }
} else if ((KeyState[Count] == false) && (OldKeyState[Count] == true)) { // do following if Key button is up.
switch (Count) { // Choose Mouse button action for key button up. case ButtonLeft: mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); break; // Left Mouse button up. case ButtonMiddle: mouse_event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0); break; // Middle Mouse button up. case ButtonRight: mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); // Right Mouse button up. }
}
}
}
Beep(400, 100); // Inform user that Program has ended with sound beep. return Msg.wParam; // Return reson for Program end. }

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Intermediate category)?
(The codewith your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
2/24/2002 3:02:47 PM:Aidman
All Key are Numpad Keys, Numlock must 
be toggled. When using the program in 
games, increase the MoveSpeed 
constant.
I am sorry for the lack of 
spaces in the beginning of every code 
line, PSC has unfortunately removed all 
my spaces. =(
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/25/2002 10:32:57 AM:Aidman
Please vote or give any comments, I 
would really like to hear what you 
think, becouse this my first code 
published i C++.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/28/2002 9:35:32 AM:Aidman
Please people don't be shy,
give me 
some comments... like:
* Do you like 
the code?
* Is it easy to 
understand?
* Do you have any use for 
it?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | C/ C++ Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.