zjg2003 发表于 2009-6-15 20:18:48

帮忙看下桌面图标定位的要怎么处理?

本帖最后由 zjg2003 于 2009-6-15 20:21 编辑

下面代码红色部为是我添加的,不怕摆好的位置被打乱,每5秒同步一次
但出了个问题:就是时间久了图标文字下面的黑色阴隐就更多,这个要怎么处理???
大家看图:注意图中的QQ2008这几个字





#NoTrayIcon
#AutoIt3Wrapper_icon=D:\autoit3\Aut2Exe\Icons\FOLDER.ico
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseAnsi=y
#AutoIt3Wrapper_Res_Comment=2008-04-19, 23:31
#AutoIt3Wrapper_Res_Description=桌面图标同步程序
#AutoIt3Wrapper_Res_Fileversion=1.0.0.1
#AutoIt3Wrapper_Res_LegalCopyright=Amu

#include <GuiListView.au3>
Opt("MustDeclareVars", 1)
Global $hWndManager = WinGetHandle("Program Manager")
Global $hWndDesktop = ControlGetHandle("Program Manager","",1)
If Not IsDeclared("GWL_STYLE") Then Global Const $GWL_STYLE = -16
Global $LVS_Style = _WinAPI_GetWindowLong($hWndDesktop, $GWL_STYLE)
Global $inifile, $iSet, $iRefresh, $SNAPTOGRID

If $CmdLine Then
    For $i = 1 To $CmdLine
      Select
            Case StringRegExp($CmdLine[$i], '^[/-](?i)load[=:].+$|^[/-](?i)l[=:].+$') And Not $inifile         
                $iSet = 1
                $inifile = StringRegExpReplace($CmdLine[$i], '^[/-](?i)load[=:]?|^[/-](?i)l[=:]?', "")

            Case StringRegExp($CmdLine[$i], '^[/-](?i)save[=:].+$|^[/-](?i)s[=:].+$') And Not $inifile
                $iSet = 0
                $inifile = StringRegExpReplace($CmdLine[$i], '^[/-](?i)save[=:]?|^[/-](?i)s[=:]?', "")

            Case StringRegExp($CmdLine[$i], '^[/-](?i)SnapToGrid[=:]\d+$|^[/-](?i)g[=:]\d+$') And $inifile         
                $SNAPTOGRID = Number (StringRegExpReplace($CmdLine[$i], '^[/-](?i)SnapToGrid[=:]?|^[/-](?i)g[=:]?', "") )

            Case StringRegExp($CmdLine[$i], '^[/-](?i)Refresh$|^[/-](?i)r$')
                $iRefresh = 1

            Case StringRegExp($CmdLine[$i], '^[/-](?i)Help$|^[/-](?i)[?h]$')
                MsgBox(64,"参数帮助!","AutoIcon.exe [</load|/save>=<file>] " & @CRLF & "" & @CRLF & _
                  "/load=file 要加载的配置文件。" & @CRLF & "/save=file 要保存的配置文件。" & @CRLF & _
                        "/G=<0|1>   为“0”取消图标对齐到网格,为“1”图标对齐到网格,默认不作更改。" & @CRLF & "/R         相当于桌面右键“刷新”")
                Exit
            Case Not $inifile
                $inifile = $CmdLine[$i]
                If FileExists($inifile) Then $iSet = 1
      EndSelect   
    Next
Else
    If Not IsDeclared("iMsgBoxAnswer") Then Dim $iMsgBoxAnswer
    $iMsgBoxAnswer = MsgBox(547,"注意!","" & @CRLF & "选“是”保存桌面图标位置信息到文件" & @CRLF & "" & @CRLF & "选“否”从文件读取并排列桌面图标。")
    Select
      Case $iMsgBoxAnswer = 6 ;Yes
            $inifile = FileSaveDialog( "输入一个文件名。", @ScriptDir, "配置文件(*.ini)", 2)
            If @error Or Not $inifile Then Exit
            $iSet = 0
            If Not StringRegExp($inifile, "\.ini$") Then $inifile &= ".ini"
      Case $iMsgBoxAnswer = 7 ;No
            $inifile = FileOpenDialog( "选择一个文件。", @ScriptDir, "配置文件(*.ini)", 1)
            If @error Or Not $inifile Then Exit
            $iSet = 1
      Case $iMsgBoxAnswer = 2 ;Cancel
            Exit
    EndSelect   
EndIf

If $iSet Then
    If $SNAPTOGRID Then $SNAPTOGRID = $LVS_EX_SNAPTOGRID
    If IsNumber ($SNAPTOGRID) Then _SendMessage($hWndDesktop, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_SNAPTOGRID, $SNAPTOGRID)
    If BitAND($LVS_Style, $LVS_AUTOARRANGE) Then _WinAPI_SetWindowLong($hWndDesktop, $GWL_STYLE, $LVS_Style - $LVS_AUTOARRANGE );取消自动排列

    If $iRefresh Then DllCall("shell32.dll", "none", "SHChangeNotify", "long", 0x8000000, "int", 0, "ptr", 0, "ptr", 0);刷新图标
   While 1
    _SaveAndLoadIconPos($inifile, 1)
    sleep(5000)
    Wend
    ;Run("RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters");刷新桌面(通过复制文件的方式替换壁纸文件适用)
Else
    _SaveAndLoadIconPos($inifile)
EndIf

Func _SaveAndLoadIconPos($iFile, $iLoad = 0)
    Local $iCount, $iIndex, $sName, $xy   
    If Not IsHWnd($hWndManager) Then $hWndManager = WinGetHandle("Program Manager")
    If Not IsHWnd($hWndDesktop) Then $hWndDesktop = ControlGetHandle("Program Manager","",1)
    $iCount = ControlListView($hWndManager, "", $hWndDesktop, "GetItemCount")
    If @error Then
      SetError(1)
      Return 0
    EndIf
    If Not $iLoad And FileExists($iFile) Then IniDelete($iFile, "图标位置")
    For $iIndex = 0 to $iCount - 1
      $sName = ControlListView($hWndManager, "", $hWndDesktop,"GetText", $iIndex)
      If $iLoad Then
            $xy = StringSplit (IniRead ($iFile, "图标位置", $sName, ""), ",")
            If $xy = 2 Then _
            _SendMessage($hWndDesktop, $LVM_SETITEMPOSITION, $iIndex, BitOR(BitShift($xy, -16), BitAND($xy, 0xffff) ) )
      Else;保存图标信息
            $xy = _GUICtrlListView_GetItemPosition($hWndDesktop, $iIndex)
            IniWrite($iFile, "图标位置", $sName, $xy & "," & $xy )
      EndIf   
    Next
    Return 1
EndFunc

iori76952652 发表于 2009-6-15 20:39:16

:face (29):

也想知道一下~

等待中......................................

zjg2003 发表于 2009-6-17 20:17:09

顶起来先...................

lynfr8 发表于 2009-6-17 22:12:28

打开注册表编辑器,进入HKEY_CURRENT_USER\ControlPanel\Desktop\WindowMetrics子键分支,双击ShellIconBPP键值项,在打开的“编辑字符串”对话框中,“数值数据”文本框内显示了桌面图标的颜色参数,系统默认的图标颜色参数为16。这里提供的可用颜色参数包括:4表示16种颜色,8表示256种颜色,16表示65536种颜色,24表示1600万种颜色,32表示TrueColor(真彩色)。你可以根据自己的不需要选择和设置你的桌面图标颜色参数。单击“确定”关闭“编辑字符串”对话框。注销当前用户并重新启动计算机后设置就生效。

如果上面行的话,在脚本原来那里加多一句注册表写入
当然这是治标的办法
治本还得弄懂原脚本的思路
我看着有点晕,不搞了。。。

zjg2003 发表于 2009-6-18 12:01:40

4# lynfr8

谢谢你,不过这样似乎真是不能治本。

0633zhou 发表于 2009-12-25 00:29:27

4# lynfr8

谢谢你,不过这样似乎真是不能治本。
页: [1]
查看完整版本: 帮忙看下桌面图标定位的要怎么处理?