static private JumpListLink ParseApplyJumpListTask(Primary parent, T7EJumplistItem jumplistItem, int itemIndex) { JumpListLink task = new JumpListLink { Title = jumplistItem.ItemName }; if (jumplistItem.ItemIconToString().Equals("Don't use an icon") != true) { // Icon processing string localIconPath = IconPathToLocal(jumplistItem.ItemIconPath, jumplistItem.ItemIconIndex, itemIndex, parent.CurrentAppId, false); if (File.Exists(localIconPath)) { task.IconReference = new IconReference(localIconPath, 0); } } switch (jumplistItem.TaskAction) { case T7EJumplistItem.ActionType.Keyboard: string kbdScriptName = GetKeyboardScriptFilename(parent, jumplistItem, itemIndex); if (File.Exists(kbdScriptName)) { // It should already have been made task.Path = Common.Path_ProgramFiles + "\\AutoHotKey.exe"; task.Arguments = "\"" + kbdScriptName + "\""; } else { return(null); } break; case T7EJumplistItem.ActionType.CommandLine: if (jumplistItem.TaskCMDShowWindow) { task.Path = "cmd.exe"; task.Arguments = "/k \"" + jumplistItem.ItemCmdToString().Replace("\"", "\"\"") + "\""; // I'm not sure if this is right, but for any executable, set workingdir to the exe path. task.WorkingDirectory = Path.GetDirectoryName(jumplistItem.TaskCMDPath); } else { task.Path = jumplistItem.TaskCMDPath; task.Arguments = jumplistItem.TaskCMDArgs; task.WorkingDirectory = Path.GetDirectoryName(jumplistItem.TaskCMDPath); } break; case T7EJumplistItem.ActionType.AutoHotKey: string ahkFilename = GetAhkScriptFilename(false, jumplistItem, itemIndex); if (File.Exists(ahkFilename)) // It should have already been made. { // Working directory info for autohotkey? Probably not, // since some scripts will use the predefined scripts in appdata. task.Path = Common.Path_ProgramFiles + "\\AutoHotKey.exe"; task.Arguments = "\"" + ahkFilename + "\""; } else { return(null); } break; } return(task); }
static private void ParseWriteJumpListTask(ref XmlTextWriter xmlWriter, bool isPack, T7EJumplistItem jumplistItem, int itemIndex) { xmlWriter.WriteStartElement("task"); xmlWriter.WriteAttributeString("name", jumplistItem.ItemName); if (jumplistItem.ItemIconToString().Equals("Don't use an icon") != true) { // Icon processing string localIconPath = IconPathToLocal(jumplistItem.ItemIconPath, jumplistItem.ItemIconIndex, itemIndex, PrimaryParent.CurrentAppId, isPack); if (SaveLocalIcon(localIconPath, jumplistItem.ItemIconBitmap)) { if (isPack) { if (jumplistItem.ItemIconToString().Equals("Use program icon")) { xmlWriter.WriteElementString("icon", "Use program icon"); } else { xmlWriter.WriteElementString("icon", Path.GetFileName(localIconPath)); } } else { xmlWriter.WriteElementString("icon", jumplistItem.ItemIconToString()); } } } xmlWriter.WriteStartElement("action"); switch (jumplistItem.TaskAction) { case T7EJumplistItem.ActionType.Keyboard: // Include AHK processing HERE in xml stage, or in jumplist stage? // Include here. if (!isPack) { // We only need this if we're not writing a pack. string kbdFilename = GetKeyboardScriptFilename(PrimaryParent, jumplistItem, itemIndex); FormKeyboardScript(PrimaryParent, jumplistItem, kbdFilename); } xmlWriter.WriteAttributeString("type", "T7E_TYPE_KBD"); xmlWriter.WriteAttributeString("ignoreAbsent", jumplistItem.TaskKBDIgnoreAbsent.ToString()); xmlWriter.WriteAttributeString("ignoreCurrent", jumplistItem.TaskKBDIgnoreCurrent.ToString()); xmlWriter.WriteAttributeString("sendBackground", jumplistItem.TaskKBDSendInBackground.ToString()); xmlWriter.WriteAttributeString("minimizeAfterward", jumplistItem.TaskKBDMinimizeAfterward.ToString()); xmlWriter.WriteAttributeString("newWindow", jumplistItem.TaskKBDNew.ToString()); xmlWriter.WriteAttributeString("isShortcut", jumplistItem.TaskKBDShortcutMode.ToString()); xmlWriter.WriteCData(jumplistItem.TaskKBDString); break; case T7EJumplistItem.ActionType.CommandLine: xmlWriter.WriteAttributeString("type", "T7E_TYPE_CMD"); xmlWriter.WriteAttributeString("showWindow", jumplistItem.TaskCMDShowWindow.ToString()); if (isPack) { xmlWriter.WriteValue(ReplacePathsToVars(jumplistItem.ItemCmdToString())); } else { xmlWriter.WriteValue(jumplistItem.ItemCmdToString()); } break; case T7EJumplistItem.ActionType.AutoHotKey: // Include processing here. string ahkFilename = GetAhkScriptFilename(isPack, jumplistItem, itemIndex); FormAhkScript(isPack, jumplistItem, ahkFilename); xmlWriter.WriteAttributeString("type", "T7E_TYPE_AHK"); xmlWriter.WriteValue(Path.GetFileName(ahkFilename)); break; } xmlWriter.WriteEndElement(); xmlWriter.WriteEndElement(); }