Desktop Grid Topic is solved
Desktop Grid
Hi
Is there a way to get (Sysget?) or calculate the current icon grid of your desktop, something like 25 icons wide x 10 icons high?
Is there a way to get (Sysget?) or calculate the current icon grid of your desktop, something like 25 icons wide x 10 icons high?
Re: Desktop Grid
An idea:
First minimize all open windows
While your mouse is over an icon, the icon borders are displayed in a specific color, I suppose it depends on how you configured the screen colors. Use Window spy to check what color that is.
Move the mouse near the left upper corner of the screen, so that it is over the first icon. Search for the first occurrence of that color first from the left edge toward the right side, then from the top of the screen toward the bottom. Make sure that you are on an icon border by checking that several pixels above and below an assumed vertical line have exactly the same color, and the same to the left and the right of an assumed horizontal line (if that is not the case, the pixel you found is part of the icon and not part of the icon border line). This gives you the width and the height of one icon.
Divide the screen width by the icon width, and the screen height by the icon height, and you're done.
First minimize all open windows
While your mouse is over an icon, the icon borders are displayed in a specific color, I suppose it depends on how you configured the screen colors. Use Window spy to check what color that is.
Move the mouse near the left upper corner of the screen, so that it is over the first icon. Search for the first occurrence of that color first from the left edge toward the right side, then from the top of the screen toward the bottom. Make sure that you are on an icon border by checking that several pixels above and below an assumed vertical line have exactly the same color, and the same to the left and the right of an assumed horizontal line (if that is not the case, the pixel you found is part of the icon and not part of the icon border line). This gives you the width and the height of one icon.
Divide the screen width by the icon width, and the screen height by the icon height, and you're done.
Re: Desktop Grid
@braunbaer, I don't think that will work. If you look at my screenshot, you will see that the size of the highlighted area is determined by whether the icon has a single- or multi-line title and also whether it is selected or not. If the icon has a multi-line title, but is not selected (like the "DisplayFus..." icon below), just hovering over it will show a smaller highlighted area than it does if selected. Additionally, notice the amount of unused vertical space between icons. Just dividing your screen size by the highlighted area will (depending on your resolution and scaling) probably give you more icons than are actually there - even if you round down. I can't give you a solution to this, but I can tell you that your suggestion is somewhat flawed.
Russ
Russ
Re: Desktop Grid
@RussF - what about to use the checkmark boxes (that are AFAICS at a static position within an icons variable framing) as markers on a virtual grid?
Re: Desktop Grid
@BoBo, that is certainly a possibility, but the user must have "View checkboxes" selected in File Explorer. It would then be a matter of calculating the distance from one checkbox to another. Somehow I feel that display scaling would still be a factor and would have to be taken into account in the calculations.
Russ
Russ
Re: Desktop Grid
Isn't there a chance to extract the currently used desktop icon size info from the system/registry so no visual interference is necessary to get the data for a following calculation?
Re: Desktop Grid
Yes, you can get it from HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics. The keys are IconSpacing and IconVerticalSpacing. The numbers are negative values, the most common default being -1125. You can change these, numbers closer to 0 (less negative) having tighter spacing and higher negative values being farther apart. Unfortunately, I have not yet found a resource that interprets exactly what those numbers represent.
Russ
Russ
Re: Desktop Grid
Yep, the 'negative number thing' is looking kinda obscure…
"The default value is -1128. The minimum amount of space is -480, and the maximum is -2730."
https://www.tenforums.com/tutorials/16941-change-desktop-icon-spacing-windows-10-a.html
https://answers.microsoft.com/en-us/windows/forum/all/why-is-the-spacing-of-desktop-icons-as-set-in-the/75738637-0acb-4e7a-8b3d-7eb88cbec728
Looks kinda related…
https://www.autohotkey.com/board/topic/24632-reference-negative-icon-numbers/
"The default value is -1128. The minimum amount of space is -480, and the maximum is -2730."
https://www.tenforums.com/tutorials/16941-change-desktop-icon-spacing-windows-10-a.html
https://answers.microsoft.com/en-us/windows/forum/all/why-is-the-spacing-of-desktop-icons-as-set-in-the/75738637-0acb-4e7a-8b3d-7eb88cbec728
Looks kinda related…
https://www.autohotkey.com/board/topic/24632-reference-negative-icon-numbers/
Re: Desktop Grid
First, I'd like to thank everybody for their contribution.
And I'll add that what I definitely is a autohotkey/windows dll solution not involving manual/visual counting
I'll look into the registry key direction to see if I can find out anything useful.
And I'll add that what I definitely is a autohotkey/windows dll solution not involving manual/visual counting
I'll look into the registry key direction to see if I can find out anything useful.
-
- Posts: 4331
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Desktop Grid Topic is solved
For one monitor this should work:
Code: Select all
GetWorkArea(workWidth, workHeight)
GetDesktopSpacing(widthSpacing, heightSpacing)
MsgBox, % grid := workWidth//widthSpacing . "x" . workHeight//heightSpacing
GetWorkArea(ByRef width, ByRef height) {
static SPI_GETWORKAREA := 0x30
VarSetCapacity(RECT, 16, 0)
res := DllCall("SystemParametersInfo", "UInt", SPI_GETWORKAREA, "UInt", 0, "Ptr", &RECT, "UInt", 0)
width := NumGet(RECT, 8, "UInt") - NumGet(RECT, "UInt")
height := NumGet(RECT, 12, "UInt") - NumGet(RECT, 4, "UInt")
Return res
}
GetDesktopSpacing(ByRef widthSpacing, ByRef heightSpacing) {
static SID_STopLevelBrowser := "{4C96BE40-915C-11CF-99D3-00AA004AE837}"
, IID_IShellBrowser := "{000214E2-0000-0000-C000-000000000046}"
, IID_IFolderView := "{CDE725B0-CCC9-4519-917E-325D72FAB4CE}"
, VT_UI4 := 0x13, SWC_DESKTOP := 0x8
shellWindows := ComObjCreate("Shell.Application").Windows
desktop := shellWindows.Item( ComObject(VT_UI4, SWC_DESKTOP) )
IShellBrowser := ComObjQuery(desktop, SID_STopLevelBrowser, IID_IShellBrowser)
; IShellBrowser::QueryActiveShellView
DllCall(NumGet(NumGet(IShellBrowser + 0) + A_PtrSize*15), "Ptr", IShellBrowser, "PtrP", IShellView)
IFolderView := ComObjQuery(IShellView, IID_IFolderView)
; IFolderView::GetSpacing
hr := DllCall(NumGet(NumGet(IFolderView + 0) + A_PtrSize*12), "Ptr", IFolderView, "Int64P", point)
ObjRelease(IFolderView), ObjRelease(IShellView), ObjRelease(IShellBrowser)
widthSpacing := point & 0xFFFFFFFF
heightSpacing := point >> 32
Return hr
}
Re: Desktop Grid
Well done @teadrinker !!!
We're not worthy, we're not worthy!
Russ
We're not worthy, we're not worthy!
Russ
-
- Posts: 4331
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Desktop Grid
Haha, I'm not Alice Cooper!
Re: Desktop Grid
Thanks to @teadrinker for the PERFECT ANSWER
It's exactly what I was looking for.
It's exactly what I was looking for.