Jump to content

Recommended Posts

Posted (edited)

i wanna use sendmessage or postmessage just write a message in notepad per say using sendmessage or post message

something like this but in autoit just type hey in notepad and send {enter}

Private Declare Auto Function FindWindow Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
    Private Declare Auto Function PostMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Boolean
    Private Declare Auto Function GetWindow Lib "user32" (ByVal hWnd As IntPtr, ByVal uCmd As Integer) As IntPtr
    Private Const WM_KEYDOWN = &H100
    Private Const WM_CHAR = &H102
    Private Const WM_KEYUP = &H101
    Private Const WM_COMMAND = &H111
    Private Const GW_CHILD = 5

    Sub Main()

        Dim whnd As IntPtr = FindWindow(vbNullString, "untitled - notepad")
        Dim Cwhnd As IntPtr = GetWindow(whnd, GW_CHILD)

        'PostMessage(whnd, WM_KEYDOWN, &H11, &H11D0001)
        'PostMessage(whnd, WM_KEYDOWN, &H4F, &H440001)
        'PostMessage(whnd, WM_CHAR, &HF, &H440001)
        'PostMessage(whnd, WM_KEYUP, &H4F, &HC0440001)
        'PostMessage(whnd, WM_KEYUP, &H11, &HC11D0001)

        'PostMessage(whnd, WM_COMMAND, &H10002, &H0)

        PostMessage(Cwhnd, WM_KEYDOWN, &H11, &H1D0001)
        PostMessage(Cwhnd, WM_KEYDOWN, &H4F, &H180001)
        PostMessage(Cwhnd, WM_CHAR, &HF, &H180001)
        PostMessage(Cwhnd, WM_KEYUP, &H4F, &HC0180001)
        PostMessage(Cwhnd, WM_KEYUP, &H11, &HC01D0001)

        'Dim Txt As String = "CRAZY"
        'For x As Integer = 0 To Txt.Length - 1
        '    PostMessage(Cwhnd, WM_KEYDOWN, CInt(Asc(Txt.Chars(x))), &H2F0001)
        'Next

    End Sub

End Module
Edited by X-sploiT
Posted

As James said...this is what you need.

run("notepad")
WinWait("Untitled - Notepad")
ControlSend("[CLASS:Notepad]", "", "Edit1", "This is a line of text in the notepad window")

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...