I have code that in theory should allow to movement of desktop icons based on their names. The code is not functional. I've tried using different shortcut names to no avail. Here is the code.
#AutoIt3Wrapper_UseX64=y
#include <GuiListView.au3>
While 1
Local $ShortcutName = "Tera Term"
_SetShortcutPos($ShortcutName, 100, 40)
$ShortcutName = "Help Desk"
_SetShortcutPos($ShortcutName, 200, 40)
$ShortcutName = "Visual Studio 2022"
_SetShortcutPos($ShortcutName, 300, 40)
$ShortcutName = "Plex"
_SetShortcutPos($ShortcutName, 400, 40)
Sleep(10)
WEnd
Func _SetShortcutPos($Name = "", $X = 0, $Y = 0)
Local $Desktop = ControlGetHandle("[CLASS:Progman]", "", "[CLASS:SysListView32;INSTANCE:1]")
Local $Pos = _GUICtrlListView_FindInText($Desktop, $Name)
_GUICtrlListView_SetItemPosition($Desktop, $Pos, $X, $Y)
EndFunc
If you use the code above with your icon names the first time that you build/run the program, ensure that your computer only has one monitor plugged in. Run the program, shutdown WHILE its running, and then turn the computer back on with BOTH monitors plugged in.
Don't ask me why that works, but I only had to do it once, and i've gone through 10 different PC restart cycles with different combinations of monitors plugged in/not plugged in, code running/not running during shutdown, and i'm yet to break it again.
I will update this answer if I run into any issues.
Here is a copy/paste of the final code.
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\Downloads\Logo-for-Redacted-in-RGB.ico
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GuiListView.au3>
; Create an array of all shortcut names and their respective positions
Local $aShortcuts[33][3] = [["Tera Term", 30, 29], ["DESI Labeling System", 30, 105], ["Visual Studio 2022", 30, 192], _
["My Mail Spam Filter", 30, 278], ["Spiceworks", 30, 364], ["Adobe Reader XI", 30, 449], _
["FreezeIcons", 30, 535], ["temp", 30, 621], ["Microsoft Edge", 30, 707], ["Access", 30, 793], _
["Outlook", 30, 879], ["PERSONAL (E)", 116, 29], ["redacted", 116, 105], ["Graphics Portal", 116, 191], _
["OBS Studio", 116, 277], ["Plex", 116, 364], ["Google Chrome", 116, 449], ["DesktopOK", 116, 535], _
["Samsung Magician", 116, 621], ["Device Inventory", 116, 707], ["Word", 116, 793], _
["Excel", 116, 879], ["Help Desk", 202, 29], ["redacted", 202, 105], ["Zoho Assist", 202, 191], _
["redacted", 202, 277], ["static ip addresses", 202, 364], ["Device Listing", 202, 449], _
["Out of Office Calendar", 202, 535], ["redacted", 202, 621], ["Person 2 - Chrome", 202, 707], _
["Recycle Bin", 202, 793], ["redacted", 202, 879]]
While 1
For $i = 0 To UBound($aShortcuts) - 1
_SetShortcutPos($aShortcuts[$i][0], $aShortcuts[$i][1], $aShortcuts[$i][2])
Next
Sleep(1000)
WEnd
Func _SetShortcutPos($Name = "", $X = 0, $Y = 0)
Local $Desktop = ControlGetHandle("[CLASS:Progman]", "", "[CLASS:SysListView32;INSTANCE:1]")
Local $Pos = _GUICtrlListView_FindInText($Desktop, $Name)
_GUICtrlListView_SetItemPosition($Desktop, $Pos, $X, $Y)
EndFunc