Click here to Skip to main content
15,886,963 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionNeed to publish? Pin
Richard Andrew x644-Feb-24 3:05
professionalRichard Andrew x644-Feb-24 3:05 
AnswerRe: Need to publish? Pin
Dave Kreskowiak4-Feb-24 7:44
mveDave Kreskowiak4-Feb-24 7:44 
GeneralRe: Need to publish? Pin
Richard Andrew x644-Feb-24 12:32
professionalRichard Andrew x644-Feb-24 12:32 
AnswerRe: Need to publish? Pin
TNCaver14-Mar-24 7:04
TNCaver14-Mar-24 7:04 
QuestionCan anyone recommend a tool to... Pin
Richard Andrew x643-Feb-24 14:42
professionalRichard Andrew x643-Feb-24 14:42 
AnswerRe: Can anyone recommend a tool to... Pin
Gerry Schmitz3-Feb-24 15:26
mveGerry Schmitz3-Feb-24 15:26 
GeneralRe: Can anyone recommend a tool to... Pin
Richard Andrew x644-Feb-24 3:04
professionalRichard Andrew x644-Feb-24 3:04 
QuestionSend String/Text to a other window [vb.net / API] Pin
Seek514-Dec-23 21:01
Seek514-Dec-23 21:01 
Hello,

I want to send a message/test to a other windows.
It should save me many time in putting me many time
strings/textes in MS Project, Outlook, ... ...

Therefore i want to use the Windwos API in VB.net.

I tried it in this way, but it doesn't work.
I get the windows handle, but the text isn't set at notepad or in a other window.



BASIC
Private Sub tmr_Worktimer_Tick(sender As Object, e As EventArgs) Handles tmr_Worktimer.Tick
        If IsKeyPressed(Keys.VK_SHIFT) Then
            Dim aPoint As New POINTAPI
            GetCursorPos(aPoint)
            Dim hWnd As IntPtr = WindowFromPoint(aPoint.x, aPoint.y)
            SetForegroundWindow(hWnd)
            SetWindowTextUnicode(hWnd, WM_SETTEXT, IntPtr.Zero, "Test")
        End If
    End Sub



My API Calls are:
BASIC
Public Structure Keys
        Const VK_BACK As Short = &H8  ' Backspace key
        Const VK_TAB As Short = &H9  ' Tab key
        Const VK_RETURN As Short = &HD  ' Enter key
        Const VK_SHIFT As Short = &H10  ' Shift key
        Const VK_CONTROL As Short = &H11  ' STRG key
        Const VK_MENU As Short = &H12  ' Alt key
        Const VK_CAPITAL As Short = &H14  ' Caps Lock
        Const VK_ESCAPE As Short = &H1B  ' Escape
        Const VK_SPACE As Short = &H20  ' Space
        Const VK_PRIOR As Short = &H21  ' PageUp
        Const VK_NEXT As Short = &H22  ' PageDown
End Structure

 <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)>
    Public Function GetAsyncKeyState(ByVal vKey As Int32) As Short
    End Function

 Public Function IsKeyPressed(ByVal KeyToCheck As Short) As Boolean
        Dim res As Short
        res = GetAsyncKeyState(KeyToCheck)
        If res < 0 Then ' -32768 Then
            IsKeyPressed = True
        Else
            IsKeyPressed = False
        End If
    End Function
	
	    <System.Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)>
    Public Structure POINTAPI
        Dim x As Integer
        Dim y As Integer
    End Structure
	
	    <DllImport("user32.dll", ExactSpelling:=True, SetLastError:=True)>
    Public Function GetCursorPos(ByRef lpPoint As POINTAPI) As <MarshalAs(UnmanagedType.Bool)> Boolean
    End Function
	
	    <DllImport("user32.dll")>
    Public Function WindowFromPoint(xPoint As Integer, yPoint As Integer) As IntPtr
    End Function
	
	    <DllImport("user32.dll")>
    Public Function SetForegroundWindow(hWnd As IntPtr) As Boolean
    End Function
	
	    Friend Const WM_SETTEXT As Integer = 12

    <DllImport("user32.dll", EntryPoint:="SendMessageW", CharSet:=CharSet.Unicode)>
    Public Function SetWindowTextUnicode(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As IntPtr, ByVal lParam As String) As IntPtr
    End Function



Any ideas? Is there a other way to send the string/text?
AnswerRe: Send String/Text to a other window [vb.net / API] Pin
Richard MacCutchan4-Dec-23 22:15
mveRichard MacCutchan4-Dec-23 22:15 
GeneralRe: Send String/Text to a other window [vb.net / API] Pin
Seek514-Dec-23 23:55
Seek514-Dec-23 23:55 
GeneralRe: Send String/Text to a other window [vb.net / API] Pin
Richard MacCutchan5-Dec-23 0:01
mveRichard MacCutchan5-Dec-23 0:01 
GeneralRe: Send String/Text to a other window [vb.net / API] Pin
jschell5-Dec-23 5:12
jschell5-Dec-23 5:12 
AnswerRe: Send String/Text to a other window [vb.net / API] Pin
jschell5-Dec-23 5:15
jschell5-Dec-23 5:15 
AnswerRe: Send String/Text to a other window [vb.net / API] Pin
Gerry Schmitz5-Dec-23 6:30
mveGerry Schmitz5-Dec-23 6:30 
AnswerRe: Send String/Text to a other window [vb.net / API] Pin
Andre Oosthuizen5-Dec-23 8:43
mveAndre Oosthuizen5-Dec-23 8:43 
QuestionLibVLCSharp hosted in mcr.microsoft.com/dotnet/aspnet:6.0 Docker image inside a linux context Pin
etodemerzel30-Nov-23 11:29
etodemerzel30-Nov-23 11:29 
AnswerRe: LibVLCSharp hosted in mcr.microsoft.com/dotnet/aspnet:6.0 Docker image inside a linux context Pin
Gerry Schmitz30-Nov-23 15:53
mveGerry Schmitz30-Nov-23 15:53 
QuestionHow to "update" old .NET code to current versions Pin
lewist5730-Nov-23 10:38
lewist5730-Nov-23 10:38 
QuestionRe: How to "update" old .NET code to current versions Pin
Ralf Meier30-Nov-23 11:26
mveRalf Meier30-Nov-23 11:26 
AnswerRe: How to "update" old .NET code to current versions Pin
Gerry Schmitz30-Nov-23 15:44
mveGerry Schmitz30-Nov-23 15:44 
AnswerRe: How to "update" old .NET code to current versions Pin
Richard Deeming30-Nov-23 21:50
mveRichard Deeming30-Nov-23 21:50 
AnswerRe: How to "update" old .NET code to current versions Pin
Richard MacCutchan30-Nov-23 22:09
mveRichard MacCutchan30-Nov-23 22:09 
AnswerRe: How to "update" old .NET code to current versions Pin
lewist571-Dec-23 2:50
lewist571-Dec-23 2:50 
GeneralRe: How to "update" old .NET code to current versions Pin
Richard MacCutchan1-Dec-23 3:34
mveRichard MacCutchan1-Dec-23 3:34 
GeneralRe: How to "update" old .NET code to current versions Pin
lewist571-Dec-23 3:53
lewist571-Dec-23 3:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.