我修改的代码,。。。。
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiRichEdit.au3>
Opt("GUIOnEventMode", 1)
Local $dat = "", $m = 0
$hGui = GUICreate("网址拖放测试", 400, 100, -1, -1, -1, $WS_EX_WINDOWEDGE + $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "ExitGui")
GUICtrlCreateLabel("网址:", 5, 45, 40, 20)
GUICtrlCreateButton("解析", 350, 37, 50, 25)
GUICtrlSetOnEvent($GUI_EVENT_CLOSE, "click")
$RichEdit = _GUICtrlRichEdit_Create($hGui, "", 40, 40, 310, 20, BitOR($ES_WANTRETURN, $ES_AUTOHSCROLL))
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
;~ GUIRegisterMsg(0x0111, 'WM_COMMAND');看来【拖入替换】跟【点击全选】是不能共存了,我是在解决不了
_GUICtrlRichEdit_SetText($RichEdit, "dgvsdfhtdfuhydrtgbnfdtjhytj")
GUISetState(@SW_SHOW, $hGui)
$sLast = ""
While True
$sNow = _GUICtrlRichEdit_GetText($RichEdit)
If StringLen($sNow) - StringLen($sLast) > 1 And $sLast <> "" Then
$aPos =_GUICtrlRichEdit_GetSel($RichEdit)
$sLast = StringTrimRight(StringTrimLeft($sNow,$aPos[1]-StringLen($sNow) + StringLen($sLast)),StringLen($sNow)-$aPos[1])
_GUICtrlRichEdit_SetText($RichEdit, $sLast)
Else
$sLast = $sNow
EndIf
Sleep(5)
$aPos =_GUICtrlRichEdit_GetSel($RichEdit)
ToolTip(_Caret_GetPosnum($RichEdit)&@CR&$aPos[0]&@CR&$aPos[1])
WEnd
Func ExitGui()
_GUICtrlRichEdit_Destroy($RichEdit)
Exit
EndFunc ;==>ExitGui
Func click()
$dat = _GUICtrlRichEdit_GetText($RichEdit)
MsgBox(4096, "网址为", $dat)
EndFunc ;==>click
Func _Caret_GetPosnum($hWnd);获取当前光标所在位置之前的字符数,我自己写的。。。竟然不知道udf自带_GUICtrlRichEdit_GetSel
Local $POINT = DllStructCreate("long;long")
Local $Return[2]
DllCall("User32.dll", "int", "GetCaretPos", "ptr", DllStructGetPtr($POINT))
$Return[0] = DllStructGetData($POINT, 1)
$Return[1] = DllStructGetData($POINT, 2)
Return _GUICtrlRichEdit_GetCharPosFromXY($hWnd, $Return[0], $Return[1])
EndFunc ;==>_Caret_GetPos
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg
If $ilParam = $RichEdit And BitShift($iwParam, 16) = 256 Then ControlSend ($hGui, "", 'RICHEDIT50W1',"^a")
EndFunc ;==>WM_COMMAND
|