Re: [x64 & x32 fix] DeskIcons - Get/Set Desktop Icon Positions
Posted: 01 Feb 2019, 06:46
@ iPhilip & joedf: Maybe some code and tips from Desktop Restore by Jamie O'Connell could be of help in some way.
Let's help each other out
https://www.autohotkey.com/boards/
Have you tried my suggestion with naming them 1.lnk, 2.lnk, etc then manually change the shortcut descriptions?
It's a function, you have to use it accordingly. Have you tried the example?fiffunD wrote: I created the script, however I don't see how to use it. Is a button or addition to a drop-down menu hiding from me somewhere? Thank you
Code: Select all
; save positions
coords := DeskIcons()
MsgBox now move the icons around yourself
; load positions
DeskIcons(coords)
No. Have you? Because it doesn't work that way. A BaseBar control actually contains a Rebar control that hosts a Toolbar control, much like the Taskbar's Quick Launch (at least in 9x and XP). All those icons appearing in the bar are actually toolbar buttons, and their order is saved somewhere regardless of the link name.
A little over a year ago I posted the above question. I was having an issue with hProcess not having a value because hwWindow and iProcessID didn't have a value. Long story short, I got around to looking at this and determined that the issue was twofold. First, neither ControlGet was getting a value. Changing A (active window) to ahk_class WorkerW partially fixed that (thanks r0IZ). Second, DetectHiddenWindows was preventing a value from being read. I have a large script and this was turned on at the top. This function not working in my script always baffled me because it worked fine in a script by itself. Very strange!Guest_3102018 wrote: ↑10 Mar 2018, 13:35I am having the same issue. Windows 10 x64 FCU. Currently I have this script in a larger script which has #Warn enabled. As a result, when it's not working, I receive a couple errors. Both are variables without assigned values. The latter is probably caused by the former but that would be more your department Hopefully this is helpful. If you need any other info, just ask.
iProcessID in hProcess := DllCall("OpenProcess" , "UInt", 0x438, "Int", FALSE, "ptr", iProcessID)
ret in Return, ret after DllCall("CloseHandle", "ptr", hProcess)
Code: Select all
DeskIcons(coords := "")
{
Critical
static MEM_COMMIT := 0x1000, PAGE_READWRITE := 0x04, MEM_RELEASE := 0x8000
static LVM_GETITEMPOSITION := 0x00001010, LVM_SETITEMPOSITION := 0x0000100F, WM_SETREDRAW := 0x000B
tempDetect := A_DetectHiddenWindows
DetectHiddenWindows, Off
ControlGet, hwWindow, HWND,, SysListView321, ahk_class Progman
if !hwWindow ; #D mode
ControlGet, hwWindow, HWND,, SysListView321, ahk_class WorkerW
IfWinExist ahk_id %hwWindow% ; last-found window set
WinGet, iProcessID, PID
hProcess := DllCall("OpenProcess" , "UInt", 0x438 ; PROCESS-OPERATION|READ|WRITE|QUERY_INFORMATION
, "Int", FALSE ; inherit = false
, "UInt", iProcessID)
if hwWindow and hProcess
{
ControlGet, list, list, Col1
ControlGet, list2, list, Col2
Loop, Parse, list2, `n
filetype_%A_Index% := SubStr(A_LoopField, 1, InStr(A_LoopField, " ") - 1)
if !coords
{
VarSetCapacity(iCoord, A_PtrSize * 2)
pItemCoord := DllCall("VirtualAllocEx", "UInt", hProcess, "UInt", 0, "UInt", 8, "UInt", MEM_COMMIT, "UInt", PAGE_READWRITE)
Loop, Parse, list, `n
{
SendMessage, %LVM_GETITEMPOSITION%, % A_Index-1, %pItemCoord%
DllCall("ReadProcessMemory", "UInt", hProcess, "UInt", pItemCoord, "UInt" . (A_PtrSize == 8 ? "64" : ""), &iCoord, "UInt", A_PtrSize * 2, "UIntP", cbReadWritten)
iconid := A_LoopField . "(" . filetype_%A_Index% . ")"
ret .= iconid ":" (NumGet(iCoord) & 0xFFFF) | ((Numget(iCoord, 4) & 0xFFFF) << 16) "`n"
}
DllCall("VirtualFreeEx", "UInt", hProcess, "UInt", pItemCoord, "UInt", 0, "UInt", MEM_RELEASE)
}
else
{
SendMessage, %WM_SETREDRAW%, 0, 0
Loop, Parse, list, `n
{
iconid := A_LoopField . "(" . filetype_%A_Index% . ")"
If RegExMatch(coords, "\Q" . iconid . "\E:\K.*", iCoord_new)
SendMessage, %LVM_SETITEMPOSITION%, % A_Index - 1, %iCoord_new%
}
SendMessage, %WM_SETREDRAW%, 1, 0
ret := true
}
}
DllCall("CloseHandle", "UInt", hProcess)
DetectHiddenWindows, % tempDetect
return ret
}
Ah, great observation! The left and middle monitor are 2560 wide (right one isn't, but that's irrelevant). So, the X value is obviously zero-based, meaning the middle monitor starts at 2560=0x0A00 and the right starts at 5120=0x1400.all your monitors have a horizontal resolution of 2560px
Makes sense, but I've never stacked 'em vertically.the vertical coordinates can also be negative if monitors are stacked vertically
Yep!But negative values seem to not be used here.