如果是在edit上的光标处插入没必要那么麻烦,见MSDN:EM_REPLACESEL
eg:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form2 = GUICreate("窗体1", 413, 236, 280, 244)
$Edit1 = GUICtrlCreateEdit("", 8, 8, 393, 153)
GUICtrlSetData(-1, "内容测试测试")
$Button1 = GUICtrlCreateButton("插入内容", 24, 192, 75, 25)
$Button2 = GUICtrlCreateButton("插入内容", 128, 192, 75, 25)
GUISetState(@SW_SHOW)
Opt('MouseCoordMode', 0)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
;$Post = fn_TestCarePos()
;If Not @error Then
;MouseClick('left',$Post[0],$Post[1],1,0)
;~ DllCall("user32.dll", "int", "SetCursorPos", "int", $Post[0], "int", $Post[1])
; Send('0322456')
;EndIf
;0xC2
_SendMessageTimeout(GUICtrlGetHandle($Edit1), 0x0c2, True, '测试发送成功', 0, 'wparam', 'wstr')
EndSwitch
WEnd
Func _SendMessageTimeout($hWnd, $iMsg, $wparam = 0, $lparam = 0, $iReturn = 0, $wParamType = "wparam", $lParamType = "lparam", $sReturnType = "lresult", $iTimeout = 1000, $iFlags = 3)
Local $Ret = DllCall("user32.dll", $sReturnType, "SendMessageTimeoutW", "hwnd", $hWnd, "uint", $iMsg, $wParamType, $wparam, $lParamType, $lparam, "uint", $iFlags, "uint", $iTimeout, "dword_ptr*", $iReturn)
If (@error) Or (Not $Ret[0]) Then
Return SetError(1, 0, "")
EndIf
Return SetError(0, 1, $Ret[7])
EndFunc ;==>_SendMessageTimeout
|