Jump to content

Icon Mover


flip209
 Share

Recommended Posts

This randomliy moves icons on your desktop to random positions

#include <GuiListView.au3>

WinActivate("Program Manager")
WinWaitActive("Program Manager")
$shift = 0
HotKeySet("{EsC}", "_EXIT")

_Random_Icon_Move(100)

Func _exit()
    Exit
EndFunc   ;==>_exit

Func _Random_Icon_Move($sleep = 3000)
    ;Walk the listview items, saving their positions to the DSI file.
    While 1
        $hWnd_LV = ControlGetHandle("[CLASS:Progman]", "", "SysListView321")
        $nIdx = Random(0, _GUICtrlListView_GetItemCount($hWnd_LV) - 1, 1)
        $x = Random(0, @DesktopWidth - 30)
        $y = Random(0, @DesktopHeight - 30)
        $aPos = _GUICtrlListView_GetItemPosition($hWnd_LV, $nIdx)
        _GUICtrlListView_SetItemPosition($hWnd_LV, $nIdx, $x, $y)
        Sleep($sleep)
    WEnd
EndFunc   ;==>_Random_Icon_Move

" I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln

Link to comment
Share on other sites

It is not a habit it is an addiction. lol .....

Edited by flip209

" I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln

Link to comment
Share on other sites

I found moving icons to be rather fun so I gave it a shot to, it makes the icons foat around and bounce, well sort of:

#include <GuiListView.au3>
#include <array.au3>
Global $hWnd_LV = ControlGetHandle("[CLASS:Progman]", "", "SysListView321")
Global $icons[_GUICtrlListView_GetItemCount($hWnd_LV)][5] ; 0=id,1=xpos,2=ypos,3=xdir,4=ydir

For $i = 0 To UBound($icons, 1) - 1
    $icons[$i][0] = $i
    $temp = _GUICtrlListView_GetItemPosition($hWnd_LV, $i)
    $icons[$i][1] = $temp[0]
    $icons[$i][2] = $temp[1]
    $icons[$i][3] = Random(-1, 1) * 5
    $icons[$i][4] = Random(-1, 1) * 5
Next
$backup=$icons
_ArrayDisplay($backup)

WinActivate("Program Manager")
WinWaitActive("Program Manager")
HotKeySet("{EsC}", "_EXIT")

While 1
    Sleep(1)
    For $i = 0 To UBound($icons, 1) - 1
        $icons[$i][1] += $icons[$i][3]
        $icons[$i][2] += $icons[$i][4]
        _Iconmove($icons[$i][0], $icons[$i][1], $icons[$i][2])
        If $icons[$i][1] <= 0 And $icons[$i][3]<0 Then ;Or 
            $icons[$i][3] *= -1
        ElseIf $icons[$i][1] >= @DesktopWidth - 30 And $icons[$i][3]>0 Then
            $icons[$i][3] *= -1
        EndIf
        If $icons[$i][2] <= 0 Or $icons[$i][2] >= @DesktopHeight - 30 Then
            $icons[$i][4] *= -1
        EndIf
        
        For $j=0 To UBound($icons, 1) - 1
            If $j<>$i Then
                
                If $icons[$i][1]+30>=$icons[$j][1] And $icons[$i][1]<=$icons[$j][1]+30 And $icons[$i][2]+30>=$icons[$j][2] And $icons[$i][2]<=$icons[$j][2]+30 Then
                    $icons[$i][3]*=-1
                    $icons[$i][1]+=$icons[$i][3]
                    $icons[$j][3]*=-1
                    $icons[$j][1]+=$icons[$i][3]
                    If ($icons[$i][2]>0 And $icons[$j][2]<0) Or ($icons[$i][2]<0 And $icons[$j][2]>0) Then
                    $icons[$i][4]*=-1
                    $icons[$j][4]*=-1

                    EndIF
                EndIf

            EndIf
            Next
    Next
WEnd

Func _exit()
    For $t=0 To UBound($backup,1)-1
        _Iconmove($backup[$t][0],$backup[$t][1],$backup[$t][2])
    Next
    Exit
EndFunc   ;==>_exit

Func _Iconmove($id, $x, $y)
    _GUICtrlListView_SetItemPosition($hWnd_LV, $id, $x, $y)
EndFunc   ;==>_Iconmove

Ps. You have to have "Arrange to grid" (Or whatever it's called in english) disabled :D

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

I found moving icons to be rather fun so I gave it a shot to, it makes the icons foat around and bounce, well sort of:

#include <GuiListView.au3>
#include <array.au3>
Global $hWnd_LV = ControlGetHandle("[CLASS:Progman]", "", "SysListView321")
Global $icons[_GUICtrlListView_GetItemCount($hWnd_LV)][5] ; 0=id,1=xpos,2=ypos,3=xdir,4=ydir

For $i = 0 To UBound($icons, 1) - 1
    $icons[$i][0] = $i
    $temp = _GUICtrlListView_GetItemPosition($hWnd_LV, $i)
    $icons[$i][1] = $temp[0]
    $icons[$i][2] = $temp[1]
    $icons[$i][3] = Random(-1, 1) * 5
    $icons[$i][4] = Random(-1, 1) * 5
Next
$backup=$icons
_ArrayDisplay($backup)

WinActivate("Program Manager")
WinWaitActive("Program Manager")
HotKeySet("{EsC}", "_EXIT")

While 1
    Sleep(1)
    For $i = 0 To UBound($icons, 1) - 1
        $icons[$i][1] += $icons[$i][3]
        $icons[$i][2] += $icons[$i][4]
        _Iconmove($icons[$i][0], $icons[$i][1], $icons[$i][2])
        If $icons[$i][1] <= 0 And $icons[$i][3]<0 Then ;Or 
            $icons[$i][3] *= -1
        ElseIf $icons[$i][1] >= @DesktopWidth - 30 And $icons[$i][3]>0 Then
            $icons[$i][3] *= -1
        EndIf
        If $icons[$i][2] <= 0 Or $icons[$i][2] >= @DesktopHeight - 30 Then
            $icons[$i][4] *= -1
        EndIf
        
        For $j=0 To UBound($icons, 1) - 1
            If $j<>$i Then
                
                If $icons[$i][1]+30>=$icons[$j][1] And $icons[$i][1]<=$icons[$j][1]+30 And $icons[$i][2]+30>=$icons[$j][2] And $icons[$i][2]<=$icons[$j][2]+30 Then
                    $icons[$i][3]*=-1
                    $icons[$i][1]+=$icons[$i][3]
                    $icons[$j][3]*=-1
                    $icons[$j][1]+=$icons[$i][3]
                    If ($icons[$i][2]>0 And $icons[$j][2]<0) Or ($icons[$i][2]<0 And $icons[$j][2]>0) Then
                    $icons[$i][4]*=-1
                    $icons[$j][4]*=-1

                    EndIF
                EndIf

            EndIf
            Next
    Next
WEnd

Func _exit()
    For $t=0 To UBound($backup,1)-1
        _Iconmove($backup[$t][0],$backup[$t][1],$backup[$t][2])
    Next
    Exit
EndFunc   ;==>_exit

Func _Iconmove($id, $x, $y)
    _GUICtrlListView_SetItemPosition($hWnd_LV, $id, $x, $y)
EndFunc   ;==>_Iconmove

Ps. You have to have "Arrange to grid" (Or whatever it's called in english) disabled :D

I like....

" I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln

Link to comment
Share on other sites

Conversly, here's a script that saves your icon locations to an ini file and restores them when an ini is present. I got tired of having to re-arrange my icons everytime I did remote desktop from a machine with a lower resolution. Enjoy. 

Of course there are some limitations, such as icons created after the ini file has been will not be affected. Was thinking of adding an append icon to ini function.

Edit: Discovered that with the latest version of Win 10 I am running that the original script no longer works due to window name changes.  Updated code below

Tested on Win10x64 1709

#AutoIt3Wrapper_UseX64 = Y
#include <GuiListView.au3>

$inifile = "IconFreezer.ini"
$hWnd = WinWait("[CLASS:WorkerW]", "FolderView", 5)
$hWnd_LV = ControlGetHandle($hWnd,"FolderView","SysListView321")


If Not FileExists($inifile) Then
    _SaveIcons()
Else
    _RestoreIcons()
EndIf

Func _SaveIcons()
    FileClose(FileOpen($inifile,2))
    For $i = 0 to _GUICtrlListView_GetItemCount($hWnd_LV) - 1
        $iconposx = _GUICtrlListView_GetItemPositionX($hWnd_LV,$i)
        $iconposy = _GUICtrlListView_GetItemPositionY($hWnd_LV,$i)
        $iconname = _GUICtrlListView_GetItemText($hWnd_LV,$i)
        IniWriteSection($inifile,$iconname,"X=" & $iconposx & @LF & "Y=" & $iconposy)
    Next
EndFunc

Func _RestoreIcons()
    For $i = 0 To _GUICtrlListView_GetItemCount($hWnd_LV) - 1
        $iconpos = IniReadSection($inifile,_GUICtrlListView_GetItemText($hWnd_LV,$i))
        If IsArray($iconpos) Then
            $iconposx = _GUICtrlListView_GetItemPositionX($hWnd_LV,$i)
            $iconposy = _GUICtrlListView_GetItemPositionY($hWnd_LV,$i)
            If $iconposx <> $iconpos[1][1] Or $iconposy <> $iconpos[2][1] Then _GUICtrlListView_SetItemPosition($hWnd_LV, $i, $iconpos[1][1], $iconpos[2][1])
        EndIf
        $iconpos = 0
    Next
EndFunc

Old code

Spoiler
#include <GuiListView.au3>

$inifile = "IconFreezer.ini"
WinActivate("Program Manager")
WinWaitActive("Program Manager")
$hWnd_LV = ControlGetHandle("[CLASS:Progman]","","SysListView321")

If Not FileExists($inifile) Then 
    _SaveIcons()
Else
    _RestoreIcons()
EndIf

Func _SaveIcons()
    FileClose(FileOpen($inifile,2))
    For $i = 0 to _GUICtrlListView_GetItemCount($hWnd_LV) - 1
        $iconposx = _GUICtrlListView_GetItemPositionX($hWnd_LV,$i)
        $iconposy = _GUICtrlListView_GetItemPositionY($hWnd_LV,$i)
        $iconname = _GUICtrlListView_GetItemText($hWnd_LV,$i)
        IniWriteSection($inifile,$iconname,"X=" & $iconposx & @LF & "Y=" & $iconposy)
    Next
EndFunc

Func _RestoreIcons()
    For $i = 0 To _GUICtrlListView_GetItemCount($hWnd_LV) - 1
        $iconpos = IniReadSection($inifile,_GUICtrlListView_GetItemText($hWnd_LV,$i))
        If IsArray($iconpos) Then 
            $iconposx = _GUICtrlListView_GetItemPositionX($hWnd_LV,$i)
            $iconposy = _GUICtrlListView_GetItemPositionY($hWnd_LV,$i)
            If $iconposx <> $iconpos[1][1] Or $iconposy <> $iconpos[2][1] Then _GUICtrlListView_SetItemPosition($hWnd_LV, $i, $iconpos[1][1], $iconpos[2][1])
        EndIf
        $iconpos = 0    
    Next
EndFunc

 

 

Edited by spudw2k
Link to comment
Share on other sites

  • 5 months later...

it's a useless script which can be used to get troubles yourself :P

I've had a lot of fun with it at the office. Another tech and I are constantly messing with each other...it didn't take him two seconds to realize this one was me but it still was fun.
Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]
Link to comment
Share on other sites

  • 9 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...