找回密码
 加入
搜索
查看: 2291|回复: 7

保存信息到配置文件问题

[复制链接]
发表于 2008-6-5 17:46:53 | 显示全部楼层 |阅读模式


如上图,将一个软件或任意程序拖到此框,就会显示出具体路径,能不能将获得的路径,直接自动保存到my.ini
文件里。my.ini格式是这样的



my.ini文件里有A1和A2两处,获得的路径信息将写入A1处(d:\qq2008\qq.exe),而A2处能不能自动取掉最后的qq.exe(d:\qq2008),最终就成了上图这样。

源码:
#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $file, $btn, $msg
    
    GUICreate(" My GUI input acceptfile", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES
    $file = GUICtrlCreateInput("", 10, 5, 300, 20)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)


    GUISetState()

    $msg = 0
    While $msg <> $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()
        Select
            Case $msg = $file
                ExitLoop
Case $file
        EndSelect
    WEnd
EndFunc


[ 本帖最后由 botanycc 于 2008-6-9 20:34 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2008-6-5 18:16:33 | 显示全部楼层
下次请使用含义清楚的标题
#include <GUIConstantsEx.au3>

;~ Opt('MustDeclareVars', 1)

Example()

Func Example()
        Local $file, $btn, $msg

        GUICreate(" My GUI input acceptfile", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES
        $file = GUICtrlCreateInput("", 10, 5, 300, 20)
        GUICtrlSetState(-1, $GUI_DROPACCEPTED)
        GUISetState()
        $msg = 0
        While 1
                $msg = GUIGetMsg()
                Select
                        Case $msg = $file
                                ExitLoop
                        Case $msg =$GUI_EVENT_CLOSE
                                $tmp=GUICtrlRead($file)
                                IniWrite("aa.ini","sect","a1",$tmp)
                                IniWrite("aa.ini","sect","a2",StringLeft($tmp,StringInStr($tmp,'\',0,-1)))
                                GUIDelete()
                                MsgBox(0,"pcbar","文件信息已保存至aa.ini")
                                ShellExecute("aa.ini")
                                Exit
                EndSelect
        WEnd
EndFunc   ;==>Example
 楼主| 发表于 2008-6-5 18:20:17 | 显示全部楼层
嗯,知道了,多谢版主大人
 楼主| 发表于 2008-6-5 18:58:27 | 显示全部楼层
啊,我用最笨的方法多加了几行,怎么有错误啊。



只能从最后先拖放,其次2和1处,能不能打乱顺序都可以啊。还有就是打开后,不执行拖放 直接退出程序,那配置文件里原先的信息就会被清空的,这个怎么解决好呢?

#include <GUIConstantsEx.au3>

Example()
 
Func Example()
    Local $file, $btn, $msg

    GUICreate(" My", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018)
    $file = GUICtrlCreateInput("", 10, 5, 300, 20)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    $file2 = GUICtrlCreateInput("", 10, 40, 300, 20)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    $file3 = GUICtrlCreateInput("", 10, 75, 300, 20)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    GUISetState()
    $msg = 0
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $file
                ExitLoop
            Case $msg =$GUI_EVENT_CLOSE
                $tmp=GUICtrlRead($file)
                $tmp2=GUICtrlRead($file2)
                $tmp3=GUICtrlRead($file3)
                IniWrite("aa.ini","sect","a1",$tmp)
                IniWrite("aa.ini","sect","a2",StringLeft($tmp,StringInStr($tmp,'\',0,-1)))

                IniWrite("aa.ini","sect","a3",$tmp2)
                IniWrite("aa.ini","sect","a4",StringLeft($tmp2,StringInStr($tmp2,'\',0,-1)))

                IniWrite("aa.ini","sect","a5",$tmp3)
                IniWrite("aa.ini","sect","a6",StringLeft($tmp3,StringInStr($tmp3,'\',0,-1)))
                GUIDelete()

                Exit
        EndSelect
    WEnd
EndFunc

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2008-6-5 20:50:00 | 显示全部楼层
if $tmp<>"" then .....
 楼主| 发表于 2008-6-5 20:52:58 | 显示全部楼层
什么?不太明白
发表于 2011-1-9 01:43:51 | 显示全部楼层
学习下~~赚点金币。。。
发表于 2011-2-18 20:37:35 | 显示全部楼层
学习了,,刚了学到配置。。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-10-2 14:32 , Processed in 0.082732 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表