Results 1 to 11 of 11

Thread: Disable Windows Key [Resolved]

  1. #1

    Thread Starter
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Resolved Disable Windows Key [Resolved]

    I made an app that allows me not to logoff my WinXP computer at work. The Form is always on top and it asks for a password to access Windows. It just saves keep logging off and on evertime I leave the computer.

    My problem is while the app is running if you press the Windows key the Start menu pops up. All other keys are disabled Ctrl+Esc, Ctrl+Tab etc. I've even sorted out Taskmanger so it can't be end tasked. I think the Keyascii is 91 for this key.

    The app works perfect with Win98 but with WinXP the Windows key is still active.

    Thanks.
    Last edited by Keithuk; Jan 16th, 2006 at 07:24 AM.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Disable Windows Key

    See JBD2's post in this thread. I have no idea if it works as I've never had the need or desire to try it out. However, if you do a search for Windows Key, you will find this question being asked a lot, but not a whole lot of answers have been returned.

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Disable Windows Key

    I answered this question yesterday . Look at the code here, it uses a lowlevel keyboard hook to disable the left and the right windows key.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Disable Windows Key

    Quote Originally Posted by Joacim Andersson
    I answered this question yesterday . Look at the code here, it uses a lowlevel keyboard hook to disable the left and the right windows key.
    Why the heck didn't your post show up when I did a search (I realize that you can't answer that question ).

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Disable Windows Key

    Quote Originally Posted by Hack
    Why the heck didn't your post show up when I did a search (I realize that you can't answer that question ).
    Of course I can...

    You searched for "windows key", and in my post I only typed "window key", nobody else in that thread called it "window/s key" even if that was what they asked for.

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Disable Windows Key

    Quote Originally Posted by Joacim Andersson
    Of course I can...

    You searched for "windows key", and in my post I only typed "window key", nobody else in that thread called it "window/s key" even if that was what they asked for.
    When will I learn never to use "you can't" and "Joacim Andersson" in the same sentence?

  7. #7
    Addicted Member Bregalad's Avatar
    Join Date
    Jul 2000
    Location
    Oslo,Norway
    Posts
    183

    Re: Disable Windows Key

    If all you want it for is to avoid logging off and on WinXP, why not just use CTRL+ALT+DEL and select Lock Computer?

  8. #8

    Thread Starter
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: Disable Windows Key

    Thanks Joacim Andersson your code works for the Windows key. But I've found that Ctrl+Esc isn't trapped now.

    So I presume this topic is resolved now for the Windows key, thank you all.
    Last edited by Keithuk; Jan 16th, 2006 at 07:25 AM.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  9. #9
    New Member
    Join Date
    Aug 2006
    Posts
    1

    Question Re: Disable Windows Key [Resolved]

    hello keithuk,i am developing an application for hook keyboard,so it disables special key combinations,for example CTRL+ALT+DEL,ALT+TAB...
    in my application there is a number of checkboxes,one for each key combination,but the application do not work in the just manner.
    i have problems about understanding this procedure, i put the code,if someone would give me an help i will be very pleased...

    Private Function Keyboard_Proc(ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer
    Dim bProc As Boolean = False

    Select Case wParam
    Case 256, 257, 260, 261
    'Alt+Tab, Alt+Esc, Ctrl+Esc, Windows Key
    bProc = ((lParam.vkCode = 9) AndAlso (lParam.flags = 32)) Or _
    ((lParam.vkCode = 27) AndAlso (lParam.flags = 32)) Or _
    ((lParam.vkCode = 27) AndAlso (lParam.flags = 0)) Or _
    ((lParam.vkCode = 91) AndAlso (lParam.flags = 1)) Or _
    ((lParam.vkCode = 92) AndAlso (lParam.flags = 1))
    End Select

    If bProc = True Then
    Return 1
    Else
    Return CallNextHookEx(0, nCode, wParam, lParam)
    End If
    End Function

    i do not understand the values of "lparam.flags", why 0 or 1 or 32???

    enri

  10. #10
    Member
    Join Date
    Jul 2006
    Posts
    53

    Re: Disable Windows Key [Resolved]

    @Joacim

    why do i get this compiler error "Invalid use of AddressOf Operator"?
    in this line:

    VB Code:
    1. hKeyb = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf KeybCallback, App.hInstance, 0&)

    did i missed something? i just copied and pasted your code...



    Edit:
    ok got it now...the code must be in a module
    Last edited by ogagsme; Oct 7th, 2006 at 04:32 AM.

  11. #11
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Disable Windows Key [Resolved]

    Quote Originally Posted by ogagsme
    ok got it now...the code must be in a module
    Correct. All hooks and callbacks in VB must reside in a regular BAS module. They can not be in any form of class modules (and a Form is a sort of class module), the reason for this is that a class have a reference counter to keep track of the number of references it has. But a callback is called by an external thread and doesn't have a reference to any object.

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