Valhalla Legends Forums Archive | Visual Basic Programming | Dissabling Buttons.

AuthorMessageTime
OuTLawZGoSu
How can I make it so when a person presses the Windows button or CTRL+ALT+DEL, it wont work. Instead, it will show a message, " Error".

If the same meathod can be used for all the buttons, post that here too.
April 15, 2004, 1:11 AM
Grok
[quote author=OuTLawZGoSu link=board=31;threadid=6306;start=0#msg55170 date=1081991503]
How can I make it so when a person presses the Windows button or CTRL+ALT+DEL, it wont work. Instead, it will show a message, " Error".

If the same meathod can be used for all the buttons, post that here too.
[/quote]

Replace the keyboard driver.

P.S. Not likely with VB.
April 15, 2004, 1:13 AM
OuTLawZGoSu
I meant only in the program, not all the programs.
I made a password program to prevent pricks ( my dad ) from gettin on my computer. But when I hit the Window Button ( between Left CTRL and Left ALT ), you can see the taskbar. Then you can just use the " Show the Desktop " feature. I need to prevent that.

Also, since I dont know how to dissable CTRL+ALT+DEL, I named the program " Norton antivirus" and put the same icon as NAV. My dad isn't THAT smart to figure out that it's not the real norton. Cleaver eh? But, not to take any chances, I need to dissable those buttons.

April 15, 2004, 4:29 AM
Fr0z3N
Try GetAsyncKeyState using the API

[code]
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
[/code]
April 15, 2004, 4:38 AM
Grok
If there's something you don't want seen, just use pgp tools to encrypt it.
April 15, 2004, 4:55 AM
hismajesty
Log the keys and compare.
April 15, 2004, 11:05 AM
Telos
There used to be a semi-hackish way to do this by making the OS think the screensaver was enabled but it disabled those keys systemwide while the program was running
April 15, 2004, 12:53 PM
iago
Pull out your IDE cable and take it with you when you leave, kthx
April 15, 2004, 1:24 PM
Networks
[quote author=iago link=board=31;threadid=6306;start=0#msg55246 date=1082035468]
Pull out your IDE cable and take it with you when you leave, kthx
[/quote]

Who is grounding who? lol
April 15, 2004, 2:05 PM
OuTLawZGoSu
[quote author=Fr0z3N link=board=31;threadid=6306;start=0#msg55207 date=1082003906]
Try GetAsyncKeyState using the API

[code]
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
[/code]
[/quote]

So how would I put that in a Form_Keypress()
[code]
If GetAsyncKeyState = "13" then
'message
ElseIf GetAsyncKeyState = (ALT KEY Here) Then
'message
EndIf
[/code]

I'm at a skool computer right now so I cant test it.
April 15, 2004, 3:42 PM
iago
[quote author=Networks link=board=31;threadid=6306;start=0#msg55254 date=1082037932]
[quote author=iago link=board=31;threadid=6306;start=0#msg55246 date=1082035468]
Pull out your IDE cable and take it with you when you leave, kthx
[/quote]

Who is grounding who? lol
[/quote]

Haha, I initially read that to mean electrical grounding, but I didn't think he wanted to electrocute his dad.

Why don't you just log off and not give him access to your Windows password?

Heck, I find a Screensaver password is more than enough to keep my family away from my .. . stuff.
April 15, 2004, 4:44 PM
Tuberload
[quote author=iago link=board=31;threadid=6306;start=0#msg55268 date=1082047453]
Heck, I find a Screensaver password is more than enough to keep my family away from my .. . *porn*.
[/quote]

:P
April 15, 2004, 6:03 PM
iago
[quote author=Tuberload link=board=31;threadid=6306;start=0#msg55280 date=1082052210]
[quote author=iago link=board=31;threadid=6306;start=0#msg55268 date=1082047453]
Heck, I find a Screensaver password is more than enough to keep my family away from my .. . *porn*.
[/quote]

:P
[/quote]

haha, I was going to type "po..... stuff" but I decided that was too obvious :)
April 15, 2004, 6:20 PM
Eli_1
[quote author=OuTLawZGoSu link=board=31;threadid=6306;start=0#msg55259 date=1082043770]
So how would I put that in a Form_Keypress()
[code]
If GetAsyncKeyState = "13" then
'message
ElseIf GetAsyncKeyState = (ALT KEY Here) Then
'message
EndIf
[/code]
I'm at a skool computer right now so I cant test it.
[/quote]

No, if your going to put it in keypress, you could just use KeyAscii. If you looked at the prototype of GetAsyncKeyState you'd see that you need to pass something to that function. So it would be:
[code]
if GetAsyncKeyState(13) = -32767 Then
'// doSomething();
end if
[/code]
April 15, 2004, 7:50 PM
OuTLawZGoSu
[quote]
No, if your going to put it in keypress, you could just use KeyAscii. If you looked at the prototype of GetAsyncKeyState you'd see that you need to pass something to that function. So it would be:
[/quote]

Oh ye, I forgot about KeyAscii. Aight I'll try that.

EDIT: Eh.. wats the ascii code for the ALT, CTRL, and the "Windows" Button ( the one located between alt and ctrl).

I tryed:
[code]
Private sub Btn1_Click()
text2.text = asc(text1.text)
End sub

'didnt work.
[/code]

[quote author=Telos link=board=31;threadid=6306;start=0#msg55239 date=1082033606]
There used to be a semi-hackish way to do this by making the OS think the screensaver was enabled but it disabled those keys systemwide while the program was running
[/quote]

Think you can find more info on this?
April 16, 2004, 3:44 PM
Eli_1
It's in c++, but it's just an API call so it shouldn't be so hard to port to VB.

[code]
void DisableCAD(bool disabled) {
SystemParametersInfo SPI_SCREENSAVERRUNNING, disabled, NULL, NULL);
}
[/code]

[code]
' // [Edit]
Private Declare Function SystemParametersInfo _
Lib "user32" Alias "SystemParametersInfoA" _
(ByVal uAction As Long, _
ByVal uParam As Long, _
ByVal lpvParam As Any, _
ByVal fuWinIni As Long) As Long
[/code]
April 16, 2004, 6:48 PM
OuTLawZGoSu
Got no idea wat that is :/
April 17, 2004, 4:25 AM
iago
[quote author=OuTLawZGoSu link=board=31;threadid=6306;start=15#msg55489 date=1082175931]
Got no idea wat that is :/
[/quote]

You'll get over it.
April 17, 2004, 7:55 AM
OuTLawZGoSu
Wow! Thx for the help iago!
April 17, 2004, 3:23 PM
GoSuGaMING
does anyone know off hand what the keyascii for tab is?
April 17, 2004, 4:15 PM
Adron
[quote author=GoSuGaMING link=board=31;threadid=6306;start=15#msg55525 date=1082218508]
does anyone know off hand what the keyascii for tab is?
[/quote]

9
April 17, 2004, 6:19 PM
iago
Doesnt' vb have constants. VBTAB or VB_TAB or VBKEYTAB or something like that?
April 17, 2004, 7:15 PM
kamakazie
[quote author=iago link=board=31;threadid=6306;start=15#msg55564 date=1082229319]
Doesnt' vb have constants. VBTAB or VB_TAB or VBKEYTAB or something like that?
[/quote]

Yes, vbKeyTab.
April 17, 2004, 8:14 PM
OuTLawZGoSu
Aight, I've been searching and I found this.
http://web.cs.mun.ca/~michael/c/ascii-table.html

The only problem I have is finding the Windows Button.
Any of those abreviations stand for that button?
April 17, 2004, 8:18 PM
kamakazie
[quote author=OuTLawZGoSu link=board=31;threadid=6306;start=15#msg55582 date=1082233110]
Aight, I've been searching and I found this.
http://web.cs.mun.ca/~michael/c/ascii-table.html

The only problem I have is finding the Windows Button.
Any of those abreviations stand for that button?
[/quote]

I *think* the windows button just sends Ctrl+Esc.
April 17, 2004, 8:45 PM
K
Quick search for '"windows key" key code':
VK_LWIN = 0x5B;
April 17, 2004, 8:56 PM
iago
[quote author=K link=board=31;threadid=6306;start=15#msg55584 date=1082235385]
Quick search for '"windows key" key code':
VK_LWIN = 0x5B;
[/quote]

That is the same key as ']', isn't it? At least, that's the ascii value of ']'.

And I don't think the windows key has a code, or at least the code doesn't get passed to the form, but why don't you try displaying all pressed keys? Then you'd see the code.
April 17, 2004, 9:03 PM
CrAz3D
Unless you look through each process,
App.TaskVisible = False should hide your program from ctrl alt del
April 17, 2004, 9:04 PM
iago
[quote author=CrAz3D link=board=31;threadid=6306;start=15#msg55586 date=1082235893]
Unless you look through each process,
App.TaskVisible = False should hide your program from ctrl alt del
[/quote]

That's not a bad idea, there's a program called "window hider" I posted on the general forum some time ago that will hide programs from ctrl-alt-delete and from clicking on them. You wouldn't be able see the window either, though.
April 17, 2004, 9:07 PM
K
[quote author=iago link=board=31;threadid=6306;start=15#msg55585 date=1082235829]
[quote author=K link=board=31;threadid=6306;start=15#msg55584 date=1082235385]
Quick search for '"windows key" key code':
VK_LWIN = 0x5B;
[/quote]

That is the same key as ']', isn't it? At least, that's the ascii value of ']'.

And I don't think the windows key has a code, or at least the code doesn't get passed to the form, but why don't you try displaying all pressed keys? Then you'd see the code.
[/quote]

I didn't think the windows key was passed on to applications either, but I found a code example that appeared to register it as a hotkey using that constant. *Shrug*
April 17, 2004, 9:45 PM

Search