Jump to content
Sign in to follow this  
matumbo

Just a question

Recommended Posts

matumbo

Hi, I've been useing this script

#INCLUDE <A3LListView.au3>

;Get runtime instructions
If @COMPILED Then
Switch $CmdLine[0]
Case 0
$sMode = "/INSTALL"
Case 2
$sMode = ( $CmdLine[1] );/SAVE or /RESTORE
$sINI = $CmdLine[2];the *.ICN filename to use as ini file
Case Else
MsgBox( 4096 + 48, @SCRIPTNAME, "Error - Commandline Usage:" & @LF & @LF & 'IconMap.exe /save "<.icn filename>"' & @LF & 'IconMap.exe /restore "<.icn filename>"' )
EndSwitch
Else
;Designtime testing ;o)
$sMode = "/RESTORE"
$sINI = "D:\AU3_Functions\Trids\IconMap\Settings_1.icn"
Endif

;Get a handle on the desktop, which is actually a listview control.
$hWnd_LV = ControlGetHandle( "Program Manager", "", "SysListView321" )

;Save or Restore?
Switch StringUpper( $sMode )
Case "/SAVE"
;Drop all previous icon positions
IniDelete(  $sINI, "Icons" )
;Walk the listview items, saving their positions to the INI file.
For $nIdx = 0 to _ListView_GetItemCount( $hWnd_LV ) - 1
$sIconText = _ListView_GetItemText( $hWnd_LV, $nIdx ) 
$aPos = _ListView_GetItemPosition( $hWnd_LV, $nIdx )
IniWrite( $sINI, "Icons", $sIconText, $aPos[0] & ";" & $aPos[1] )
Next
Beep( 1500, 100 )
Beep( 1000, 100 )
Beep( 500, 100 )

Case "/RESTORE"
;Walk the listview items, applying their positions from the INI file.
For $nIdx = 0 to _ListView_GetItemCount( $hWnd_LV ) - 1
$sIconText = _ListView_GetItemText( $hWnd_LV, $nIdx ) 
$aPos = StringSplit( IniRead( $sINI, "Icons", $sIconText, "0;0" ), ";" )
if $aPos[0] <> 2 Then
MsgBox( 0, @SCRIPTNAME, "Error - invalid coordinates for icon:" & @LF & @LF & $sIconText )
Exit
Endif
_ListView_SetItemPosition( $hWnd_LV, $nIdx, $aPos[1], $aPos[2] )
Next
Beep( 500, 100 )
Beep( 1000, 100 )
Beep( 1500, 100 )

Case "/INSTALL"
;setup a context menu for the command shell
If MsgBox( 4096 + 4 + 32, @SCRIPTNAME, "Configure shell options for Right-clicking on *.ICN map files?" ) = 6 Then ;6=Yes
;Prep Registry entries to handle ".icn" files
RegWrite( "HKCR\.icn", "", "REG_SZ", "IconMaps" ) 
RegWrite( "HKCR\IconMaps", "", "REG_SZ", "Desktop Icon Positions" ) 
RegWrite( "HKCR\IconMaps\Shell", "", "REG_SZ", "1_save" ) 
RegWrite( "HKCR\IconMaps\Shell\1_save", "", "REG_SZ", "S&ave IconMap layout" ) 
RegWrite( "HKCR\IconMaps\Shell\1_save\command", "", "REG_SZ", '"C:\Program Files\IconMaps\IconMap.exe" /save "%1"' ) 
RegWrite( "HKCR\IconMaps\Shell\2_restore", "", "REG_SZ", "R&estore IconMap layout" ) 
RegWrite( "HKCR\IconMaps\Shell\2_restore\command", "", "REG_SZ", '"C:\Program Files\IconMaps\IconMap.exe" /restore "%1"' )
Endif
Case Else
MsgBox( 4096 + 48, @SCRIPTNAME, "Error - Switch Usage:" & @LF & @LF & 'IconMap.exe /save "<.icn filename>"' & @LF & 'IconMap.exe /restore "<.icn filename>"' )

EndSwitch

It's meant to save the dekstop icons postions if it's compiled.

but if I don't compile it, if I just click "Run script" it's randoms all my icons

can any1 tell me what in the script randoms my icons?

Share this post


Link to post
Share on other sites
PsaltyDS

Hi, I've been useing this script

It's meant to save the dekstop icons postions if it's compiled.

but if I don't compile it, if I just click "Run script" it's randoms all my icons

can any1 tell me what in the script randoms my icons?

Two things: First, put in some debug points to see if you are getting the values you want from the INI. Second, try _ListView_SetItemPosition32() vice _ListView_SetItemPosition():

ConsoleWrite("Debug: $aPos[1] = " & $aPos[1] & "  $aPos[2] = " & $aPos[2] & @LF)
_ListView_SetItemPosition32( $hWnd_LV, $nIdx, $aPos[1], $aPos[2] )

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×