Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27348

VS 2010 Problem with SendMessage to a not focused application.

$
0
0
EDIT: I completey rewrote the thread since I go ta solution but another problem.

I delcare:

Code:

  Private Declare Function PostMessage Lib "user32.dll" Alias "PostMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As IntPtr
    Private Const WM_KEYDOWN As Long = &H100
    Private Const WM_KEYUP As Long = &H101

Then in my button.

Code:

Dim processes() As System.Diagnostics.Process = System.Diagnostics.Process.GetProcessesByName("Notepad")
        For Each p As Process In processes
            PostMessage(p.MainWindowHandle, WM_KEYDOWN, Keys.F5, 0)
            PostMessage(p.MainWindowHandle, WM_KEYUP, Keys.F5, 0)
        Next

That works really great, the problem is, when I switch the Keys.F5 to something like Keys.A, it doesn't press a at all (I guess because Notepad is not focused,
but I tried eve nwith it's focused on the text editor there, still nothing happens. No A.

Viewing all articles
Browse latest Browse all 27348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>