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 


GetAsyncKeyState or RegisterHotKey
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
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Sun Nov 09, 2008 10:26 pm    Post subject: GetAsyncKeyState or RegisterHotKey Reply with quote

I just want a simple hotkey, you press F11 and it starts doing a function. Should I just use GetAsyncKeyState for simplicity or RegisterHotKey?
_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sun Nov 09, 2008 11:01 pm    Post subject: Reply with quote

Use whatever the hell you want, one really isn't simpler than the other.

Big woop you respond to WM_HOTKEY instead of WM_TIMER or a thread.
Back to top
View user's profile Send private message
Box
Grandmaster Cheater
Reputation: 0

Joined: 16 Oct 2007
Posts: 541

PostPosted: Mon Nov 10, 2008 6:49 am    Post subject: Reply with quote

or u could use the menu editor and set the hotkey...
_________________
zurkei wrote:
Wow box your a real dick, I can't believe I actually thought that you were telling the truth...

Fact: no one tells the truth on cheat engine fourms
Back to top
View user's profile Send private message
Xoujiro
Advanced Cheater
Reputation: 0

Joined: 20 Mar 2006
Posts: 86

PostPosted: Mon Nov 10, 2008 7:09 am    Post subject: Reply with quote

GetAsyncKeyState seems easier to use for me..

Quote:
if ( GetAsyncKeyState ( VK_F11 ) ) {
//FUNCTION
}


done and RegisterHotkey looks so complicated...
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: Mon Nov 10, 2008 8:12 am    Post subject: Reply with quote

RegisterHotKey is not complicated, it's better, you don't have to call GetAsyncKeyState in a loop, just call RegisterHotKey once and call your functions when a WM_HOTKEY arrives.
Back to top
View user's profile Send private message
tdenisenko
Grandmaster Cheater
Reputation: 0

Joined: 23 Oct 2007
Posts: 799
Location: Turkey

PostPosted: Mon Nov 10, 2008 11:24 am    Post subject: Reply with quote

if you have a GUI use RegisterHotkey
_________________
I am learning C++ and ASM and making trainers!
My Last Chaos Trainer!
LC Trainer by tdenisenko
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Mon Nov 10, 2008 2:41 pm    Post subject: Reply with quote

slovach wrote:
Use whatever the hell you want, one really isn't simpler than the other.

Big woop you respond to WM_HOTKEY instead of WM_TIMER or a thread.


just thought i would point out that using WM_TIMER is badd. It only takes the message if no other messages are on the stack. so uh, don't use it Razz

RegisterHotKey is best, no questions.

_________________
Back to top
View user's profile Send private message
BirdsEye
Advanced Cheater
Reputation: 0

Joined: 05 Apr 2008
Posts: 94

PostPosted: Wed Nov 12, 2008 4:16 pm    Post subject: Reply with quote

Xoujiro wrote:
GetAsyncKeyState seems easier to use for me..

Quote:
if ( GetAsyncKeyState ( VK_F11 ) ) {
//FUNCTION
}


done and RegisterHotkey looks so complicated...


Its not that complicated:

Code:


LRESULT CALLBACK WndProc(. . .)
{
    . . .
    case WM_HOTKEY:
        switch(LOWORD(wParam))
       {
            case 100:
                . . .
            break;
       }
   break;
   . . .
}

int WINAPI WinMain(. . .)
{
     . . .
     RegisterHotKey(hWnd, 100, NULL, VK_F1);
     . . .
}


Just replace first-parameter (hWnd) with the handle to you parent window, the second parameter (100) to whatever identifier you want, the third parameter if want an option of keys to be held down along with the hotkey for 'activation' (Check MSDN ), and the fourth parameter with your choise of virtual key.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25823
Location: The netherlands

PostPosted: Wed Nov 12, 2008 5:44 pm    Post subject: Reply with quote

RegisterHotKey is easier but I noticed it doesn't always work when some games are running.
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
nog_lorp
Grandmaster Cheater
Reputation: 0

Joined: 26 Feb 2006
Posts: 743

PostPosted: Wed Nov 12, 2008 6:27 pm    Post subject: Reply with quote

WM_TIMER is low priority, it still ends up on the queue it just gets superseded by most other messages. That isn't really bad.
_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish
Back to top
View user's profile Send private message
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Wed Nov 12, 2008 7:47 pm    Post subject: Reply with quote

Use RegisterHotkey. It's more efficient than GetAsyncKeyState because you don't waste CPU doing a loop.
Back to top
View user's profile Send private message
blackmorpheus
Expert Cheater
Reputation: 0

Joined: 05 Apr 2008
Posts: 159

PostPosted: Sat Nov 15, 2008 7:01 am    Post subject: Reply with quote

You can make a simple hotkey with both, this is how to do it with GetAsyncKeyState.
place this at the beginning of ur main.cpp
Code:

bool bHotkey = false;  // boolean that stores if hotkey is false or true..



place this in a loop that executes all the time:

Code:

if(GetAsyncKeyState(VK_KEY)&1)
{
     if(bHotkey){ bHotkey =false;}
     else {bHotkey = true;}
// u can use Sleep(10) or something here
 }


then you can acces ur hotkey like this..
Code:

if(bHotkey)  or while(bHotkey) or whatever(bHotkey)
{
code
}
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sat Nov 15, 2008 12:30 pm    Post subject: Reply with quote

blackmorpheus wrote:
You can make a simple hotkey with both, this is how to do it with GetAsyncKeyState.
place this at the beginning of ur main.cpp
Code:

bool bHotkey = false;  // boolean that stores if hotkey is false or true..



place this in a loop that executes all the time:

Code:

if(GetAsyncKeyState(VK_KEY)&1)
{
     if(bHotkey){ bHotkey =false;}
     else {bHotkey = true;}
// u can use Sleep(10) or something here
 }


then you can acces ur hotkey like this..
Code:

if(bHotkey)  or while(bHotkey) or whatever(bHotkey)
{
code
}


This is kind of redundant, considering you're essentially already checking if the key is down.
Back to top
View user's profile Send private message
Heartless
I post too much
Reputation: 0

Joined: 03 Dec 2006
Posts: 2436

PostPosted: Sat Nov 15, 2008 12:45 pm    Post subject: Reply with quote

I use RegisterHotKey over GetAsyncKeyState. But I'm currently learning to use DirectInput.

Which do you suggest to use for game programming?

_________________
What dosen't kill you, usually does the second time.
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Sat Nov 15, 2008 1:03 pm    Post subject: Reply with quote

game programming pretty much needs a full keyboard hook because hotkeys would collide with other programs and GetAsnc would take up a massive load for every key.

aka DirectInput or custom driver

Edit: 1337 post

_________________


Last edited by HomerSexual on Sun Nov 23, 2008 11:27 am; edited 1 time in total
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