本帖最后由 lixiaolong 于 2011-3-13 21:52 编辑
本人语言不好,请原谅.
请问如何实现ComboBox 实时监控输入,自动匹配字符后弹出列表框.
就是想实现和系统自带的“运行”一样的效果,用户输入字符后自动弹出列表框,显示匹配的字符.
这样的效果,好像是独立的列表框?
要匹配urllist.txt中的网址,路径.http://www.baidu.com
http://www.autoitscript.com/forum/index.php?app=core&module=attach§ion=attach&attach_id=11789
http://www.autoitscript.com/forum/topic/58072-autoit-operating-system-support
http://www.autoitscript.com/forum/topic/53453-run-script-as-system
http://www.autoitscript.com/forum/topic/54475-shellexecute-canceled
http://www.autoitscript.com/forum/topic/35500-system-level-run
http://www.autoitscript.com/forum/topic/18387-start-menu-run-dialog-with-registered-file-type
http://www.autoitscript.com/forum/topic/15785-how-to-open-the-start-menu-properties-with-run
http://www.autoitx.com/thread-15405-1-1.html
http://www.autoitx.com/logging.php?action=login&loginsubmit=yes&floatlogin=yes&inajax=1
http://www.autoitx.com/forum.php?mod=redirect&goto=findpost&ptid=22733&pid=275258
http://www.autoitx.com/forum.php?mod=viewthread&tid=22733&rpid=275258&ordertype=0&page=1
http://www.autoitx.com
http://www.autoitx.com/archiver/tid-10908.html
http://www.zhcw.com/
%temp%\low
C:\Program Files\CCleaner\CCleaner.exe
代码
#RequireAdmin
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=C:\Windows\System32\shell32.dll|-25
#AutoIt3Wrapper_outfile=运行.exe
#AutoIt3Wrapper_Res_Comment=模仿系统自带的“运行”
#AutoIt3Wrapper_Res_Description=模仿系统自带的“运行”
#AutoIt3Wrapper_Res_Fileversion=1.0.0.2
#AutoIt3Wrapper_Res_LegalCopyright=Lixiaolong
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
HotKeySet("!b", "liulan")
HotKeySet("!d", "del")
GUICreate(" 模仿系统自带的运行", 411, 252, 8, 473, $WS_SYSMENU, $WS_EX_ACCEPTFILES)
GUISetBkColor(0xffffff)
GUISetFont(9, 400, '', '微软雅黑')
GUICtrlCreateIcon("shell32.dll", -77, 12, 23, 32, 32)
GUICtrlCreateLabel("Windows 将根据您所输入的名称,为您打开相应的程序、文件夹、文档或 Internet 资源。", _
63, 23, 319, 47)
GUICtrlCreateLabel("打开(&O):", 12, 83, 47, 21)
$file = GUICtrlCreateCombo("", 63, 79, 320, 500)
GUICtrlSetState($file, $GUI_DROPACCEPTED)
GUICtrlCreateIcon("user32.dll", -7, 63, 111, 16, 16)
GUICtrlCreateLabel("使用管理权限创建此任务。", 88, 113, 333, 23)
$btn = GUICtrlCreateButton("确定", 109, 174, 88, 30, 0x0001)
GUICtrlSetState(-1, $GUI_DISABLE)
$btn2 = GUICtrlCreateButton("取消", 203, 174, 88, 30)
$btn3 = GUICtrlCreateButton("浏览(&B)...", 298, 174, 88, 30)
GUISetState()
AdlibRegister("check", 100)
GUICtrlSetData($file, RegRead("HKEY_CURRENT_USER\Software\运行", "key"))
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_DROPPED
GUICtrlSetData($file, @GUI_DragFile, @GUI_DragFile)
Case $msg = $btn
yunxing(StringStripWS(GUICtrlRead($file), 3))
Case $msg = $btn2
ExitLoop
Case $msg = $btn3
$var = FileOpenDialog('浏览', @UserProfileDir & "\", "程序 (*.exe;*.pif;*.com;*.bat;*.cmd)")
If $var Then GUICtrlSetData($file, $var, $var)
EndSelect
WEnd
Func liulan()
ControlClick(" 模仿系统自带的运行", "", "Button3")
EndFunc ;==>liulan
Func del()
RegDelete("HKEY_CURRENT_USER\Software\运行")
GUICtrlSetData($file, "")
EndFunc ;==>del
Func check()
If GUICtrlRead($file) <> '' Then
GUICtrlSetState($btn, $GUI_ENABLE)
Else
GUICtrlSetState($btn, $GUI_DISABLE)
EndIf
EndFunc ;==>check
Func yunxing($set)
Local $test, $test2, $Right4 = StringRight($set, 4)
While 1
If $set = "" Then
ExitLoop
Else
If StringInStr($set, '%') <> 0 Then
_ShellExecute($set)
ExitLoop
Else
_ShellExecuteW($set)
ExitLoop
EndIf
EndIf
WEnd
EndFunc ;==>yunxing
Func _ShellExecuteW($Str)
$len = StringLen($Str)
For $i = 1 To 1000
If StringInStr(StringRight($Str, $i), ' ') <> 0 Then
ExitLoop
EndIf
Next
If StringInStr(StringMid($Str, $len - $i + 1), '\') <> 0 Then
$frag = ShellExecute(StringMid($Str, 1, $len - $i) & StringMid($Str, $len - $i + 1))
If $frag Then reg($Str)
Else
$frag = ShellExecute(StringMid($Str, 1, $len - $i), StringMid($Str, $len - $i + 1))
If $frag Then reg($Str)
EndIf
EndFunc ;==>_ShellExecuteW
Func _ShellExecute($run)
$run2 = StringRegExp($run, '([^%]+)', 3)
For $i = 0 To UBound($run2) - 2
Next
If $i Then
$frag = ShellExecute(EnvGet($run2[0]) & $run2[1])
If $frag Then reg($run)
Else
$frag = ShellExecute(EnvGet($run2[0]))
If $frag Then reg($run)
EndIf
EndFunc ;==>_ShellExecute
Func reg($Tong)
$s = 0
$REG = RegRead("HKEY_CURRENT_USER\Software\运行", "key")
$key = $REG
If $REG = '' Then
RegWrite("HKEY_CURRENT_USER\Software\运行", "key", "REG_SZ", $Tong)
Else
$key = StringSplit($key, '|')
For $i = 1 To UBound($key) - 1
If $key[$i] = $Tong Then
$s = 1
ExitLoop
EndIf
Next
If Not $s Then RegWrite("HKEY_CURRENT_USER\Software\运行", "key", "REG_SZ", $REG & '|' & $Tong)
EndIf
$REG = RegRead("HKEY_CURRENT_USER\Software\运行", "key")
GUICtrlSetData($file, '')
GUICtrlSetData($file, $REG, $Tong)
EndFunc ;==>reg
我试了很多方法还是不行,实在是不明白,请大家帮帮忙,谢谢.AdlibRegister('UrlList', 100); 这是例子
Func UrlList()
If GUICtrlRead($file) <> '' And StringLen(GUICtrlRead($file)) < 10 Then
Dim $UrlUrl
$UrlList = FileRead(FileOpen('Urllist.txt', 0))
$UrlList = StringRegExp($UrlList, '.+', 3)
For $i = 0 To UBound($UrlList) - 1
If StringInStr($UrlList[$i], GUICtrlRead($file)) <> 0 Then
If $i = 0 Then GUICtrlSetData($file, '')
GUICtrlSetData($file, $UrlList[$i])
EndIf
Next
_GUICtrlComboBox_ShowDropDown($file, 1)
EndIf
EndFunc ;==>UrlList
|