找回密码
 加入
搜索
查看: 13418|回复: 17

[AU3基础] 创建一个ini文件并填入所在路径 代码怎么写?

 火.. [复制链接]
发表于 2011-2-28 09:24:12 | 显示全部楼层 |阅读模式
悬赏100金钱已解决
本帖最后由 cjhhuanshao 于 2011-2-28 13:42 编辑

RT
要求:创建的ini文件 名字 Rainmeter.ini 并在里面写入以下内容
[Rainmeter]
SkinPath=D:\Rainmeter\Skins\

红色所在路径!

最佳答案

查看完整内容

回复 8# cjhhuanshao [au3]_IniWrite("Rainmeter.ini", "Rainmeter", "SkinPath", @ScriptDir & "\Skins\");不覆盖 _IniWrite("Rainmeter.ini", "Rainmeter", "SkinPath", @ScriptDir & "\Skins\", 1);覆盖 Func _IniWrite($sIniFile, $Config, $sPath, $IniPath, $Flag = 0) If $Flag = 1 Then FileDelete(@ScriptDir & '\' & $sIniFile) IniWrite($sIniFile, $Config, $sPath, $IniPath) EndFunc ;==>_IniWrite[/au3] ...
发表于 2011-2-28 09:24:13 | 显示全部楼层
回复 8# cjhhuanshao

_IniWrite("Rainmeter.ini", "Rainmeter", "SkinPath", @ScriptDir & "\Skins\");不覆盖
_IniWrite("Rainmeter.ini", "Rainmeter", "SkinPath", @ScriptDir & "\Skins\", 1);覆盖

Func _IniWrite($sIniFile, $Config, $sPath, $IniPath, $Flag = 0)
        If $Flag = 1 Then FileDelete(@ScriptDir & '\' & $sIniFile)
        IniWrite($sIniFile, $Config, $sPath, $IniPath)
EndFunc   ;==>_IniWrite
发表于 2011-2-28 09:37:09 | 显示全部楼层
本帖最后由 Joo 于 2011-2-28 09:38 编辑

$inipath="D:\Rainmeter\Skins\"

iniwrite($inipath&"Rainmeter.ini","Rainmeter","SkinPath",$inipath)
发表于 2011-2-28 09:37:57 | 显示全部楼层
inipath 我觉得还是需要你自己定义 先
 楼主| 发表于 2011-2-28 10:00:38 | 显示全部楼层
回复 2# Joo
没效果!
我的意思是 程序在那里目录就在填入所在路径 比如 程序在D:\美化工具\Rainmeter 创建的Rainmeter.ini里面内容

[Rainmeter]
SkinPath=D:\美化工具\Rainmeter\Skins\
发表于 2011-2-28 10:17:47 | 显示全部楼层
$sProPath = @ScriptDir
$sIniFile = "Rainmeter.ini"
IniWrite($sIniFile, "Rainmeter", "SkinPath", $sProPath & "\Skins")
 楼主| 发表于 2011-2-28 10:32:54 | 显示全部楼层
回复 5# easied
非常感谢,但如果Rainmeter.ini文件已经存在,就覆盖不了!如何覆盖呢?并提示 设置成功!
发表于 2011-2-28 10:44:28 | 显示全部楼层
你在写的时候先检查是否有*.ini.若有就删除不就好了。为何需要覆盖呢?
 楼主| 发表于 2011-2-28 10:47:03 | 显示全部楼层
回复 7# habou
这样也可以,可我不会写代码,失败阿!
 楼主| 发表于 2011-2-28 13:36:37 | 显示全部楼层
回复 9# lixiaolong
非常感谢!
发表于 2011-2-28 14:44:52 | 显示全部楼层
写了GUI
#include <GUIConstantsEx.au3>

GUICreate(" GUI 按钮", 200, 100) ; 创建居中显示的对话框窗口
$Button1 = GUICtrlCreateButton("创建ini文件(不覆盖)", 10, 30)
$Button2 = GUICtrlCreateButton("创建ini文件(覆盖)", 10, 60)

GUISetState() ; 显示有两个按钮的窗口

While 1
        $msg = GUIGetMsg()
        Select
                Case $msg = $GUI_EVENT_CLOSE
                        ExitLoop
                Case $msg = $Button1
                        _IniWrite("Rainmeter.ini", "Rainmeter", "SkinPath", @ScriptDir & "\Skins\");不覆盖
                        MsgBox(0, 0, 'OK!')
                Case $msg = $Button2
                        _IniWrite("Rainmeter.ini", "Rainmeter", "SkinPath", @ScriptDir & "\Skins\", 1);覆盖
                        MsgBox(0, 0, 'OK!')
        EndSelect
WEnd

Func _IniWrite($sIniFile, $Config, $sPath, $IniPath, $Flag = 0)
        If $Flag = 1 Then FileDelete(@ScriptDir & '\' & $sIniFile)
        IniWrite($sIniFile, $Config, $sPath, $IniPath)
EndFunc   ;==>_IniWrite
发表于 2011-2-28 15:02:50 | 显示全部楼层
学习下了。。
发表于 2011-2-28 15:40:32 | 显示全部楼层
iniwrite本来就是不存在则写入,存在则修改的.
哪来的不能覆盖的说法?
 楼主| 发表于 2011-2-28 15:54:34 | 显示全部楼层
本帖最后由 cjhhuanshao 于 2011-2-28 18:26 编辑

回复 11# lixiaolong
太感谢你了,这就是我想要的结果,但还要想一个功能就是把路径显示出来!

本帖子中包含更多资源

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

×
发表于 2011-2-28 19:06:57 | 显示全部楼层
回复 14# cjhhuanshao

这样可以吗?


#include <GUIConstantsEx.au3>

GUICreate(" GUI 按钮", 310, 55); 创建居中显示的对话框窗口
$Button1 = GUICtrlCreateButton("确定", 260, 25, 45, 25)
GUICtrlCreateLabel(":当前皮肤路径", 5, 10)
$Input = GUICtrlCreateInput("", 5, 25, 250, 25)
GUISetState() ; 显示有两个按钮的窗口

While 1
        $msg = GUIGetMsg()
        Select
                Case $msg = $GUI_EVENT_CLOSE
                        ExitLoop
                Case $msg = $Button1
                        _IniWrite("Rainmeter.ini", "Rainmeter", "SkinPath", @ScriptDir & "\Skins\", 1);覆盖
                        MsgBox(0, 0, 'OK!')
        EndSelect
WEnd

Func _IniWrite($sIniFile, $Config, $sPath, $IniPath, $Flag = 0)
        If $Flag = 1 Then FileDelete(@ScriptDir & '\' & $sIniFile)
        IniWrite($sIniFile, $Config, $sPath, $IniPath)
        $lujin = IniRead($sIniFile, $Config, $sPath, ''); 读取ini文件SkinPath=的值.
        GUICtrlSetData($Input, $lujin); $Input上显示当前皮肤路径($lujin)
EndFunc   ;==>_IniWrite

本帖子中包含更多资源

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

×
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-11 17:31 , Processed in 0.086734 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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