View previous topic :: View next topic |
Author |
Message |
Frouk Grandmaster Cheater
Reputation: 5
Joined: 22 Jun 2021 Posts: 511
|
Posted: Sun Oct 17, 2021 6:28 am Post subject: [C Code]What is better? |
|
|
What is better when creating and using hotkey?
or
Code: | GetAsyncKeyState() //If exists |
?
And game crashing when creating thread in auto assembler script
And one more thing, i can't use hotkey when creating one in c code
|
|
Back to top |
|
 |
Csimbi I post too much
Reputation: 97
Joined: 14 Jul 2007 Posts: 3325
|
Posted: Sun Oct 17, 2021 6:48 am Post subject: |
|
|
Async is better because is very fast
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun Oct 17, 2021 7:51 pm Post subject: |
|
|
Neither is 'better' and have their own purposes.
Csimbi wrote: | Async is better because is very fast |
It being 'very fast' is because it is async. It is designed to return immediately with no locking/blocking. However, it has downsides as well because of how it works and can result in inaccurate results when polling for keys based on various conditions.
Some of which can be found on its API page:
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getasynckeystate
GetKeyState has its own ups/downs as well:
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getkeystate
In most cases, GetAsyncKeyState is plenty for hotkeys, but should keep in mind it may fail/not be accurate/not always catch keys depending on what else is running and doing things with the key state buffer of the system.
A more ideal solution would be to hook onto the targets input handling and do things that way for the best accuracy and ability to block presses from reaching the target if you wanted to as well.
_________________
- Retired. |
|
Back to top |
|
 |
OldCheatEngineUser Whateven rank
Reputation: 20
Joined: 01 Feb 2016 Posts: 1586
|
Posted: Mon Oct 18, 2021 5:57 pm Post subject: Re: [C Code]What is better? |
|
|
Frouk wrote: | And one more thing, i can't use hotkey when creating one in c code |
if you are making a GUI application and/or using a message loop, and you want to assign multiple hotkeys for several functions you have, then: (choose either one)
- get the state for all keys and parse keys you are interested in using switch case... (GetKeyboardState)
- register system wide hotkey (RegisterHotKey)
- if you are really experienced win32 programmer, then you can go for SetWindowsHookEx (note that you need to inject your dll into target's memory)
this is what I used to do in past when I needed several hotkeys, good luck.
_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote: | i am a sweetheart. |
|
|
Back to top |
|
 |
|