Sign in to follow this  
Followers 0
qwer85

PostMessage

4 posts in this topic

#1 ·  Posted (edited)

I need to send the key "2" into the notepad using PostMessage API function... But it's not working... Pls help, thx in advance.

$handle = WinGetHandle("Unnamed - Notepad")
_API_PostMessage($handle, 0x0100, 0x32, 0)
_API_PostMessage($handle, 0x0101, 0x32, 0)

Func _API_PostMessage($hWnd, $iMsg, $iwParam, $ilParam)
  Local $aResult
  $aResult = DllCall("User32.dll", "int", "PostMessageA", "hwnd", $hWnd, "int", $iMsg, "int", $iwParam, "int", $ilParam)
  Return $aResult[0]
EndFunc
Edited by qwer85

Share this post


Link to post
Share on other sites



I need to send the key "2" into the notepad using PostMessage API function... But it's not working... Pls help, thx in advance.

$handle = WinGetHandle("Unnamed - Notepad")
_API_PostMessage($handle, 0x0100, 0x32, 0)
_API_PostMessage($handle, 0x0101, 0x32, 0)

Func _API_PostMessage($hWnd, $iMsg, $iwParam, $ilParam)
  Local $aResult
  $aResult = DllCall("User32.dll", "int", "PostMessageA", "hwnd", $hWnd, "int", $iMsg, "int", $iwParam, "int", $ilParam)
  Return $aResult[0]
EndFunc
Can't comment on the code because I don't know what messages 100 and 101 are. But why not use Send or ControlSend?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

I don't much about PostMessage but I found this sample... Hope it helps you.

$hWnd = ControlGetHandle("Untitled - Notepad", "", "Edit1")
$user32 = DllOpen("user32.dll")
$ret = DllCall($user32, "int", "MapVirtualKey", "int", 0x0D, "int", 0)
$lParam = BitOR($ret[0] * 0x10000, BitAND(1, 0xFFFF))
If IsArray($ret) Then
    DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", 0x0D, "long", $lParam)
    Sleep(1)
    DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", 0x0D, "long", BitOR($lParam, 0xC0000000))
EndIf
DllClose($user32)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

It works!

Thx a lot... can you help me also to send a mouse click with PostMessage?

Edited by qwer85

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