Sign in to follow this  
Followers 0
X-sploiT

Hooking a window

4 posts in this topic

I need help i need to hook a window and send a message to the text box can someone please help

Share this post


Link to post
Share on other sites



#3 ·  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

Share this post


Link to post
Share on other sites

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")

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0