Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C]Using Switch/Case On GetAsyncKeyState ?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Wed Sep 03, 2008 6:10 am    Post subject: [C]Using Switch/Case On GetAsyncKeyState ? Reply with quote

I want to like use switch/case on GetASyncKeyState (lazy to start if/else).

i was wondering if i would do it like this ?

Code:
int vKey = VK_F1 | VK_F2 | VK_F3 | VK_F4;

SHORT lol = GetAsyncKeyState(vKey);
swtch(lol)
{
case VK_F1:
case VK_F2:
//and so on..
}
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Wed Sep 03, 2008 6:22 am    Post subject: Reply with quote

SetWindowsHookEx
Back to top
View user's profile Send private message MSN Messenger
Zand
Master Cheater
Reputation: 0

Joined: 21 Jul 2006
Posts: 424

PostPosted: Wed Sep 03, 2008 7:40 am    Post subject: Reply with quote

No.

Quote:

Return Value

If the function succeeds, the return value specifies whether the key was pressed since the last call to GetAsyncKeyState, and whether the key is currently up or down. 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.
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Wed Sep 03, 2008 7:42 am    Post subject: Reply with quote

Call GetAsyncKeyState in a loop or just call RegisterHotKey once.
Back to top
View user's profile Send private message
Kerelmans
Advanced Cheater
Reputation: 0

Joined: 29 Oct 2007
Posts: 57

PostPosted: Wed Sep 03, 2008 10:03 am    Post subject: Reply with quote

Symbol wrote:
Call GetAsyncKeyState in a loop or just call RegisterHotKey once.

Isn't the GetAsyncKeyState value cleared after using the code? so when you loop it it'd just...
I'm not experienced at this... :p
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Wed Sep 03, 2008 1:27 pm    Post subject: Reply with quote

Code:

   bool Active = true;
   char lastKeyPress;
   while(Active) {
     for(int i=8; i<190; i++){
        if(GetAsyncKeyState(i))
           checkKey(i)
     }
   }
   void checkKey(int key) {
     swtch(key)
     {
       case VK_F1:
        case VK_F2:
         //and so on..
     }
  }



http://bothack.wordpress.com/2007/12/12/keylogging-fun-for-cc-beginners/

_________________
Hacks I made for kongregate.
Kongregate Universal Badge Hack: http://forum.cheatengine.org/viewtopic.php?p=4129411
Kongreate Auto Rating/Voter hack: http://forum.cheatengine.org/viewtopic.php?t=263576
Took a test lol
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Thu Sep 04, 2008 5:54 am    Post subject: Reply with quote

Symbol wrote:
Call GetAsyncKeyState in a loop or just call RegisterHotKey once.


i think i'll do that ;D.

like this yeah ?

Code:
do
{
SHORT lol = GetAsyncKeyState(ARRAY_OF_HOTKEYS);
if(lol == VK_XX)
 else if
 //and so on..
}
while(condition);
Back to top
View user's profile Send private message
Zand
Master Cheater
Reputation: 0

Joined: 21 Jul 2006
Posts: 424

PostPosted: Thu Sep 04, 2008 9:57 am    Post subject: Reply with quote

You don't get it. GetAsyncKeyState doesn't return a virtual key code. It returns the state of the key, down or up. It doesn't take an array as a param either.
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Thu Sep 04, 2008 10:13 am    Post subject: Reply with quote

Zand wrote:
You don't get it. GetAsyncKeyState doesn't return a virtual key code. It returns the state of the key, down or up. It doesn't take an array as a param either.



ahh !! then what do i use GetKeyState ?
Back to top
View user's profile Send private message
Renkokuken
GO Moderator
Reputation: 4

Joined: 22 Oct 2006
Posts: 3249

PostPosted: Thu Sep 04, 2008 11:10 am    Post subject: Reply with quote

No-one has recommended GetKeyboardState yet..?
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Thu Sep 04, 2008 12:41 pm    Post subject: Reply with quote

Rot1 wrote:
Symbol wrote:
Call GetAsyncKeyState in a loop or just call RegisterHotKey once.


i think i'll do that ;D.

like this yeah ?

Code:
do
{
SHORT lol = GetAsyncKeyState(ARRAY_OF_HOTKEYS);
if(lol == VK_XX)
 else if
 //and so on..
}
while(condition);


Code:

void hotkeyz(void){
while(dicks){
if(GetAsyncKeyState(VK_F10)){
suck();
}

if(GetAsyncKeyState(VK_F11)){
fuck_tabs();
}
}Sleep(100);
}


Read the MSDN entry.

Quote:
SHORT GetAsyncKeyState

If the function succeeds, the return value specifies whether the key was pressed since the last call to GetAsyncKeyState, and whether the key is currently up or down. 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.


Go look at AX in a debugger if you really care.
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Thu Sep 04, 2008 12:54 pm    Post subject: Reply with quote

Renkokuken wrote:
No-one has recommended GetKeyboardState yet..?


woah, thanks !! Very Happy never heard of that API, i'm new to it, thanks Renko!.
Back to top
View user's profile Send private message
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Thu Sep 04, 2008 5:49 pm    Post subject: Reply with quote

int VirtualKey;

if( GetAsyncKeyState( VirtualKey ) ) {

Switc( VirtualKey ) {

case 0x41:
MessageBox( NULL, "You pushed A", "message", MB_OK );
Break;
//and so on...

}

}
Back to top
View user's profile Send private message AIM Address MSN Messenger
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Fri Sep 05, 2008 5:22 am    Post subject: Reply with quote

slippppppppp wrote:
int VirtualKey;

if( GetAsyncKeyState( VirtualKey ) ) {

Switc( VirtualKey ) {

case 0x41:
MessageBox( NULL, "You pushed A", "message", MB_OK );
Break;
//and so on...

}

}


i will try this also and leave feedback.
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Fri Sep 05, 2008 6:59 am    Post subject: Reply with quote

slippppppppp wrote:
int VirtualKey;

if( GetAsyncKeyState( VirtualKey ) ) {

Switc( VirtualKey ) {

case 0x41:
MessageBox( NULL, "You pushed A", "message", MB_OK );
Break;
//and so on...

}

}

Wrong.
GetAsyncKeyState doesn't get the state of the keyboard, it gets the state of a key, you will get compile error/warning. (Use of uninitialized variable)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites