Set the Position of Desktop Shortcuts

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Set the Position of Desktop Shortcuts

Post by Marcus Tettmar » Thu Jan 19, 2006 11:41 am

This script demonstrates how to reposition a desktop shortcut and accompanies the following article:
http://www.mjtnet.com/blog/2006/01/19/s ... positions/


//Functions needed for working with windows messages
VBSTART
Function LoWord(wInt)
LoWord = wInt AND &HFFFF&
End Function

Function HiWord(wInt)
HiWord = wInt \ &H10000 AND &HFFFF&
End Function

Function MAKELPARAM(wLow, wHigh)
MAKELPARAM = LoWord(wLow) Or (&H10000 * LoWord(wHigh))
End Function
VBEND

//Refresh icon view
SetFocus>Program Manager
Press F5

//Get index of RealPlayer shortcut on desktop
GetListItem>Program Manager,SysListView32,0,RealPlayer,0,0,0,Result,Handle

//Set position of icon.
//If Align to Grid is on this will slot icon in where it fits best.
//If Align to Grid is off it will place icon at this absolute position.
Let>xpos=100
Let>ypos=500
VBEval>MAKELPARAM(%xpos%,%ypos%),lparam

//Reposition
Let>LVI_SETITEMPOSITION=4111
LibFunc>user32,SendMessageA,r,Handle,LVI_SETITEMPOSITION,Result,lparam

SRT>ToggleAlignToGrid
//Code to toggle Align to Grid
SetFocus>Program Manager
Press MenuKey
Send>il
END>ToggleAlignToGrid
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts