找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 7589|回复: 0

Autoit3(AU3) 桌面图标位置设置

[复制链接]
发表于 2011-7-24 09:03:13 | 显示全部楼层 |阅读模式
  1. #NoTrayIcon
  2. #Region ;**** 参数创建于 ACNWrapper_GUI ****
  3. #AutoIt3Wrapper_icon=U:\autoit3\Aut2Exe\Icons\strawberry.ico
  4. #AutoIt3Wrapper_outfile=AutoIcon.exe
  5. #AutoIt3Wrapper_Compression=4
  6. #AutoIt3Wrapper_Res_Comment=桌面图标设置
  7. #AutoIt3Wrapper_Res_Description=网吧桌面图标设置
  8. #AutoIt3Wrapper_Res_Fileversion=1.0.0.1
  9. #AutoIt3Wrapper_Res_LegalCopyright=SxyNetBar
  10. #EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
  11. #AutoIt3Wrapper_UseAnsi=y
  12. #include <GuiListView.au3>
  13. Opt("MustDeclareVars", 1)
  14. Global $hWndManager = WinGetHandle("Program Manager")
  15. Global $hWndDesktop = ControlGetHandle("Program Manager","",1)
  16. If Not IsDeclared("GWL_STYLE") Then Global Const $GWL_STYLE = -16
  17. Global $LVS_Style = _WinAPI_GetWindowLong($hWndDesktop, $GWL_STYLE)
  18. Global $inifile, $iSet, $iRefresh, $SNAPTOGRID
  19. If $CmdLine[0] Then
  20.      For $i = 1 To $CmdLine[0]
  21.          Select
  22.              Case StringRegExp($CmdLine[$i], '^[/-](?i)load[=:].+$|^[/-](?i)l[=:].+$') And Not $inifile        
  23.                  $iSet = 1
  24.                  $inifile = StringRegExpReplace($CmdLine[$i], '^[/-](?i)load[=:]?|^[/-](?i)l[=:]?', "")
  25.                
  26.              Case StringRegExp($CmdLine[$i], '^[/-](?i)save[=:].+$|^[/-](?i)s[=:].+$') And Not $inifile
  27.                  $iSet = 0
  28.                  $inifile = StringRegExpReplace($CmdLine[$i], '^[/-](?i)save[=:]?|^[/-](?i)s[=:]?', "")
  29.                
  30.              Case StringRegExp($CmdLine[$i], '^[/-](?i)SnapToGrid[=:]\d+$|^[/-](?i)g[=:]\d+$') And $inifile        
  31.                  $SNAPTOGRID = Number (StringRegExpReplace($CmdLine[$i], '^[/-](?i)SnapToGrid[=:]?|^[/-](?i)g[=:]?', "") )
  32.                
  33.              Case StringRegExp($CmdLine[$i], '^[/-](?i)Refresh$|^[/-](?i)r$')
  34.                  $iRefresh = 1
  35.                
  36.              Case StringRegExp($CmdLine[$i], '^[/-](?i)Help$|^[/-](?i)[?h]$')
  37.                  MsgBox(64,"参数帮助!","AutoIcon.exe [</load|/save>=<file>] [/G=<0|1>] [/R]" & @CRLF & "" & @CRLF & _
  38.                      "/load=file 要加载的配置文件。" & @CRLF & "/save=file 要保存的配置文件。" & @CRLF & _
  39.                          "/G=<0|1>   为“0”取消图标对齐到网格,为“1”图标对齐到网格,默认不作更改。" & @CRLF & "/R         相当于桌面右键“刷新”")
  40.                  Exit
  41.              Case Not $inifile
  42.                  $inifile = $CmdLine[$i]
  43.                  If FileExists($inifile) Then $iSet = 1
  44.          EndSelect   
  45.      Next
  46. Else
  47.      If Not IsDeclared("iMsgBoxAnswer") Then Dim $iMsgBoxAnswer
  48.      $iMsgBoxAnswer = MsgBox(547,"注意!","" & @CRLF & "选“是”保存桌面图标位置信息到文件" & @CRLF & "" & @CRLF & "选“否”从文件读取并排列桌面图标。")
  49.      Select
  50.          Case $iMsgBoxAnswer = 6 ;Yes
  51.              $inifile = FileSaveDialog( "输入一个文件名。", @ScriptDir, "配置文件(*.ini)", 2)
  52.              If @error Or Not $inifile Then Exit
  53.              $iSet = 0
  54.              If Not StringRegExp($inifile, "\.ini$") Then $inifile &= ".ini"
  55.          Case $iMsgBoxAnswer = 7 ;No
  56.              $inifile = FileOpenDialog( "选择一个文件。", @ScriptDir, "配置文件(*.ini)", 1)
  57.              If @error Or Not $inifile Then Exit
  58.              $iSet = 1
  59.          Case $iMsgBoxAnswer = 2 ;Cancel
  60.              Exit
  61.      EndSelect   
  62. EndIf
  63. If $iSet Then
  64.      If $SNAPTOGRID Then $SNAPTOGRID = $LVS_EX_SNAPTOGRID
  65.      If IsNumber ($SNAPTOGRID) Then _SendMessage($hWndDesktop, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_SNAPTOGRID, $SNAPTOGRID)
  66.      If BitAND($LVS_Style, $LVS_AUTOARRANGE) Then _WinAPI_SetWindowLong($hWndDesktop, $GWL_STYLE, $LVS_Style - $LVS_AUTOARRANGE );取消自动排列
  67.    
  68.      If $iRefresh Then DllCall("shell32.dll", "none", "SHChangeNotify", "long", 0x8000000, "int", 0, "ptr", 0, "ptr", 0);刷新图标
  69.      _SaveAndLoadIconPos($inifile, 1)
  70.      ;Run("RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters");刷新桌面(通过复制文件的方式替换壁纸文件适用)
  71. Else
  72.      _SaveAndLoadIconPos($inifile)
  73. EndIf
  74. Func _SaveAndLoadIconPos($iFile, $iLoad = 0)
  75.      Local $iCount, $iIndex, $sName, $xy   
  76.      If Not IsHWnd($hWndManager) Then $hWndManager = WinGetHandle("Program Manager")
  77.      If Not IsHWnd($hWndDesktop) Then $hWndDesktop = ControlGetHandle("Program Manager","",1)
  78.      $iCount = ControlListView($hWndManager, "", $hWndDesktop, "GetItemCount")
  79.      If @error Then
  80.          SetError(1)
  81.          Return 0
  82.      EndIf
  83.      If Not $iLoad And FileExists($iFile) Then IniDelete($iFile, "图标位置")
  84.      For $iIndex = 0 to $iCount - 1
  85.          $sName = ControlListView($hWndManager, "", $hWndDesktop,"GetText", $iIndex)
  86.          If $iLoad Then
  87.              $xy = StringSplit (IniRead ($iFile, "图标位置", $sName, ""), ",")
  88.              If $xy[0] = 2 Then _
  89.              _SendMessage($hWndDesktop, $LVM_SETITEMPOSITION, $iIndex, BitOR(BitShift($xy[2], -16), BitAND($xy[1], 0xffff) ) )
  90.          Else;保存图标信息
  91.              $xy = _GUICtrlListView_GetItemPosition($hWndDesktop, $iIndex)
  92.              IniWrite($iFile, "图标位置", $sName, $xy[0] & "," & $xy[1] )
  93.          EndIf   
  94.      Next
  95.      Return 1
  96. EndFunc
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

蓝色动力网络微信平台
网站管理,业务合作联系邮箱: admin#lansedongli.com    QQ:13412492 限网站业务问题.
网站帐号、密码、密保找回请使用注册邮箱,发送邮件至 password#lansedongli.com ,否则不予受理.
免责声明:本论坛所有文字和图片仅代表其个人观点.
本站某些资料或文章来自于互联网,不代表本站观点,如果侵犯了您的权益,请来信告知,我们会在三天内删除.
为了给大家一个更好的交流场所,请勿在本论坛发表与中华人民共和国法律相抵触的言论,请合作,谢谢!
Copyright © 2007-2025 Corporation Powered by网吧系统 版权所有    程序:Discuz! X3.5

Archiver|手机版|蓝色动力网络 ( 浙ICP备11043737号-1|湘公网安备 43018102000145号 )  

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