Re: Hotkey Help?
Posted: Tue Jan 17, 2012 1:56 am
Hotkey mapping can be complex if you are doing it between different programs.
You can use this code to register a system-wide hotkey: viewtopic.php?f=32&t=7564&p=55919#p56005
Based on this code, you can use this sample to see if the game is in focus and then you could send some keys:
You can use this code to register a system-wide hotkey: viewtopic.php?f=32&t=7564&p=55919#p56005
Based on this code, you can use this sample to see if the game is in focus and then you could send some keys:
Code: Select all
<DllImport("user32.dll")> Shared Function GetWindowText(ByVal hWnd As IntPtr, ByVal lpString As StringBuilder, ByVal nMaxCount As Integer) As Integer
End Function
<DllImport("user32.dll")> Shared Function GetForegroundWindow() As IntPtr
End Function
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_HOTKEY Then
Dim foreground As IntPtr = GetForegroundWindow()
Dim sb As StringBuilder = New StringBuilder(255)
GetWindowText(foreground, sb, sb.MaxCapacity)
Dim winTitle As String = sb.ToString()
If winTitle = "Untitled - Notepad" Then 'example
SendKeys.SendWait("test")
End If
End If
MyBase.WndProc(m)
End Sub