获取字符区间位置的另一个文本
#Include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetTextInRange($hWnd, $iStart, $iEnd)
$hWnd | 控件句柄 |
$iStart | 文本前的字符区间位置 |
$iEnd | 文本后的字符区间位置 特别值: -1 - 文本结束 |
成功: | 返回文本 |
失败: | 返回 False,设置@error |
@error: | 101 - $hWnd 参数值不是句柄 |
102 - $iStart 既不是正数,也不是 0 | |
1031 - $iEnd 既不是正数或 0,也不是 -1 | |
1032 - $iStart < $iEnd 与 $iEnd &l;> -1 |
在MSDN中搜索
#include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $hRichEdit
Main()
Func Main()
Local $hGui, $iMsg
$hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 320, 350, -1, -1)
$hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
_GUICtrlRichEdit_SetEventMask($hRichEdit, $ENM_LINK)
_GUICtrlRichEdit_AutoDetectURL($hRichEdit, True)
_GUICtrlRichEdit_AppendText($hRichEdit, @CR & "http://www.autoitscript.com")
While True
$iMsg = GUIGetMsg()
Select
Case $iMsg = $GUI_EVENT_CLOSE
_GUICtrlRichEdit_Destroy($hRichEdit) ; 除非脚本崩溃才需要
;~ GUIDelete() ; 同样行
Exit
EndSelect
WEnd
EndFunc ;==>Main
Func WM_NOTIFY($hWnd, $iMsg, $iWparam, $iLparam)
#forceref $hWnd, $iMsg, $iWparam
Local $hWndFrom, $iCode, $tNMHDR, $tEnLink, $cpMin, $cpMax, $tMsgFilter
$tNMHDR = DllStructCreate($tagNMHDR, $iLparam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hRichEdit
Select
Case $iCode = $EN_LINK
$tMsgFilter = DllStructCreate($tagMSGFILTER, $iLparam)
If DllStructGetData($tMsgFilter, "msg") = $WM_LBUTTONUP Then
$tEnLink = DllStructCreate($tagENLINK, $iLparam)
$cpMin = DllStructGetData($tEnLink, "cpMin")
$cpMax = DllStructGetData($tEnLink, "cpMax")
MsgBox(4096, "", "Invoke your web browser here and point it to " & _
_GUICtrlRichEdit_GetTextInRange($hRichEdit, $cpMin, $cpMax))
EndIf
EndSelect
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY