|
-
May 17th, 2008, 03:49 PM
#1
Thread Starter
Admodistrator
Bringing window to front and sending a message
Gah. Im depressed that I cant do this, I used to be good at programming! I'm in Vb.Net 2008 express, and I have a window that I need to send the message F9 to. So, I tried using sendmessage, but it isnt working. So I figured I would use keybd_event after bringing the window to the front. Problem is, I cant bring the window to the front!!! Im tearing my hair out. Okay. Heres my code (along with a whole bunch of other crud I threw in there to hopefully get it to work)
VB Code:
Public Class Form1 Const VK_F9 = 120 Const VK_SPACE As Int32 = &H20 Const SW_SHOW As Int32 = 5 Const WM_KEYDOWN As Integer = 256 Const WM_KEYUP As Integer = 257.0 <Runtime.InteropServices.DllImport("user32", EntryPoint:="ShowWindow")> _ Private Shared Function ShowWindow( _ ByVal hwnd As IntPtr, ByVal nCmdShow As Integer) As Integer End Function Private SW_SHOWNORMAL As Integer = &H1 Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated Dim recordingAudioHwnd As Int32 = Process.GetProcessesByName("Live 7.0.1")(0).MainWindowHandle Dim recordingVideoHwnd As Int32 = Process.GetProcessesByName("LiveCam")(0).MainWindowHandle ShowWindow(recordingAudioHwnd, SW_SHOWNORMAL) SetForegroundWindow(recordingAudioHwnd) keybd_event(VK_F9, 0, 0, 0) keybd_event(VK_F9, 0, WM_KEYUP, 0) Application.DoEvents() keybd_event(VK_SPACE, 0, 0, 0) keybd_event(VK_SPACE, 0, WM_KEYUP, 0) Me.Close() End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class
NOTHING works. Thanks for your help.
Edit**
myAudio(0) is returning a hwnd for those who are wondering 
edit#2-
I had to fix the declaration for ShowWindow. Now that somewhat works. Problem is, it isnt sending the vk_space ever, any ideas?
Last edited by |2eM!x; May 17th, 2008 at 06:57 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|