Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Create a Boss Key? 2

Status
Not open for further replies.

Mizfar

Programmer
Sep 1, 2005
6
GB
I am trying to create an application with VB.NET 2003 version, and am trying to make a Boss Key (This is, for examlpe When F12 is pressed it will Hide the application, and if it is pressed again, it will show it).

I am having a little trouble with it because I am using the Me.Hide() method which works fine until you need to show the form again. This is because once the form is hidden it has lost focus and i cant manage to cacth the next Keypress.

I would be grateful if you couls explain to me clearly, as I am very new to VB.NET, how I couls get around this problem.
 
If you are prepared to have an icon in the systray you can use:

Private Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged
If Me.WindowState = FormWindowState.Minimized Then
Me.Hide()
NotifyIcon1.Visible = True
End If
End Sub
Private Sub NotifyIcon1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles NotifyIcon1.DoubleClick
NotifyIcon1.Visible = False
Me.Show()
Me.WindowState = FormWindowState.Normal
End Sub
 
Thanks very much for the help, I will use your method but is it possible to do it without having a Notify icon?
 
you couls make the notifyicon invisible.

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
sorry kevinf2349 already suggest sthat.

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
The problem is if i made it invisble, It just shows a gap in taskbar, and I wanted to make it so that the application hides and show by pressing F12.
From what I have read so far it can be done by Multithreading, but I dont quite understand how to implement that ibto ny application. I would be grateful if you could explain it for me. Thanks
 
Would a timer that polls the F12 key every 0.1 second work?
 
If you did not want to use F12, but wanted to user Ctrl+F12 ,for example, you could Register a HotKey. I have not got VB.NET code for this but I have managed it in Delphi.

If not when the form is hiden you could use the GetASyncKeyState Function from User32.dll. Again I have VB6 Source but not DOTNET.
I realy should use .NET more.
Try looking for VB.NET keylogging programs on PlanetSourceCode.Com. That might help

Thanx!

Dave Shaw
Nothing is Impossible, it is just something I haven't got round to doing. - Me
History admires the wise, but elevates the brave. - Edmund Morris
 
Thanks viper for the advice.
Also if you could post the VB6 source to make it clearer for me, I would appreciate it.

Thanks.
 
Could someone please explain to me what I have done wrong here:

Code:
    Private Sub frmMain_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        If e.KeyCode = Keys.F12 Then
            Me.Hide()
        End If
    End Sub

As the code indicates that the when if the F12 key is pressed then show form. but it doesnt seem to do anything when the F12 key is pressed, could someone please explain this to me.
Thanks
 
you tell it to hide not show.

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
Okay, thanks so much guys, I think I figured it out.
I just need to find out how to capture a keystroke using the timer.

Code:
Private Sub HideTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles HideTimer.Tick
        Dim k As System.Windows.Forms.KeyEventArgs
        If k.KeyCode = Keys.F12 Then
            Me.Show()
            HideTimer.Enabled = False
        End If
This is what I have tried so far, but no luck.
I need to find a way to capture the Keystroke with the timer.
If any of you know how this may be done please explain it to me.
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top