| View previous topic :: View next topic |
| Author |
Message |
ElectroFusion Grandmaster Cheater
Reputation: 0
Joined: 17 Dec 2006 Posts: 786
|
Posted: Sun Nov 09, 2008 10:26 pm Post subject: GetAsyncKeyState or RegisterHotKey |
|
|
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 |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sun Nov 09, 2008 11:01 pm Post subject: |
|
|
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 |
|
 |
Box Grandmaster Cheater
Reputation: 0
Joined: 16 Oct 2007 Posts: 541
|
Posted: Mon Nov 10, 2008 6:49 am Post subject: |
|
|
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 |
|
 |
Xoujiro Advanced Cheater
Reputation: 0
Joined: 20 Mar 2006 Posts: 86
|
Posted: Mon Nov 10, 2008 7:09 am Post subject: |
|
|
GetAsyncKeyState seems easier to use for me..
| Quote: | if ( GetAsyncKeyState ( VK_F11 ) ) {
//FUNCTION
} |
done and RegisterHotkey looks so complicated...
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Mon Nov 10, 2008 8:12 am Post subject: |
|
|
| 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 |
|
 |
tdenisenko Grandmaster Cheater
Reputation: 0
Joined: 23 Oct 2007 Posts: 799 Location: Turkey
|
Posted: Mon Nov 10, 2008 11:24 am Post subject: |
|
|
if you have a GUI use RegisterHotkey
_________________
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Mon Nov 10, 2008 2:41 pm Post subject: |
|
|
| 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
RegisterHotKey is best, no questions.
_________________
|
|
| Back to top |
|
 |
BirdsEye Advanced Cheater
Reputation: 0
Joined: 05 Apr 2008 Posts: 94
|
Posted: Wed Nov 12, 2008 4:16 pm Post subject: |
|
|
| 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 |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25823 Location: The netherlands
|
Posted: Wed Nov 12, 2008 5:44 pm Post subject: |
|
|
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 |
|
 |
nog_lorp Grandmaster Cheater
Reputation: 0
Joined: 26 Feb 2006 Posts: 743
|
Posted: Wed Nov 12, 2008 6:27 pm Post subject: |
|
|
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 |
|
 |
rapion124 Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Mar 2007 Posts: 1095
|
Posted: Wed Nov 12, 2008 7:47 pm Post subject: |
|
|
| Use RegisterHotkey. It's more efficient than GetAsyncKeyState because you don't waste CPU doing a loop.
|
|
| Back to top |
|
 |
blackmorpheus Expert Cheater
Reputation: 0
Joined: 05 Apr 2008 Posts: 159
|
Posted: Sat Nov 15, 2008 7:01 am Post subject: |
|
|
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 |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sat Nov 15, 2008 12:30 pm Post subject: |
|
|
| 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 |
|
 |
Heartless I post too much
Reputation: 0
Joined: 03 Dec 2006 Posts: 2436
|
Posted: Sat Nov 15, 2008 12:45 pm Post subject: |
|
|
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 |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Sat Nov 15, 2008 1:03 pm Post subject: |
|
|
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 |
|
 |
|