Hotkey help.

Posts 1–11 of 11 · Page 1 of 1
Hotkey help.
I have been searching google for a couple days and i can't find anything on hokeys that work with unfocused/focused app....Can someone tell me how to make a hotkey that works for a unfocused app?
Did you try calling the native RegisterHotkey Method? You'll have to pInvoke it though
(dllimport etc)
Great Virtual Keys....Again...Can someone show me a example of VK's i have googled it i can't find any good examples.
Quote Originally Posted by XxTylerxX View Post
Great Virtual Keys....Again...Can someone show me a example of VK's i have googled it i can't find any good examples.
Virtual-Key Codes (Windows)

Parameters

vKey [in]
int

Specifies one of 256 possible virtual-key codes. For more information, see Virtual Key Codes.

You can use left- and right-distinguishing constants to specify certain keys. See the Remarks section for further information.
That was in the link I gave you before, didn't see it?
Wow man ur going to have to learn to read API documentation... I mean, this is getting old. You can't just post everytime you don't know how to do something. atleast try to attempt it, post some source or something...

Once u find the function if u don't know how to use it its because u don't know C#... =/
Quote Originally Posted by why06 View Post
Wow man ur going to have to learn to read API documentation... I mean, this is getting old. You can't just post everytime you don't know how to do something. atleast try to attempt it, post some source or something...

Once u find the function if u don't know how to use it its because u don't know C#... =/
Err i do try before i post...actually i i try alot...and i cant post my source its to big but i ask mpgh because you all great coders i small noob coder...and i do research and stuff. When i get to the point of where i searched a couple of day and im getting no where i come here.
try this one (you'll need to download this file from the web tough (don't have the link nao (reinstalled windows + it wasn't compatible with 2010 only 2008)).

(there may be another thing then Globalevent that u can use but haven't found it yet.)

Globalevent_KeyDown (object sender,object KeyEventArgs e)
{
switch(e.KeyCode)
{
case Keys. (*YOUR KEY*):
(exsample) timer1.start
break;

case Keys. (*YOUR KEY*):
(exsample) timer1.stop
break;

case Keys. (*YOUR KEY*):
(exsample) timer2.start
break;

(ect.)
}
}
Quote Originally Posted by Kuro Tenshi View Post
try this one (you'll need to download this file from the web tough (don't have the link nao (reinstalled windows + it wasn't compatible with 2010 only 2008)).

(there may be another thing then Globalevent that u can use but haven't found it yet.)

Globalevent_KeyDown (object sender,object KeyEventArgs e)
{
switch(e.KeyCode)
{
case Keys. (*YOUR KEY*):
(exsample) timer1.start
break;

case Keys. (*YOUR KEY*):
(exsample) timer1.stop
break;

case Keys. (*YOUR KEY*):
(exsample) timer2.start
break;

(ect.)
}
}
well that doesnt work for unfocused forms...

in my opinion that should be done this way:

Code:
[DllImport("user32.dll", SetLastError = true)]
static extern Int16 GetAsyncKeyState(UInt16 virtualKeyCode);

private void backGroundWorker1_RunWorkerAsync(...)
{
     while (true)
     {
          if (GetKeyState( your vk key in bytes (eg. 0x2D - VK_INSERT) ) < 0)
          {
               // you get here when your key is pressed
          }

          System.Threading.Thread.Sleep(50);
     }
}
in attachements i add a file with an enumeration of the keyboard keys and the respective bytes.
VK.txtattachment deleted
i had this code before but it didn't work that well i have to say most keys didn't even work.
Srry that i need to double post but the way to make a getasynckeystate to work is precisely the same as VB only then you wont need to add ; behind it:

if u make a form or something just use a timer like i do:
Code:
public void hotkeyTest()
        {
            Boolean hotkey1;
            hotkey1 = GetAsyncKeyState(Keys.Multiply);
            if (hotkey1 == true)
            {
                //your event
            }
        }

private void tHotkey1_Tick(object sender, EventArgs e)
        {
            hotkeyTest();
        }
Posts 1–11 of 11 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us