heken Posted December 1, 2008 Posted December 1, 2008 How could my au3 script change the displayed icon for a shortcut? I do NOT mean to modify the compiled file (.exe), no.Actually, I have a very simple autoit script that mutes/sounds the master volume. The .au3 file is located on My documents, but I've created a shortcut on the Quick Launch toolbar. Once there, I've set up the icon manually to let it look like a speaker.Now, what I desire is to swap the icon from "sound speaker" to "mute speaker" depending on the current master volume status (i.e. every time I click on the shortcut).To accomplish this, I need to tweak somehow the "shortcut file". Any clue? Thanks.
KaFu Posted December 1, 2008 Posted December 1, 2008 Not exactally what you're looking for, but why go the hard way ? Instead of indicating the state in the Quicklaunch Bar indicate it in the system-tray, easy to implement #Include <Constants.au3> #NoTrayIcon Opt("TrayMenuMode",1) ; Default tray menu items (Script Paused/Exit) will not be shown. $exititem = TrayCreateItem("Exit") TraySetState() $start = 0 While 1 $msg = TrayGetMsg() If $msg = $exititem Then ExitLoop $diff = TimerDiff($start) If $diff > 1000 Then $num = -Random(0,100,1) ; negative to use ordinal numbering ToolTip("#icon=" & $num) TraySetIcon("Shell32.dll",$num) $start = TimerInit() EndIF WEnd Exit OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
heken Posted December 1, 2008 Author Posted December 1, 2008 Solved!Not very elegant, but it works.Const $shortcut = "whatever the location to my shortcut is" Const $soundSpeaker = 2 Const $muteSpeaker = 3 Dim $actualIcon ; mutes/sounds the master volume Send("{VOLUME_MUTE}") ; gets the shortcut properties $details = FileGetShortcut($shortcut) ; swaps the icon If $details[5] = $soundSpeaker Then $actualIcon = $muteSpeaker Else $actualIcon = $soundSpeaker EndIf ; replace the current shortcut with the proper icon FileCreateShortcut($details[0], $shortcut, $details[1], $details[2], $details[3], $details[4], "", $actualIcon, $details[6])
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now