Go Back   UnKnoWnCheaTs - Multiplayer Game Hacks and Cheats > Anti-Cheat Software & Programming > Programming for Beginners

- Sponsored Advertisement -
http://www.myfpscheats.com/

Welcome to the UnKnoWnCheaTs - Multiplayer Game Hacks and Cheats.
You have to register before you can post and see and access any of the advanced forum features, please click the register link to proceed to the registration form. To start viewing threads or posts, select a forum that you want to visit from the selection below.
Programming for Beginners
This section is for those just beginning in the programming world.
You are Unregistered, please register to gain Full access.    
Reply
 
Thread Tools

Key is down or pressed and hold
Old 02-05-2010, 09:29 AM   #1


killer.assassin's Avatar

Join Date: Apr 2009
Posts: 57
Reputation: -224
Rep Power: 0
killer.assassin is a complete Unknown Asshatkiller.assassin is a complete Unknown Asshatkiller.assassin is a complete Unknown Asshat
Question Key is down or pressed and hold

Well i have been programming for a while now and want to know more. i.e increase my knowlede and make more hacks. lol.

I was wondering what is the command of checking that
if a key is pressed and hold.
for example i am holding right click.
How sholud i make c++ to know that i m doing so.
please tell me the command and syntax thanks.

I already know about GetAsyncKeyState.
can it be used to check the key state. if it is being pressed or not.
I only use it for activating the hacks.

THanks in advance.
killer.assassin is offline

Reply With Quote


Old 02-05-2010, 06:37 PM   #2
Level 3

mandai's Avatar

Join Date: May 2007
Location: UK
Posts: 433
Reputation: 1953
Rep Power: 85
mandai is an oracle in the cheating communitymandai is an oracle in the cheating communitymandai is an oracle in the cheating communitymandai is an oracle in the cheating communitymandai is an oracle in the cheating communitymandai is an oracle in the cheating communitymandai is an oracle in the cheating communitymandai is an oracle in the cheating communitymandai is an oracle in the cheating communitymandai is an oracle in the cheating communitymandai is an oracle in the cheating community
Major Slant Champion
I don't think there is a built in "command" (other than active console input) that will cause something to happen when key states are changed, you will have to make your own handlers to detect that.

Code:
//I know this is C# but you should be able to get the idea
while (true)
      {
         foreach (int i in Enum.GetValues(typeof(Keys)))
         {
              if (GetAsyncKeyState(i) == -32768)// i is 1 for left, 2 for right and 4 for middle mouse buttons.
              {
                        Console.WriteLine((Keys)i + " (" + i + ")");
                        Thread.Sleep(int.Parse(interval1));
              }
         }
         Thread.Sleep(int.Parse(interval2));
      }
If GetAsyncKeyState returns a value of 0 it means the button is up and -32768 means its down.

Alternatively you could also use DirectInput to get key information.

Last edited by mandai; 02-05-2010 at 06:47 PM. Reason: mouse click info
mandai is offline

Reply With Quote

Old 02-05-2010, 07:39 PM   #3
The 0n3

Sfab1's Avatar

Join Date: Nov 2007
Location: Finland
Posts: 423
Reputation: 22706
Rep Power: 287
Sfab1 has reputation that takes up 2GB of server space!Sfab1 has reputation that takes up 2GB of server space!Sfab1 has reputation that takes up 2GB of server space!Sfab1 has reputation that takes up 2GB of server space!Sfab1 has reputation that takes up 2GB of server space!Sfab1 has reputation that takes up 2GB of server space!Sfab1 has reputation that takes up 2GB of server space!Sfab1 has reputation that takes up 2GB of server space!Sfab1 has reputation that takes up 2GB of server space!Sfab1 has reputation that takes up 2GB of server space!Sfab1 has reputation that takes up 2GB of server space!
Recognitions:
Members who have contributed financial support towards UnKnoWnCheaTs. Donation (1)
Points: 16,512, Level: 17
Points: 16,512, Level: 17 Points: 16,512, Level: 17 Points: 16,512, Level: 17
Activity: 32.2%
Activity: 32.2% Activity: 32.2% Activity: 32.2%
Last Achievements
if(GetAsyncKeyState(VK_NUMPAD1)) << if holded
if(GetAsyncKeyState(VK_NUMPAD1) & 1) << if pressed once

example

if(GetAsyncKeyState(VK_NUMPAD1) & 1)
NoFog = !NoFog;

if uve pressed numpad1 once no fog hack turns on and otherway
__________________

Sfab1 is online now

Reply With Quote

Old 02-06-2010, 05:35 AM   #4


killer.assassin's Avatar

Threadstarter
Join Date: Apr 2009
Posts: 57
Reputation: -224
Rep Power: 0
killer.assassin is a complete Unknown Asshatkiller.assassin is a complete Unknown Asshatkiller.assassin is a complete Unknown Asshat
I will try both these methods......


1st one is dufficult because i am new but i know i will understand it somehow.
and second one "lol i should have known that"
Thanks for your reply.


-------------------------------------------------------------------------------------------------------------


I understood the concept of keyboard. thanks for the help
but next comes the mouse. I have read about mouse that it uses events to check movements and clicks
Can any one give a simple example, so i can understand the concept.

thanks

Last edited by killer.assassin; 02-07-2010 at 08:04 AM.
killer.assassin is offline

Reply With Quote

Old 02-07-2010, 03:15 PM   #5
Hacker Supreme

Krtek's Avatar

Join Date: Oct 2008
Posts: 235
Reputation: 3567
Rep Power: 80
Krtek is a legend in the cheating communityKrtek is a legend in the cheating communityKrtek is a legend in the cheating communityKrtek is a legend in the cheating communityKrtek is a legend in the cheating communityKrtek is a legend in the cheating communityKrtek is a legend in the cheating communityKrtek is a legend in the cheating communityKrtek is a legend in the cheating communityKrtek is a legend in the cheating communityKrtek is a legend in the cheating community
Quote:
Originally Posted by killer.assassin View Post
Well i have been programming for a while now and want to know more. i.e increase my knowlede and make more hacks. lol.

I was wondering what is the command of checking that
if a key is pressed and hold.
for example i am holding right click.
How sholud i make c++ to know that i m doing so.
please tell me the command and syntax thanks.

I already know about GetAsyncKeyState.
can it be used to check the key state. if it is being pressed or not.
I only use it for activating the hacks.

THanks in advance.
What you want to do is perfectly possible with GetAsyncKeyState;

Quote:
If the most significant bit is set, the key is down, and if the least significant bit is set, the key was pressed after the previous call to GetAsyncKeyState. However, you should not rely on this last behavior; for more information, see the Remarks.
To get the most significant bit you could do this:

Code:
if( ( GetAsyncKeyState(SomeKeyCode) >> 15 ) )
{
      //More code here
}
That should work fine ( although the compiler might complain a bit in which case you should probably cast it )

This code however, assumes that a SHORT is 16 bits in length. Which need not be true.
Krtek is offline

Reply With Quote

Old 02-08-2010, 11:01 AM   #6
Level 3

Gellin's Avatar

Join Date: Nov 2007
Location: msdn
Posts: 528
Reputation: 22916
Rep Power: 291
Gellin has reputation that takes up 2GB of server space!Gellin has reputation that takes up 2GB of server space!Gellin has reputation that takes up 2GB of server space!Gellin has reputation that takes up 2GB of server space!Gellin has reputation that takes up 2GB of server space!Gellin has reputation that takes up 2GB of server space!Gellin has reputation that takes up 2GB of server space!Gellin has reputation that takes up 2GB of server space!Gellin has reputation that takes up 2GB of server space!Gellin has reputation that takes up 2GB of server space!Gellin has reputation that takes up 2GB of server space!
Points: 16,705, Level: 17
Points: 16,705, Level: 17 Points: 16,705, Level: 17 Points: 16,705, Level: 17
Activity: 1.1%
Activity: 1.1% Activity: 1.1% Activity: 1.1%
Last Achievements
Quote:
Originally Posted by Krtek View Post
What you want to do is perfectly possible with GetAsyncKeyState;
True

Code:
if( GetAsyncKeyState(VK_RBUTTON) < 0 )
{
        //Do something when you are holding right click
}
__________________
Gellin is offline

Reply With Quote

Old 02-08-2010, 01:05 PM   #7


killer.assassin's Avatar

Threadstarter
Join Date: Apr 2009
Posts: 57
Reputation: -224
Rep Power: 0
killer.assassin is a complete Unknown Asshatkiller.assassin is a complete Unknown Asshatkiller.assassin is a complete Unknown Asshat
ok thanks i will try that.

i didnt knew that VK_RBUTTON works with GetAsyncKeyState.

thank again.
killer.assassin is offline

Reply With Quote

Old 02-08-2010, 01:51 PM   #8
Super H4x0r

iExclusive's Avatar

Join Date: Jan 2009
Posts: 318
Reputation: 1550
Rep Power: 59
iExclusive -- Warning: My rep could overloadiExclusive -- Warning: My rep could overloadiExclusive -- Warning: My rep could overloadiExclusive -- Warning: My rep could overloadiExclusive -- Warning: My rep could overloadiExclusive -- Warning: My rep could overloadiExclusive -- Warning: My rep could overloadiExclusive -- Warning: My rep could overloadiExclusive -- Warning: My rep could overloadiExclusive -- Warning: My rep could overloadiExclusive -- Warning: My rep could overload
Alloy Arena Champion Booty Champion The Collector Champion Frantic Killer Champion
any virtual key could have been used.
iExclusive is offline

Reply With Quote
Reply  

  • Submit Thread to Digg
  • Submit Thread to del.icio.us
  • Submit Thread to StumbleUpon
  • Submit Thread to Google
  • Submit Thread to Facebook
  • Submit Thread to My Yahoo!
  • Submit Thread to MySpace
  • Submit Thread to Twitter
  • Submit Thread to Reddit



Tags
hold, key, pressed
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT +1. The time now is 04:12 PM.