Results 1 to 6 of 6

Thread: [RESOLVED] shortcut key "F7", even if app on minimiz, tray or in background

  1. #1

    Thread Starter
    Frenzied Member wiz126's Avatar
    Join Date
    Jul 2005
    Location
    Mars,Milky Way... Chit Chat Posts: 5,733
    Posts
    1,080

    Resolved [RESOLVED] shortcut key "F7", even if app on minimiz, tray or in background

    ok i have a full app that i want to add an "F7" shortcut key. when the use press "F7" then frmshortactive.show

    here is the problem, i wanat to have this shortcut to activate even if my app is minimized in background or in tray

    how would i do this?
    1) If your post has been adequately answered please click in your post on "Mark Thread Resolved".
    2) If someone has been useful to you please show your respect by rating their posts.
    3) Please use [highlight="VB"] 'your code goes in here [/highlight] tags when posting code.
    4) Before posting your question, make sure you checked this links:
    MICROSOFT MSDN -- VB FORUMS SEARCH

    5)Support Classic VB - A PETITION TO MICROSOFT

    ___________________________________________________________________________________
    THINGS TO KNOW ABOUT VB: || VB Examples/Demos
    What are Classes?
    || -
    Where to place a sub/function?(global) || Webbrowser control

  2. #2
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    Re: shortcut key "F7", even if app on minimiz, tray or in background

    Can it be done? If i am using MS Word with ur app in the background it wont let F7 get to your app, cos it is Spell check in Word. I dont think its possible.

    Prove me wrong people

  3. #3
    Lively Member
    Join Date
    Dec 2004
    Location
    E...A...R...T...H
    Posts
    88

    Re: shortcut key "F7", even if app on minimiz, tray or in background

    Ok this is a project i did recently so use it as you please.

    AutoClick.rar is the full project.

    FrmCAPM.rar is the form i used and has the code.
    Attached Files Attached Files
    Normality is what you make it.

  4. #4
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Re: shortcut key "F7", even if app on minimiz, tray or in background

    Here is some stuff on the web about keyboard hooks (which is what you want to be using).
    This world is not my home. I'm just passing through.

  5. #5
    Computer Science BS Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,339

    Re: shortcut key "F7", even if app on minimiz, tray or in background

    All you would have to do is use is the GetAsyncKeyState API. It reads input directly from your keyboard rather than use window messaging (which the Form_KeyPress, Form_KeyDown, and Form_KeyUp use), which means it'll work even if your app is not in focus. DirectInput can acheive the same thing, only it would be more code, yet would be more efficient. This is easier for you to use.

    VB Code:
    1. Private Declare Function GetAsyncKeyState Lib "user32" _
    2.     (ByVal vKey As Long) As Integer
    3.  
    4. Private Const Key_F7 As Long = 118
    5.  
    6. Private Sub Timer1_Timer()
    7.        
    8.     Dim Key As Integer
    9.  
    10.     Key = GetAsyncKeyState(Key_F7)
    11.        
    12.     If Key = -32767 Then
    13.  
    14.         MsgBox "You pressed F7"
    15.  
    16.         frmshortactive.Show
    17.            
    18.     End If
    19.  
    20. End Sub

    It's that easy

  6. #6

    Thread Starter
    Frenzied Member wiz126's Avatar
    Join Date
    Jul 2005
    Location
    Mars,Milky Way... Chit Chat Posts: 5,733
    Posts
    1,080

    Re: shortcut key "F7", even if app on minimiz, tray or in background

    Thx Jacob, that was what i was looking for i just chaged it to sut me,

    I_Love_My_Vans, they way jacob did is when you using "word" and click on F7 for spell check then what will happend is that the spell check will comup like normal and in my app the code will take place just in the background of "word"






    RESOLVED
    1) If your post has been adequately answered please click in your post on "Mark Thread Resolved".
    2) If someone has been useful to you please show your respect by rating their posts.
    3) Please use [highlight="VB"] 'your code goes in here [/highlight] tags when posting code.
    4) Before posting your question, make sure you checked this links:
    MICROSOFT MSDN -- VB FORUMS SEARCH

    5)Support Classic VB - A PETITION TO MICROSOFT

    ___________________________________________________________________________________
    THINGS TO KNOW ABOUT VB: || VB Examples/Demos
    What are Classes?
    || -
    Where to place a sub/function?(global) || Webbrowser control

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width