24楼大师的代码给了我前进的动力。不过试用了一下,发现不很稳定,用户手动输入的时候鼠标还放在书库框范围就没法输进去。。。
我稍微修改了一下,改成输入框内容识别。。。不过可能及特殊的情况我没有考虑到。希望大家帮忙测试测试各种极品组合的拖动输入粘贴删除什么的会不会不正常。谢谢了。
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiRichEdit.au3>
Opt("GUIOnEventMode", 1)
Local $dat = "", $m = 0
$hGui = GUICreate("网址拖放测试", 830, 100, -1, -1, -1, $WS_EX_WINDOWEDGE + $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "ExitGui")
GUICtrlCreateLabel("网址:", 5, 45, 40, 20)
GUICtrlCreateButton("解析", 760, 35, 60, 25)
GUICtrlSetOnEvent($GUI_EVENT_CLOSE, "click")
$RichEdit = _GUICtrlRichEdit_Create($hGui, "", 40, 40, 700, 20, BitOR($ES_WANTRETURN, $ES_AUTOHSCROLL))
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUISetState(@SW_SHOW, $hGui)
$x1 = ""
While True
$x2 = _GUICtrlRichEdit_GetText($RichEdit)
If StringLen($x2) > 0 And $x1 = "" Then
$x1 = $x2
ElseIf StringLen($x2) - StringLen($x1) = 1 Or StringLen($x1) - StringLen($x2) > 1 Then
$x1 = $x2
ElseIf StringLen($x2) - StringLen($x1) > 1 And $x1 <> "" Then
If StringRight($x2, StringLen($x1)) = $x1 Then
$x1 = StringTrimRight($x2,StringLen($x1))
_GUICtrlRichEdit_SetText($RichEdit,$x1)
Else
For $ccccccc = StringLen($x1) To 1 Step -1
If StringLeft($x2, $ccccccc) & StringRight($x2, StringLen($x1) - $ccccccc) = $x1 Then
$x1 = StringTrimRight(StringTrimLeft($x2, $ccccccc), StringLen($x1) - $ccccccc)
_GUICtrlRichEdit_SetText($RichEdit,$x1)
ExitLoop
EndIf
Next
EndIf
Else
$x1 = $x2
EndIf
Sleep(5)
WEnd
Func ExitGui()
_GUICtrlRichEdit_Destroy($RichEdit)
Exit
EndFunc ;==>ExitGui
Func click()
$dat = _GUICtrlRichEdit_GetText($RichEdit)
MsgBox(4096, "网址为", $dat)
EndFunc ;==>click
|