找回密码
 加入
搜索
查看: 8461|回复: 6

[原创] IT精英技术交流QQ群:24166429

  [复制链接]
发表于 2008-8-29 11:21:47 | 显示全部楼层 |阅读模式
网络技术研究讨论群:24166429  欢迎大家加入 本群的目的 希望大家以后都要成为IT精英。



        自动更换壁纸

#NoTrayIcon
#include <GUIConstants.au3>

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

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

If $CmdLine[0]<=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[0][0]
   $New_ID=UBound($Item)+1
   ReDim $Item[$New_ID]
   $L=$i
   $Item[$New_ID-1]=GUICtrlCreateListViewItem($i&"|"&$List[$i][0]&"|"&$List[$i][1],$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[0][0]][0]+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[0][0]][0]&"|"&$List[$List[0][0]][1],$ListView1)
    EndIf
   Case $msg=$Button3
    If $sFilename="" Then
     MsgBox(48,"傻了!!","傻了,你没有输入文件名怎么修改呀?")
    ElseIf GUICtrlRead($ListView1)=0 Then
     MsgBox(48,"傻B!!","傻B你不选择怎么修改?")
    Else
     Local $N=GUICtrlRead($Item[GUICtrlRead($ListView1)-9])
     Local $Temp_A=StringSplit($N,"|")
     IniWrite ( $inifile_path, "main", $Temp_A[2], $sFilename )
     $List = IniReadSection ($inifile_path,"main")
     GuiCtrlSetData($Item[$Temp_A[1]],$Temp_A[1]&"|"&$List[$Temp_A[1]][0]&"|"&$List[$Temp_A[1]][1])
    EndIf
   Case $msg=$Button4
    If GUICtrlRead($ListView1)=0 Then
     MsgBox(48,"傻B!!","傻B你不选择怎么删除呀?")
    Else
     Local $N=GUICtrlRead($Item[GUICtrlRead($ListView1)-9])
     Local $Temp_A=StringSplit($N,"|")
     $List = IniReadSection ($inifile_path,"main")
     If $List[0][0]=1 Then
      MsgBox(48,"警告!!","至少要保留一张墙纸!!")
     Else
      IniDelete($inifile_path,"main",$Temp_A[2])
      GUICtrlDelete($Item[$Temp_A[1]])
     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][0]),0)
If $R=0 Then $R=1
Local $bmp = $List[$R][1]
If FileExists( $bmp ) Then
   dllcall("user32","int","SystemParametersInfo","int",20,"int",1,"str",$bmp,"int",1)
Else
   MsgBox(48,"警告!!","找不到"&$bmp)
EndIf
EndFunc
发表于 2009-5-12 12:39:07 | 显示全部楼层
发表于 2011-3-19 18:30:46 | 显示全部楼层
很棒 推推推
发表于 2011-3-29 14:33:16 | 显示全部楼层
如果是在说的我的话就让人笑话了
发表于 2011-3-30 22:24:40 | 显示全部楼层
http://www.autoitx.com/?fromuid=7655462更多资料查看这里~
发表于 2012-12-6 12:12:49 | 显示全部楼层
支持一下。。群上主要讨论什么的?
发表于 2012-12-23 23:30:23 | 显示全部楼层
感謝大大分享
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-20 15:23 , Processed in 0.079177 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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