xingwei001 发表于 2008-8-29 11:21:47

IT精英技术交流QQ群:24166429

网络技术研究讨论群:24166429欢迎大家加入 本群的目的 希望大家以后都要成为IT精英。



      自动更换壁纸

#NoTrayIcon
#include <GUIConstants.au3>

Dim $inifile_path=@ScriptDir&"\List.ini"
Dim $bmp
Dim $sTmpFile
Dim $List_I
Dim $Item
Dim $New_ID
Global $sFilename = @ScriptFullPath

If Not FileExists( $inifile_path ) Then
MsgBox(16,"错误!","找不到"&$inifile_path&"程序无法继续!!")
Exit
EndIf

If $CmdLine<=0 Then
setup()
Else
set_b_pic()
EndIf

Func setup()
   Local $L
$Form1 = GUICreate("墙纸列表", 491, 320, 192, 125)
$Input1 = GUICtrlCreateInput("", 40, 8, 273, 21, -1, $WS_EX_CLIENTEDGE)
$Button1 = GUICtrlCreateButton("...", 320, 7, 30, 25)
$Button2 = GUICtrlCreateButton("添加", 355, 7, 38, 25)
$Button3 = GUICtrlCreateButton("修改", 400, 7, 38, 25)
$Button4 = GUICtrlCreateButton("删除", 445, 7, 38, 25)
$ListView1 = GuiCtrlCreateListView("编号|键名|路径", 8, 40, 474, 270)
GUICtrlCreateLabel("路径:", 8, 13, 31, 17)
GUISetState(@SW_SHOW)
Local $List = IniReadSection ($inifile_path,"main")
   If @error Then
   MsgBox(16,"错误!","读取"&$inifile_path&"失败,程序无法继续!!")
   Exit
EndIf
   
For $i=1 To $List
   $New_ID=UBound($Item)+1
   ReDim $Item[$New_ID]
   $L=$i
   $Item[$New_ID-1]=GUICtrlCreateListViewItem($i&"|"&$List[$i]&"|"&$List[$i],$ListView1)
Next

While 1
   $msg = GuiGetMsg()
   
   $sCurFilename = GUICtrlRead($Input1)
   If $sCurFilename <> $sFilename Then
    $iStartIndex = 0
    $sFilename = $sCurFilename
   Endif
   
   Select
    Case $msg = $GUI_EVENT_CLOSE
   ExitLoop
    Case $msg=$Button1
    $sTmpFile = FileOpenDialog("选择图片:", $sFilename, "文件: (*.bmp)")
             If @error Then ContinueLoop
             GUICtrlSetData($Input1, $sTmpFile)
   Case $msg=$Button2
    If $sFilename="" Then
   MsgBox(48,"傻了!!","傻了,你没有输入文件名怎么添加呀?")
    Else
   $New_ID=UBound($Item)+1
   ReDim $Item[$New_ID]
   IniWrite ( $inifile_path, "main",$List[$List]+1,$sFilename)
   If @error Then
      Exit
   EndIf
   $List = IniReadSection ($inifile_path,"main")
   $L=$L+1
   $Item[$New_ID-1]=GUICtrlCreateListViewItem($New_ID-1&"|"&$List[$List]&"|"&$List[$List],$ListView1)
    EndIf
   Case $msg=$Button3
    If $sFilename="" Then
   MsgBox(48,"傻了!!","傻了,你没有输入文件名怎么修改呀?")
    ElseIf GUICtrlRead($ListView1)=0 Then
   MsgBox(48,"傻B!!","傻B你不选择怎么修改?")
    Else
   Local $N=GUICtrlRead($Item)
   Local $Temp_A=StringSplit($N,"|")
   IniWrite ( $inifile_path, "main", $Temp_A, $sFilename )
   $List = IniReadSection ($inifile_path,"main")
   GuiCtrlSetData($Item[$Temp_A],$Temp_A&"|"&$List[$Temp_A]&"|"&$List[$Temp_A])
    EndIf
   Case $msg=$Button4
    If GUICtrlRead($ListView1)=0 Then
   MsgBox(48,"傻B!!","傻B你不选择怎么删除呀?")
    Else
   Local $N=GUICtrlRead($Item)
   Local $Temp_A=StringSplit($N,"|")
   $List = IniReadSection ($inifile_path,"main")
   If $List=1 Then
      MsgBox(48,"警告!!","至少要保留一张墙纸!!")
   Else
      IniDelete($inifile_path,"main",$Temp_A)
      GUICtrlDelete($Item[$Temp_A])
   EndIf
    EndIf
   Case Else
   EndSelect
WEnd
EndFunc

Func set_b_pic()
Local $List = IniReadSection ($inifile_path,"main")
   If @error Then
   MsgBox(16,"错误!","读取"&$inifile_path&"失败,程序无法继续!!")
   Exit
EndIf
Local $R = Round (Random ("1",$List),0)
If $R=0 Then $R=1
Local $bmp = $List[$R]
If FileExists( $bmp ) Then
   dllcall("user32","int","SystemParametersInfo","int",20,"int",1,"str",$bmp,"int",1)
Else
   MsgBox(48,"警告!!","找不到"&$bmp)
EndIf
EndFunc

74554128 发表于 2009-5-12 12:39:07

:face (17):

a85848059 发表于 2011-3-19 18:30:46

很棒 推推推

831221 发表于 2011-3-29 14:33:16

如果是在说的我的话就让人笑话了

zysanjing 发表于 2011-3-30 22:24:40

http://www.autoitx.com/?fromuid=7655462更多资料查看这里~

chentuyu1203 发表于 2012-12-6 12:12:49

支持一下。。群上主要讨论什么的?

jasonny 发表于 2012-12-23 23:30:23

感謝大大分享
页: [1]
查看完整版本: IT精英技术交流QQ群:24166429