IE (URL Shortcut) |
This section describes the "IE" mode of the "ShortcutUrl" command.
IE automation is used to invoke the URL. You can set the titlebar title and bring existing windows into focus etc. You can control window sizes and menus but of course this is an Internet Explorer only solution which will not work if IE is unavailable.
This mode of the "ShortcutUrl" command takes these parameters:
See the "ShortcutUrl" command for more information on this parameter.
Windows installer required an "8.3" name, if you wish to supply a specific value then preceed the title with the 8.3 name followed by a "|", if this is not done then MAKEMSI will try to create one for you. If MAKEMSI creates the 8.3 name it may generate the same name for more than one long filename so if in doubt it is best to supply it.
This value is also used to build the name of an environment variable which can be test for testing purposes and overrides the value supplied by the "URL" parameter if it exists. The name of the environment variable is ""SCURL_" followed by the title.
The default for this parameter can be set via the DEFAULT_SHORTCUT_DIR macro. The default value is "[ProgramMenuFolder]". You can supply any number of directories seperated by ";" where each directory will create a shortcut in that location.
There are some standard folder keys which you can use, see Microsoft's MSI "System Folder Properties" for more information.
You can use "{NL}" as a new line character.
If you supply a blank value for this parameter then a non-advertised shortcut is created instead.
The default for this parameter can be set via the DEFAULT_SHORTCUTURL_IE_FEATURE macro. This is initially "." (to advertise current feature).
If the "Icon" parameter was passed then the default is "0", else it is "".
"C" Headers will have a definition for "VK_F12" for the F12 key etc. I could not find the modifiers documented but a bit of experimentation showed that this is a bit mask with at least the following bits:
See below for an easy way of letting windows tell you what the correct value for any required key combination is. The value can be supplied as a decimal or hexadecimal value (for example "&H017B" where 01=Shift and 7B=F12 for Shift+F12).
The default for this parameter can be set via the DEFAULT_SHORTCUTURL_IE_INSTALLDIR macro. If this value is "" then this parameter is mandatory!
CONFIGURATION - OPTIONS |
The following are the generic options available:
#define? DEFAULT_SHORTCUTURL_HOW BASIC ;;Default mechanism used to create URL Shortcuts #define? DEFAULT_ADD_GENERATED_RESOURCES_TO_DOCO N
The following are the options available for the "IE mode":
#define? DEFAULT_SHORTCUTURL_IE_INSTALLDIR ;;BLANK=parameter required, else default DIR KEY #define? SHORTCUTURL_IE_VBSCRIPT_INITIALIZATION_CODE ;;Hook for defining variables etc... #define? SHORTCUTURL_IE_VBSCRIPT_SUPPORTING_FUNCTIONS_AND_SUBROUTINES ;;Hook for adding your own functions (which your inserted code will use) #define? SHORTCUTURL_IE_REUSE_EXISTING_WINDOW_IF_POSSIBLE Y ;;Look for and use any already open URL? #define? SHORTCUTURL_IE_RESIZING_CRITICAL N ;;Should we abort if we can't correctly size the window (IE7 security etc)? #define? DEFAULT_SHORTCUTURL_IE_FEATURE . ;;Blank means non-advertised shortcut or feature name or "." or "\" #define? SHORTCUTURL_IE_KEYPATH_TYPE_FOR_COMPONENTS CU=Y ;;Current User Keypath by default (for non advertised IE shortcuts) #( '<?NewLine>' #define? SHORTCUTURL_LOGLINE_INITIALIZATION '--- First time in? ------------------------------------------------- if ScLogFile <> "" then '--- We have already initialized everything :-) --------------------- How = LogAppend else '--- Need to initialize things :-) ------------------------------ How = LogCreate '--- Determine the filename (use "CreateDirectoryTree()" to create directories) --- LogsDir = GetEnvDieOpt("TEMP", false) ScLogFile = LogsDir & "\ShortcutUrl_4_" & WantedTitle & ".log.txt" end if #) #( '<?NewLine>' #define? SHORTCUTURL_IE_VBSCRIPT_DIE_DISPLAY_MESSAGE ;--- Some available Variables ------------------------------------------- ; Text - The message passed to Die() Text = "Sorry but we couldn't launch the browser." & vbCRLF & vbCRLF & Text LogLine "MSGBOX - SHORTCUTURL_IE_VBSCRIPT_DIE_DISPLAY_MESSAGE" LogLine "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" LogLine Text MsgBox Text, vbCritical+vbSystemModal, "<$ProdInfo.ProductName> ERROR" #) #( '<?NewLine>' #define? SHORTCUTURL_IE_HOOK_OBJECT_UPDATE ;;Code to do any unsupported object manipulations ;--- Some available Variables ------------------------------------------- ; oIE - IE automation object ; Die() - Subroutine to display error message (only parameter) and abort #) #( '<?NewLine>' #define? SHORTCUTURL_IE_HOOK_UPDATE_URL_JUST_BEFORE_LAUNCH_NEW_IE_SESSION ;;Intended to allow you to add parameters to the URL etc. ;--- Some available Variables ------------------------------------------- ; URL - Contains the URL we are about to launch (you can add parameters etc) ; Die() - Subroutine to display error message (only parameter) and abort #) #( '<?NewLine>' #define? SHORTCUTURL_IE_UPDATE_TITLE_VB_STATEMENTS ;;How should the Window Title be set (if at all) ;--- Some available Variables ------------------------------------------- ; oWindow - Window Object of the IE session containing the launched window ; Die() - Subroutine to display error message (only parameter) and abort <?NewLine> '--- The old DEFAULT was very simple, just set it (from "IeTitleBar" parameter) ----- 'oWindow.document.title = WantedTitle <?NewLine> ;--- Some pages will try to change the title back.... ------------------- LogLine "" LogLine "" LogLine "ImproveIeTitleBarTitle(""" & WantedTitle & """)" LogInc() if WantedTitle = "" then ;--- Dont Want the title changed -------------------------------- LogLine "We have not been asked to change the title after all..." else '--- Default very simple, just set it (from "IeTitleBar" parameter) --- dim NagCnt for NagCnt = 1 to 20 ;--- Sleep for 500ms -------------------------------------------- wscript.Sleep 500 dim CurrentTitle : CurrentTitle = "?unknown?" : CurrentTitle = oWindow.document.title err.clear() LogLine "#" & NagCnt & ", CURRENT TITLE: " & CurrentTitle ;--- Is the title already correct? -------------------------- if CurrentTitle <> WantedTitle then ;--- Current title is not what we want ------------------ LogInc() ;--- Try to change the title ------------------------- err.clear() oWindow.document.title = WantedTitle if err.number = 0 then LogLine "Successfully changed the title..." else ;--- Failed to set the title, show reason ------- dim ErrNumber : ErrNumber = err.number LogLine "Failed setting the new title! Reason: 0x" & hex(ErrNumber) & " - " & err.description ;--- Did the above fail due to the issue we have a workaround for? --- FixMicrosoftsIeIntegrityIssueIfRequired ErrNumber, oWindow end if LogDec() end if next end if LogLine "ImproveIeTitleBarTitle() - FINISHED" LogDec() #) #( '<?NewLine>' ;--- Actual code included into the function ----------------------------- #define? DEFAULT_SHORTCUTURL_IECOMPARE ;--- Some available Variables ------------------------------------------- ; oWindow - Window Object of an IE session we are looking at ; AlreadyStarted - Return code - You must set to true or false ; LaunchUrl - Copy of the URL being launched (you can modify if you wish - won't change whats launched) ; Die() - Subroutine to display error message (only parameter) and abort ;--- By default window matches if window URL begins with wanted URL (less any page info) ---- <$SHORTCUTURL_IE_WINDOW_COMPARE_VBSCRIPT-WINDOW_URL_STARTS_WITH_WANTED_URL_LOCATION> #) ;---------------------------------------------------------------------------- ;--- Two different "sample" types of IE Window comparison mechanisms -------- ;---------------------------------------------------------------------------- #( '<?NewLine>' ;--- Simple compare, the windows URL begins with the launch URL (minus any page info) --------- #define? SHORTCUTURL_IE_WINDOW_COMPARE_VBSCRIPT-WINDOW_URL_STARTS_WITH_WANTED_URL_LOCATION ;--- Log What we are doing ---------------------------------------------- LogLine "SHORTCUTURL_IE_WINDOW_COMPARE_VBSCRIPT-WINDOW_URL_STARTS_WITH_WANTED_URL_LOCATION, Window's URL is: " & oWindow.LocationURL LogInc() ;--- If a page attached to URL then remove it --------------------------- if right(LaunchUrl, 1) <> "/" then ;--- The Launch URL contains page information (directories end with "/") --- dim Pos : Pos = InStrRev(LaunchUrl, "/") if Pos <> 0 then ;--- Make sure we haven't found "protocol://" ------------------- if mid(LaunchUrl, Pos-1, 1) <> "/" then ;--- No unexplained error, so shorten URL to bit we care about --- LaunchUrl = left(LaunchUrl, Pos) end if end if end if LogLine " Matching against the launch URL: " & LaunchUrl dim MatchLength : MatchLength = len(ucase(LaunchUrl)) AlreadyStarted = ucase(left(oWindow.LocationURL, MatchLength)) = ucase(LaunchUrl) LogDec() #) #( '<?NewLine>' ;--- Simple compare, the windows URL begins with the launch URL --------- #define? SHORTCUTURL_IE_WINDOW_COMPARE_VBSCRIPT-WINDOW_URL_STARTS_WITH_WANTED_URL ;--- Log What we are doing ---------------------------------------------- LogLine "SHORTCUTURL_IE_WINDOW_COMPARE_VBSCRIPT-WINDOW_URL_STARTS_WITH_WANTED_URL, Window's URL is: " & oWindow.LocationURL dim MatchLength : MatchLength = len(ucase(LaunchUrl)) AlreadyStarted = ucase(left(oWindow.LocationURL, MatchLength)) = ucase(LaunchUrl) #)
An Easy Way to Determine a HotKey's Value |
Windows allows you to set a hotkey for any shortcut by right clicking on one and opening its properties. Now a IE shortcut (URL) is a text file in the form of an INI file which means that this information is stored in a text format which can be viewed with any text editor!
So to work out the hotkey create an IE shortcut, right click and select properties, now enter the shortcut, press "apply". Open a command prompt and either type the shortcut file or load in a text editor (the file will have a ".URL" file extension), the following shows the shortcut, its properties windows as well as the shortcut opened in notepad:
Implementation Details |
The following information may help you if you are trying to alter the defaults (as it will help you find object documentation etc):
EXAMPLE |
#( <$ShortcutUrl HOW="IE" Title="Google (via IE automation)" Description="A tooltip for this shortcut..." Url="http://www.google.com/" IconFile="Google.ico" Dir="DesktopFolder" InstallDir="INSTALLDIR" > #)