none
How detect Hotkeys while minimized? RRS feed

  • Question

  • Hi there. I have this proyect in Visual Studio 2017 (Visual Basic, Windows Forms, .NET Framework 4). How i can maximize the proyect while it is minimized or unfocused when i press Ctrl+another key?

    Thank you

    Monday, November 12, 2018 5:58 AM

All replies

  • You can define the external RegisterHotKey function, call it in Form_Load, and handle the WM_HOTKEY notification:

    Use MOD_CONTROL (&H2) instead of MOD_ALT if you want <Ctrl> key. Or use a specific combination of keys.

    In order to maximise the form, try ‘WindowState = FormWindowState.Maximized’.




    • Edited by Viorel_MVP Monday, November 12, 2018 7:40 AM
    Monday, November 12, 2018 7:39 AM
  • Thank you for reply. I just try that forum but it doesn't work
    Monday, November 12, 2018 1:24 PM
  • Hi Micaelads,

    Welcome to the MSDN forum.

    It seems your issue is about the VB.NET development and our forum is to discuss the VS IDE, I will help you move this thread to the appropriate forum for a better support, thank you for your understanding.

    Best regards,

    Sara


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Tuesday, November 13, 2018 8:21 AM
  • Hi,

    try the code,set F10  as hotkey

    Imports System.Runtime.InteropServices
    
    Public Class Form1
        <DllImport("user32.dll")>
        Public Shared Function RegisterHotKey(ByVal hWnd As IntPtr, ByVal id As UInt32, ByVal fsModifiers As UInt32, ByVal vk As UInt32) As UInt32
    
        End Function
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            RegisterHotKey(Me.Handle, 247696411, 0, CUInt(Keys.F10))
        End Sub
        Protected Overrides Sub WndProc(ByRef m As Message)
            Const WM_HOTKEY As Integer = &H312
    
            If m.Msg = WM_HOTKEY AndAlso m.WParam.ToInt32() = 247696411 Then
                Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
            End If
    
            MyBase.WndProc(m)
        End Sub
    End Class
    

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, November 13, 2018 8:25 AM