[已解决]如何读取INI内容到控件,双击则运行对应网站
本帖最后由 leibin0121 于 2014-12-17 12:24 编辑#include <ListViewConstants.au3>
Global Const $qIni = @ScriptDir&"\config.ini"
$Form1 = GUICreate("Form1", 623, 449, 192, 124)
$ListView1 = GUICtrlCreateListView("网站|地址", 8, 8, 537, 377)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 80)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 300)
$sec = IniReadSection($qIni,"data")
Global $ListView1_[$sec]
For $i = 1 To $sec
$ListView1_[$i-1] = GUICtrlCreateListViewItem($sec[$i]&"|"&$sec[$i],$ListView1)
Next
GUISetState()
Do
Until GUIGetMsg()=-3
config.ini内容如下:
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com
网址=www.baidu.com如何达到读取INI内容到控件,双击则运行对应网站?求高手解答,谢谢!
非常感谢user3000的热心帮助:#include <ListViewConstants.au3>
Global Const $qIni = @ScriptDir&"\config.ini"
$Form1 = GUICreate("Form1", 623, 449, 192, 124)
$ListView1 = GUICtrlCreateListView("网站|地址", 8, 8, 537, 377)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 80)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 300)
$sec = IniReadSection($qIni,"data")
If @error Then Local $sec = [, ['web1', 'www.baidu.com'], ['web2', 'www.qq.com']]
Global $lv_item[$sec]
For $i = 1 To $sec
$lv_item[$i-1] = GUICtrlCreateListViewItem($sec[$i]&"|"&$sec[$i],$ListView1)
Next
GUISetState()
Local $nMsg = 0
Do
$nMsg = GUIGetMsg()
Switch $nMsg
Case $lv_item To $lv_item
Local $web = $sec[$nMsg-$lv_item+1]
;Local $web = StringRegExpReplace(GUICtrlRead($nMsg), '^[^\|]+.+\|([^\|]+)\|?$', '\1')
;If Not @extended Then ContinueLoop
ShellExecute(@ProgramFilesDir & '\Internet Explorer\iexplore.exe', $web)
EndSwitch
Until GUIGetMsg()=-3
这名字貌似多了个n 回复 2# netegg
蛋蛋,求解答啊 网站ini那么多 都一样啊 起码要不一样吧
1=www.baidu.com
2=www.baidu.com
3=www.baidu.com
.
.
.
.
.
.
31=www.baidu.com
.
.
.
.
.
. 你都中级会员了,还问这个问题啊~~~ 回复 5# austere
惭愧{:face (368):} 网址已经存在数组里了,是现成的.直接打开就是了.
#include <ListViewConstants.au3>
Global Const $qIni = @ScriptDir&"\config.ini"
$Form1 = GUICreate("Form1", 623, 449, 192, 124)
$ListView1 = GUICtrlCreateListView("网站|地址", 8, 8, 537, 377)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 80)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 300)
$sec = IniReadSection($qIni,"data")
If @error Then Local $sec = [, ['web1', 'www.baidu.com'], ['web2', 'www.qq.com']]
Global $lv_item[$sec]
For $i = 1 To $sec
$lv_item[$i-1] = GUICtrlCreateListViewItem($sec[$i]&"|"&$sec[$i],$ListView1)
Next
GUISetState()
Local $nMsg = 0
Do
$nMsg = GUIGetMsg()
Switch $nMsg
Case $lv_item To $lv_item
Local $web = $sec[$nMsg-$lv_item+1]
;Local $web = StringRegExpReplace(GUICtrlRead($nMsg), '^[^\|]+.+\|([^\|]+)\|?$', '\1')
;If Not @extended Then ContinueLoop
ShellExecute(@ProgramFilesDir & '\Internet Explorer\iexplore.exe', $web)
EndSwitch
Until $nMs 回复 7# user3000
学习了~~case还可以这样用啊~ 我以为只能for呢~~ 回复 7# user3000
非常感谢你的帮助,问题解决,谢谢! 感谢分享,学习了!
页:
[1]