Revision: 1404
Updated Code
at October 3, 2006 08:21 by kray
Updated Code
Sub SetDockIconVisibility(TheApp as FolderItem, Visibility as Boolean) dim rf as resourceFork dim s as String dim HideIconString as String = "<key>NSUIElement</key>" + chr(13) + _ "<string>1</string>" + chr(13) dim iInsertBefore as Integer if TheApp = nil or (not TheApp.exists) or TheApp.MacType <> "APPL" then MsgBox "Application Error." + EndOfLine + EndofLine + _ "Sorry, there was an error accessing the application." return end if rf = TheApp.OpenResourceFork if rf <> nil then s = rf.GetResource("plst", 0) else MsgBox "Error opening resource." + EndOfLine + EndofLine + _ "The application may be running." rf.Close return end if if InStr(s, HideIconString) <> 0 and Visibility = true then s = ReplaceAll(s, HideIconString, "") // get rid of the line that hides the dock icon rf.AddResource(s, "plst", 0, "") elseif InStr(s, HideIconString) = 0 and Visibility = false then iInsertBefore = InStr(s, "</dict>" + chr(13) + "</plist>") If iInsertBefore = 0 then rf.Close MsgBox "Unexpected Error." + EndOfLine + EndofLine + _ "Couldn't locate the end of the dictionary and the property list." return end if s = left(s, iInsertBefore - 1) + HideIconString + mid(s, iInsertBefore) rf.AddResource(s, "plst", 0, "") end if rf.Close rf = TheApp.OpenResourceFork // see if we really wrote to it by closing and reopening it if rf <> nil then if rf.GetResource("plst", 0) <> s then MsgBox "Error saving resource." + EndOfLine + EndofLine + _ "The application may be running." rf.Close return end if end if rf.close End Sub
Revision: 1403
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 3, 2006 08:20 by kray
Initial Code
Sub SetDockIconVisibility(TheApp as FolderItem, Visibility as Boolean) dim rf as resourceFork dim s as String dim HideIconString as String = "<key>NSUIElement</key>" + chr(13) + _ "<string>1</string>" + chr(13) dim iInsertBefore as Integer if TheApp = nil or (not TheApp.exists) or TheApp.MacType <> "APPL" then MsgBox "Application Error." + EndOfLine + EndofLine + _ "Sorry, there was an error accessing the application." return end if rf = TheApp.OpenResourceFork if rf <> nil then s = rf.GetResource("plst", 0) else MsgBox "Error opening resource." + EndOfLine + EndofLine + _ "The application may be running." rf.Close return end if if InStr(s, HideIconString) <> 0 and Visibility = true then s = ReplaceAll(s, HideIconString, "") // get rid of the line that hides the dock icon rf.AddResource(s, "plst", 0, "") elseif InStr(s, HideIconString) = 0 and Visibility = false then iInsertBefore = InStr(s, "</dict>" + chr(13) + "</plist>") If iInsertBefore = 0 then rf.Close MsgBox "Unexpected Error." + EndOfLine + EndofLine + _ "Couldn't locate the end of the dictionary and the property list." return end if s = left(s, iInsertBefore - 1) + HideIconString + mid(s, iInsertBefore) rf.AddResource(s, "plst", 0, "") end if rf.Close rf = TheApp.OpenResourceFork // see if we really wrote to it by closing and reopening it if rf <> nil then if rf.GetResource("plst", 0) <> s then MsgBox "Error saving resource." + EndOfLine + EndofLine + _ "The application may be running." rf.Close return end if end if rf.close End Sub
Initial URL
Initial Description
Shows how to hide an icon in the Dock by manipulating the app's pList.
Initial Title
SetDockIconVisibility (RB)
Initial Tags
Initial Language
Other