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#]Hotkeys

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
yoyonerd
Grandmaster Cheater
Reputation: 0

Joined: 26 Apr 2008
Posts: 699
Location: -->formerly yoyonerd<--

PostPosted: Thu Dec 04, 2008 8:53 pm    Post subject: [C#]Hotkeys Reply with quote

so, i've used premade hotkey.cs files i found on code project

i've heard of getasynckeystate, and register hotkey, i've tried both

in c#, whats the best way to process both?

i can process one hotkey with registerhotkey, but i can't process two for some reason

with getasynckeystate, is it really necesarry i use a timer to check?, and same problem with registerhotkey, but i never tried

BASICALLY, please post a snippets for both, preferably to process the f1 and f2 keys

thanks a bunch!

for c#

Code:
protected override void WndProc(ref Message m)
        {
            const int WM_HOTKEY = 0x0312;
            const int VK_F1 = 0x71;

            switch (m.Msg)
            {
                case WM_HOTKEY:
                    MessageBox.Show("F1 Pressed");
                    break;
            }
            base.WndProc(ref m);
        }


can somebody get that to work, for f1 AND f2?

_________________


Last edited by yoyonerd on Thu Dec 04, 2008 9:09 pm; edited 1 time in total
Back to top
View user's profile Send private message AIM Address
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Thu Dec 04, 2008 8:59 pm    Post subject: Reply with quote

With RegisterHotKey you have to respond to WM_HOTKEY. When you register one, you set the ID for it.

http://msdn.microsoft.com/en-us/library/ms646279(VS.85).aspx

wParam is where you'll be checking the ID's... You will need to override WndProc to handle the message, of course.

With GetAsyncKeyState, yes you need to run it on a timer, or a loop / thread, just like the name would hint at.
Back to top
View user's profile Send private message
yoyonerd
Grandmaster Cheater
Reputation: 0

Joined: 26 Apr 2008
Posts: 699
Location: -->formerly yoyonerd<--

PostPosted: Thu Dec 04, 2008 9:24 pm    Post subject: Reply with quote

can you try and fix my code?
_________________
Back to top
View user's profile Send private message AIM Address
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Thu Dec 04, 2008 9:45 pm    Post subject: Reply with quote

yoyonerd wrote:
can you try and fix my code?


Like I said, check wParam within WM_HOTKEY. That is what is wrong.
Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Fri Dec 05, 2008 7:23 pm    Post subject: Reply with quote

Check out my keyboard hook.
_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
yoyonerd
Grandmaster Cheater
Reputation: 0

Joined: 26 Apr 2008
Posts: 699
Location: -->formerly yoyonerd<--

PostPosted: Sun Dec 07, 2008 12:34 pm    Post subject: Reply with quote

nvm, figured out what slovach was saying >.<

thanks though, and yeah samurai, i've looked at your keyboard hook before xD

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

Joined: 03 Jul 2008
Posts: 65
Location: middle of nowhere.

PostPosted: Sun Dec 07, 2008 1:31 pm    Post subject: Reply with quote

i would like to point out that system.windows.forms.keys should be the entire keys enum there should be little need to declare them elsewhere.
_________________
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 Dec 07, 2008 6:27 pm    Post subject: Reply with quote

yoyonerd wrote:
nvm, figured out what slovach was saying >.<

thanks though, and yeah samurai, i've looked at your keyboard hook before xD


also, you can use the Keys class, instead of defining everything yourself.
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
Page 1 of 1

 
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