Run("notepad.exe")
Local $var = ControlGetText("[CLASS:Notepad]", "", "Edit1")
WinWaitActive("[CLASS:Notepad]","")
ControlCommand("[CLASS:Notepad]", "", "Edit1", "EditPaste", "是要获得这里的内容吗")
$Arg_hwnd = ControlGetHandle("[CLASS:Notepad]", "", "[CLASS:Edit; INSTANCE:1]")
MsgBox(4096, "测试", GetText($Arg_hwnd))
Func GetText($Arg_hwnd)
Const $WM_GETTEXT = 0xD
Const $WM_GETTEXTLENGTH = 0xE
Dim $S_TextLen, $S_strText
$S_TextLen = _SendMessage($Arg_hwnd, $WM_GETTEXTLENGTH, 0, 0)
$S_strText = Space($S_TextLen)
$txt = _SendMessage($Arg_hwnd, $WM_GETTEXT, $S_TextLen + 1, DllStructGetPtr($S_strText))
Return DllStructGetData($S_strText, "var")
EndFunc ;==>GetText
Func Space($S_TextLen)
Local $a = DllStructCreate("char var[" & $S_TextLen & "]") ;创建一个结构,分配内存空间
Return $a;
EndFunc ;==>Space
Func _SendMessage($hWnd, $iMsg, $wParam = 0, $lParam = 0, $iReturn = 0, $wParamType = "wparam", $lParamType = "lparam", $sReturnType = "lresult")
Local $aResult = DllCall("user32.dll", $sReturnType, "SendMessageA", "hwnd", $hWnd, "uint", $iMsg, $wParamType, $wParam, $lParamType, $lParam)
If @error Then Return SetError(@error, @extended, "")
If $iReturn >= 0 And $iReturn <= 4 Then Return $aResult[$iReturn]
Return $aResult
EndFunc ;==>_SendMessage
|