Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: OuTLawZGoSu on April 14, 2004, 08:11 PM

Title: Dissabling Buttons.
Post by: OuTLawZGoSu on April 14, 2004, 08:11 PM
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.
Title: Re:Dissabling Buttons.
Post by: Grok on April 14, 2004, 08:13 PM
Quote from: OuTLawZGoSu on April 14, 2004, 08:11 PM
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.

Replace the keyboard driver.

P.S.  Not likely with VB.
Title: Re:Dissabling Buttons.
Post by: OuTLawZGoSu on April 14, 2004, 11:29 PM
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.

Title: Re:Dissabling Buttons.
Post by: Fr0z3N on April 14, 2004, 11:38 PM
Try GetAsyncKeyState using the API


Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Title: Re:Dissabling Buttons.
Post by: Grok on April 14, 2004, 11:55 PM
If there's something you don't want seen, just use pgp tools to encrypt it.
Title: Re:Dissabling Buttons.
Post by: hismajesty on April 15, 2004, 06:05 AM
Log the keys and compare.
Title: Re:Dissabling Buttons.
Post by: Telos on April 15, 2004, 07:53 AM
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
Title: Re:Dissabling Buttons.
Post by: iago on April 15, 2004, 08:24 AM
Pull out your IDE cable and take it with you when you leave, kthx
Title: Re:Dissabling Buttons.
Post by: Networks on April 15, 2004, 09:05 AM
Quote from: iago on April 15, 2004, 08:24 AM
Pull out your IDE cable and take it with you when you leave, kthx

Who is grounding who? lol
Title: Re:Dissabling Buttons.
Post by: OuTLawZGoSu on April 15, 2004, 10:42 AM
Quote from: Fr0z3N on April 14, 2004, 11:38 PM
Try GetAsyncKeyState using the API


Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer


So how would I put that in a Form_Keypress()

If GetAsyncKeyState = "13" then
'message
ElseIf GetAsyncKeyState = (ALT KEY Here) Then
'message
EndIf


I'm at a skool computer right now so I cant test it.
Title: Re:Dissabling Buttons.
Post by: iago on April 15, 2004, 11:44 AM
Quote from: Networks on April 15, 2004, 09:05 AM
Quote from: iago on April 15, 2004, 08:24 AM
Pull out your IDE cable and take it with you when you leave, kthx

Who is grounding who? lol

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.
Title: Re:Dissabling Buttons.
Post by: Tuberload on April 15, 2004, 01:03 PM
Quote from: iago on April 15, 2004, 11:44 AM
Heck, I find a Screensaver password is more than enough to keep my family away from my .. . *porn*.

:P
Title: Re:Dissabling Buttons.
Post by: iago on April 15, 2004, 01:20 PM
Quote from: Tuberload on April 15, 2004, 01:03 PM
Quote from: iago on April 15, 2004, 11:44 AM
Heck, I find a Screensaver password is more than enough to keep my family away from my .. . *porn*.

:P

haha, I was going to type "po..... stuff" but I decided that was too obvious :)
Title: Re:Dissabling Buttons.
Post by: Eli_1 on April 15, 2004, 02:50 PM
Quote from: OuTLawZGoSu on April 15, 2004, 10:42 AM
So how would I put that in a Form_Keypress()

If GetAsyncKeyState = "13" then
'message
ElseIf GetAsyncKeyState = (ALT KEY Here) Then
'message
EndIf

I'm at a skool computer right now so I cant test it.

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:

if GetAsyncKeyState(13) = -32767 Then
   '// doSomething();
end if

Title: Re:Dissabling Buttons.
Post by: OuTLawZGoSu on April 16, 2004, 10:44 AM
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:

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:

Private sub Btn1_Click()
text2.text = asc(text1.text)
End sub

'didnt work.


Quote from: Telos on April 15, 2004, 07:53 AM
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

Think you can find more info on this?
Title: Re:Dissabling Buttons.
Post by: Eli_1 on April 16, 2004, 01:48 PM
It's in c++, but it's just an API call so it shouldn't be so hard to port to VB.


void DisableCAD(bool disabled) {
   SystemParametersInfo SPI_SCREENSAVERRUNNING, disabled, NULL, NULL);
}



' // [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
Title: Re:Dissabling Buttons.
Post by: OuTLawZGoSu on April 16, 2004, 11:25 PM
Got no idea wat that is :/
Title: Re:Dissabling Buttons.
Post by: iago on April 17, 2004, 02:55 AM
Quote from: OuTLawZGoSu on April 16, 2004, 11:25 PM
Got no idea wat that is :/

You'll get over it.
Title: Re:Dissabling Buttons.
Post by: OuTLawZGoSu on April 17, 2004, 10:23 AM
Wow! Thx for the help iago!
Title: Re:Dissabling Buttons.
Post by: GoSuGaMING on April 17, 2004, 11:15 AM
does anyone know off hand what the keyascii for tab is?
Title: Re:Dissabling Buttons.
Post by: Adron on April 17, 2004, 01:19 PM
Quote from: GoSuGaMING on April 17, 2004, 11:15 AM
does anyone know off hand what the keyascii for tab is?

9
Title: Re:Dissabling Buttons.
Post by: iago on April 17, 2004, 02:15 PM
Doesnt' vb have constants. VBTAB or VB_TAB or VBKEYTAB or something like that?
Title: Re:Dissabling Buttons.
Post by: dxoigmn on April 17, 2004, 03:14 PM
Quote from: iago on April 17, 2004, 02:15 PM
Doesnt' vb have constants. VBTAB or VB_TAB or VBKEYTAB or something like that?

Yes, vbKeyTab.
Title: Re:Dissabling Buttons.
Post by: OuTLawZGoSu on April 17, 2004, 03:18 PM
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?
Title: Re:Dissabling Buttons.
Post by: dxoigmn on April 17, 2004, 03:45 PM
Quote from: OuTLawZGoSu on April 17, 2004, 03:18 PM
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?

I *think* the windows button just sends Ctrl+Esc.
Title: Re:Dissabling Buttons.
Post by: K on April 17, 2004, 03:56 PM
Quick search for '"windows key" key code':
VK_LWIN = 0x5B;
Title: Re:Dissabling Buttons.
Post by: iago on April 17, 2004, 04:03 PM
Quote from: K on April 17, 2004, 03:56 PM
Quick search for '"windows key" key code':
VK_LWIN = 0x5B;

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.
Title: Re:Dissabling Buttons.
Post by: CrAz3D on April 17, 2004, 04:04 PM
Unless you look through each process,
App.TaskVisible = False should hide your program from ctrl alt del
Title: Re:Dissabling Buttons.
Post by: iago on April 17, 2004, 04:07 PM
Quote from: CrAz3D on April 17, 2004, 04:04 PM
Unless you look through each process,
App.TaskVisible = False should hide your program from ctrl alt del

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.
Title: Re:Dissabling Buttons.
Post by: K on April 17, 2004, 04:45 PM
Quote from: iago on April 17, 2004, 04:03 PM
Quote from: K on April 17, 2004, 03:56 PM
Quick search for '"windows key" key code':
VK_LWIN = 0x5B;

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.

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*