|
-
Jan 13th, 2006, 07:56 AM
#1
Thread Starter
PowerPoster
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.
-
Jan 13th, 2006, 08:16 AM
#2
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.
-
Jan 13th, 2006, 08:17 AM
#3
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.
-
Jan 13th, 2006, 08:23 AM
#4
Re: Disable Windows Key
 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 ).
-
Jan 13th, 2006, 08:26 AM
#5
Re: Disable Windows Key
 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.
-
Jan 13th, 2006, 08:34 AM
#6
Re: Disable Windows Key
 Originally Posted by Joacim Andersson
Of course I can...
You searched for "window s 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?
-
Jan 13th, 2006, 09:08 AM
#7
Addicted Member
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?
-
Jan 16th, 2006, 07:21 AM
#8
Thread Starter
PowerPoster
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.
-
Aug 14th, 2006, 07:26 AM
#9
New Member
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
-
Oct 7th, 2006, 03:33 AM
#10
Member
Re: Disable Windows Key [Resolved]
@Joacim
why do i get this compiler error "Invalid use of AddressOf Operator"?
in this line:
VB Code:
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.
-
Oct 7th, 2006, 08:12 PM
#11
Re: Disable Windows Key [Resolved]
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|