First of all, thank you for Mark, Marco, Richard, Jack's respond to the
question, you guys provide a lot of help.
Jack asked a very good question below. As I said in the original message, I
want when the user press Print Screen key, it will activate the VB app.
By "activate" I mean the app will launch (with no form just code in module)
when window start, the user will not see any interface/form, kind of like
sleeping. But when the user press the Print Screen key, the app will print
the screen to the printer.
In addition, do any of you know how to place the app icon to the taskbar
when the launch the app, have some kind of focus to it. So when the user
hit PrintScr, the app will wake up & do its thing? And how to create a
right click menu to that icon in the taskbar? So I can provide option like
e.g. Settings, Exit, etc...
As to Marco/anyone, I don't know what a hook proj is, and I don't have any
experience in that area. Would you provide some more help/demo. Thanks
again for your respond.
Jason
"Jack Dunstan"
<jdunstan7@h... To: "professional vb" <pro_vb@p...>
.com> cc:
Subject: [pro_vb] Re: How to trap keys from keyboard in VB
08/21/2002 09:27
PM
Please respond to
"professional vb"
I was also intrigued by this post, like Marco I found the keyup event can
capture the printscreen. Also to add a little, I look into the keybd_event
api and with this you can code it so the printscreen actually only prints
the active window instead of the full screen (as would if you didn't have
the alt &printscreen held at same time.
code looks like this:
Const VK_SNAPSHOT = &H2C
Const KEYEVENTF_KEYDOWN = &H4
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal
bScan
As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeySnapshot Then
keybd_event VK_SNAPSHOT, 1, KEYEVENTF_KEYDOWN, &O0
KeyCode = 0
Exit Sub
End If
End Sub
Jason what exactly do you mean by "user press Print Screen key, it will
**activate** the VB app," - by "activate" do you mean the app is
minimized, i.e. does not have focus? If that's what you mean then Marco is
correct you will need to create some "hook" that taps into the Windows
messaging system so that it will detect (while the actual app is
"sleeping")
a keyboard event, specifically the printscreen.
hope that helps
Jack
----- Original Message -----
From: "Marco Straforini" <marco.straforini@c...>
To: "professional vb" <pro_vb@p...>
Sent: Wednesday, August 21, 2002 11:18 PM
Subject: [pro_vb] Re: How to trap keys from keyboard in VB
> I was so intrigued that I did some investigation (well, actually
> Mr. Google did it for me)
> It turns out that you cannot grab the printscreen key in the KeyDown
> event, but you can do it in the KeyUp!
>
> This is the code I used:
>
> Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
> If KeyCode = vbKeySnapshot Then
> Debug.Print "PrintScreen"
> End If
> End Sub
>
> Anyway, there is still the problem that you have to replicate
> this for all the forms in you application (and if one of them
> belongs to another project, tough luck).
>
> Marco
>
>
> ---
> Visual C# - A Guide for VB6 Developers
> This book will make it easy to transfer your skills
> from Visual Basic 6 to C#, the language of choice
> of the .NET Framework.
> http://www.wrox.com/ACON11.asp?ISBN=1861007175&p2p0059
>
>
---
Visual C# - A Guide for VB6 Developers
This book will make it easy to transfer your skills
from Visual Basic 6 to C#, the language of choice
of the .NET Framework.
http://www.wrox.com/ACON11.asp?ISBN=1861007175&p2p0059