zhenglei 发表于 2009-4-20 19:22:17

关于根据配置文件设置而自定义产生按钮-在次提问!!~~

程序要求:根据配置文件内容设置。。   GUI中根据配置文件中的数据而生成按钮。。   同时要求在GUI中点击 相应按钮则转向相应 链接。。 不知如何实现???? 提供案例更好。。。。

config.ini配置文件

[设置]
测试一=   "www.baidu.com"
测试二=   "www.163.com"



这个是沙漠狼提供的方法:
http://www.autoitx.com/forum.php?mod=viewthread&tid=5729

此方法有一定弊端。。。 在多窗口操作的情况下。 非常不好用。。因为此方法
在开始处加入了 Opt("GUIOnEventMode", 1);OnEvent模式这样一来在多窗口操作中 将无法使用一下命令
对GUI的控制非常之不方便。。 请问我这个问题要解决并且还要用可以用以下命令对窗口操作。应该如何对程序
进行设置编译。。 谢谢。。。。。。(在解决问题的情况下 ,请保持发帖主题不便 在所有按钮-未知的情况下根据配置文件内容的设置而自动产生-- 一切由配置文件控制)
While 1
        $nMsg = GUIGetMsg()
        Select
                Case

[ 本帖最后由 zhenglei 于 2009-4-20 19:23 编辑 ]

ddx13 发表于 2009-4-20 20:08:36

#include <GUIConstants.au3>
#include <string.au3>
#include <IE.au3>
#Include <process.au3>
#NoTrayIcon
dim $Combo1

HotKeySet("{F5}", "CL")
HotKeySet("{F6}", "yc")

$fw = 115
$fh = 50
$width = 85
$height = 17
$x = 20
$y = 15
$temp = 0

$xplus = $width + 10
$yplus = $height + 15
$l = 10
$listdq = IniReadSection(@ScriptDir & "\连接管理.ini" , "设置" )

$m = UBound($listdq,1)-2
$n = UBound($listdq,2)
Dim $dqbqd[$m]
Dim $tmpArray[$m][$n]
For $a = 2 To UBound($listdq,1)-1
For $b = 0 To UBound($listdq,2)-1
$tmpArray[$a-2][$b] = $listdq[$a][$b]
ConsoleWrite($tmpArray[$a-2][$b] & @CRLF)
Next
Next
$fw = $fw + 95 * int($m/10+0.9)-95
if int($m/10+0.9) < 2 then $fw =115
$fh = $fh + 32 * $m-32
if $m> 10 then $fh =340
if $m< 2 then $fh =53
$Form1 = GUICreate("快捷工具", $fw, $fh )
GUISetBkColor (0x396DA5)
For $i = 0 To $listdq-2
   If $temp < Int($i/$l) Then
      $x = $x + $xplus
      $temp = Int($i/$l)
   EndIf
   $listel1 = _StringEncrypt ( 0, $tmpArray[$i] , "lansemengxiangjiamixitong","administrators" )
   $dqbqd[$i] = GUICtrlCreateButton( $listel1, $x,$y+$yplus*Mod($i,$l), 75, 25)
Next


GUISetState(@SW_SHOW)
While 1
        $msg = GuiGetMsg()
        Select
        Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
        Case $msg = $GUI_EVENT_SECONDARYUP
                listgl()
        Case $msg = $GUI_EVENT_MINIMIZE
                yc()
        Case Else
             FOR $K =0 TO $listdq-2
             IF $msg = $dqbqd[$k] then
                     $listel2 = _StringEncrypt ( 0, $tmpArray[$k] , "lansemengxiangjiamixitong","administrators" )
                if StringInStr($listel2,"http://") = true then
                     _IECreate ($listel2, 1, 1, 0)
                     $bt = WinGetTitle ( "" )
                     WinSetState ( $bt , "" , @SW_MAXIMIZE )
                ElseIf StringInStr($listel2,"ftp://") = true then
                     _IECreate ($listel2, 1, 1, 0)
                     $bt = WinGetTitle ( "" )
                     WinSetState ( $bt , "" , @SW_MAXIMIZE )
                ElseIf StringInStr($listel2,"www.") = true then
                     _IECreate ($listel2, 1, 1, 0)
                     $bt = WinGetTitle ( "" )
                     WinSetState ( $bt , "" , @SW_MAXIMIZE )
                Else
                     _RunDOS( "start " & $listel2 )
                EndIf
             EndIf
      Next
        EndSelect
WEnd

Func listgl()
GUISetState(@SW_HIDE,$Form1)
$ComboList = ""
$ljqgz = GUICreate("连接器管理", 231, 134 )
$listz = IniReadSection(@ScriptDir & "\连接管理.ini" , "设置" )
$Combo1 = GUICtrlCreateCombo("", 44, 8, 177, 21 , BitOR($CBS_DROPDOWNLIST,$CBS_DROPDOWN,$CBS_AUTOHSCROLL,$WS_VSCROLL))
For $i = 1 To $listz
    $list = _StringEncrypt ( 0, $listz[$i] , "lansemengxiangjiamixitong","administrators" )
    $ComboList=$ComboList&"|"&$List
Next
GuiCtrlSetData($Combo1,$ComboList,"------连 接 器 列 表------")
$Input1 = GUICtrlCreateInput("", 44, 40, 177, 21)
$Input2 = GUICtrlCreateInput("", 44, 72, 177, 21)
GUICtrlCreateLabel("列 表:", 8, 12, 36, 17)
GUICtrlCreateLabel("名 称:", 8, 43, 36, 17)
GUICtrlCreateLabel("执 行:", 8, 75, 36, 17)
$tjlb = GUICtrlCreateButton("添 加", 8, 104, 67, 25, $BS_DEFPUSHBUTTON)
$sclb = GUICtrlCreateButton("删 除", 80, 104, 67, 25, 0)
$tclb = GUICtrlCreateButton("退 出", 152, 104, 67, 25, 0)
GUISetState(@SW_SHOW)

While 2
        $msg = GuiGetMsg()
        Select
        Case $msg = $GUI_EVENT_CLOSE or $msg = $tclb
                GUISetState(@SW_HIDE,$ljqgz)
                run ( @ScriptDir & "\快捷工具.exe /08060225")
                exit
        Case $msg = $tjlb
                $sj1 = GUICtrlRead($Input1)
                $sj2 = GUICtrlRead($Input2)
                if $sj1 = "" then
                        msgbox(48,"错误","名称不能空!")
                ElseIf $sj2 = "" then
                        msgbox(48,"错误","执行不能空!")
                Else
                        IniWrite ( @ScriptDir & "\连接管理.ini", "设置", _StringEncrypt ( 1, $sj1 , "lansemengxiangjiamixitong","administrators" ) , _StringEncrypt ( 1, $sj2 , "lansemengxiangjiamixitong","administrators" ) )
                        msgbox(48,"提示","添加成功!")
                        GUICtrlSetData($Input1, "")
                        GUICtrlSetData($Input2, "")
                        F_Combo()
                EndIf
        Case $msg = $sclb
                $deljz = GUICtrlRead($Combo1)
                $del = _StringEncrypt ( 1, $deljz , "lansemengxiangjiamixitong","administrators" )
                if $del = "D2C54EC18027CC2A9F2C637D049F2D4E29704D3EC36AE8C3DF54DF34A0D650AB317D287A43447A6A0DF3A5CA0CC02153C5B9882F" then
                   msgbox(48,"错误","请选择要删除的列表!")
                Else
                   IniDelete ( @ScriptDir & "\连接管理.ini" , "设置" , $del )
                   F_Combo()
                   msgbox(48,"提示","删除成功!")
                EndIf
        EndSelect
WEnd
EndFunc
Func F_Combo()
$ComboList1 = ""
$listz1 = IniReadSection(@ScriptDir & "\连接管理.ini" , "设置" )
For $i = 1 To $listz1
    $list1 = _StringEncrypt ( 0, $listz1[$i] , "lansemengxiangjiamixitong","administrators" )
    $ComboList1=$ComboList1&"|"&$List1
Next
GuiCtrlSetData($Combo1,$ComboList1,"------连 接 器 列 表------")
EndFunc

Func cl()
    GUISetState ( @SW_SHOW , $Form1 )
EndFunc
Func yc()
    GUISetState ( @SW_MINIMIZE , $Form1 )
    GUISetState ( @SW_HIDE , $Form1 )
EndFunc
Exit


以前写的,可以参考一下。

zhenglei 发表于 2009-5-13 11:31:11

留个脚印...哈哈。。 日后可能用的上
页: [1]
查看完整版本: 关于根据配置文件设置而自定义产生按钮-在次提问!!~~