Thread: Hotkey help.

Results 1 to 11 of 11
  1. #1
    XxTylerxX's Avatar
    Join Date
    Jun 2009
    Gender
    male
    Location
    MPGH
    Posts
    1,269
    Reputation
    14
    Thanks
    522

    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?
    Respect List:
    Nooby Banana
    Bombsaway
    Luke

  2. #2
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow

  3. #3
    B1ackAnge1's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Posts
    455
    Reputation
    74
    Thanks
    344
    My Mood
    Cynical
    Did you try calling the native RegisterHotkey Method? You'll have to pInvoke it though
    (dllimport etc)

  4. #4
    XxTylerxX's Avatar
    Join Date
    Jun 2009
    Gender
    male
    Location
    MPGH
    Posts
    1,269
    Reputation
    14
    Thanks
    522
    Great Virtual Keys....Again...Can someone show me a example of VK's i have googled it i can't find any good examples.
    Respect List:
    Nooby Banana
    Bombsaway
    Luke

  5. #5
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    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#... =/

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  6. #6
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    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?

  7. #7
    XxTylerxX's Avatar
    Join Date
    Jun 2009
    Gender
    male
    Location
    MPGH
    Posts
    1,269
    Reputation
    14
    Thanks
    522
    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.
    Respect List:
    Nooby Banana
    Bombsaway
    Luke

  8. #8
    Kuro Tenshi's Avatar
    Join Date
    Jan 2009
    Gender
    male
    Location
    Where arth thou be
    Posts
    3,635
    Reputation
    70
    Thanks
    746
    My Mood
    Blah
    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.)
    }
    }
    Last edited by Kuro Tenshi; 04-26-2010 at 02:41 AM.
    DigiDrawing|+ ( (Elfen Archer) )
    Link:
    https://www.mpgh.net/forum/148-showro...en-archer.html


    @ Anime Section,Otaku/weeabo (orz.) @Graphics Section, Novice DigiArtist


    neuest gift from Yura~Chan:
    https://bakyurayuu.deviantar*****m/#/d372taw
    2nd Place MOTM#9 Theme: CharMods - Combat Arms [No - Thanks] button
    come on you know that don't want to push that ordinary button

  9. The Following 2 Users Say Thank You to Kuro Tenshi For This Useful Post:

    why06 (04-26-2010),XxTylerxX (04-26-2010)

  10. #9
    kilert's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Posts
    65
    Reputation
    10
    Thanks
    6
    My Mood
    Hot
    Quote Originally Posted by pspiso 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.

  11. #10
    Kuro Tenshi's Avatar
    Join Date
    Jan 2009
    Gender
    male
    Location
    Where arth thou be
    Posts
    3,635
    Reputation
    70
    Thanks
    746
    My Mood
    Blah
    i had this code before but it didn't work that well i have to say most keys didn't even work.
    DigiDrawing|+ ( (Elfen Archer) )
    Link:
    https://www.mpgh.net/forum/148-showro...en-archer.html


    @ Anime Section,Otaku/weeabo (orz.) @Graphics Section, Novice DigiArtist


    neuest gift from Yura~Chan:
    https://bakyurayuu.deviantar*****m/#/d372taw
    2nd Place MOTM#9 Theme: CharMods - Combat Arms [No - Thanks] button
    come on you know that don't want to push that ordinary button

  12. #11
    Kuro Tenshi's Avatar
    Join Date
    Jan 2009
    Gender
    male
    Location
    Where arth thou be
    Posts
    3,635
    Reputation
    70
    Thanks
    746
    My Mood
    Blah
    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();
            }
    Last edited by Kuro Tenshi; 05-15-2010 at 12:19 AM.
    DigiDrawing|+ ( (Elfen Archer) )
    Link:
    https://www.mpgh.net/forum/148-showro...en-archer.html


    @ Anime Section,Otaku/weeabo (orz.) @Graphics Section, Novice DigiArtist


    neuest gift from Yura~Chan:
    https://bakyurayuu.deviantar*****m/#/d372taw
    2nd Place MOTM#9 Theme: CharMods - Combat Arms [No - Thanks] button
    come on you know that don't want to push that ordinary button

Similar Threads

  1. VB08 HOTkey (help)
    By boyd45 in forum Visual Basic Programming
    Replies: 3
    Last Post: 06-21-2008, 02:22 PM
  2. [HELP] VB6 Hotkey for Zoom not working
    By SteeL in forum WarRock - International Hacks
    Replies: 13
    Last Post: 11-10-2007, 03:06 AM
  3. Vb (hotkey) Help
    By redarr in forum Visual Basic Programming
    Replies: 13
    Last Post: 11-05-2007, 03:31 PM
  4. [Help]With Hotkeys..
    By dor619 in forum Visual Basic Programming
    Replies: 2
    Last Post: 10-14-2007, 12:03 PM
  5. [Help] How do i set a hotkey to Scope?
    By wr194t in forum Visual Basic Programming
    Replies: 9
    Last Post: 09-27-2007, 04:53 PM