Macro Scheduler & Editor Shortcuts in Win 7 Right Click

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

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

Post Reply
User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Macro Scheduler & Editor Shortcuts in Win 7 Right Click

Post by Rain » Sat Apr 09, 2011 6:19 pm

Submitted by: Rain

Macro Scheduler Version: 12

Description: This example demonstrates how to use the registry read and delete key functions to add Macro Scheduler & Editor Shortcuts to Windows 7 Desktop Right Click Context Menu.

Browse to the directory where msched.exe is located and click "Apply" to add the shortcuts.

Image

Code: Select all

//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1

//Windows 7 required

Dialog>Dialog1
object Dialog1: TForm
  Left = 461
  Top = 104
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'Add MS Shortcuts to Desktop Context Menu (Windows 7)'
  ClientHeight = 115
  ClientWidth = 396
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object MSButton1: tMSButton
    Left = 288
    Top = 8
    Width = 57
    Height = 21
    Caption = 'Browse'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 0
    DoBrowse = False
    Filename = 'C:\Program Files'
    InitialDir = 'C:\Program Files'
    BrowseStyle = fbFolder
  end
  object Edit1: TEdit
    Left = 40
    Top = 8
    Width = 241
    Height = 21
    HelpType = htKeyword
    Enabled = False
    TabOrder = 1
  end
  object MSRadioGroup1: tMSRadioGroup
    Left = 40
    Top = 32
    Width = 113
    Height = 73
    Caption = 'Menu Position'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = [fsBold]
    ItemIndex = 0
    Items.Strings = (
      'Top'
      'Center'
      'Bottom')
    ParentFont = False
    TabOrder = 2
    Text = 'Top'#13#10'Center'#13#10'Bottom'#13#10
  end
  object MSButton2: tMSButton
    Left = 176
    Top = 32
    Width = 75
    Height = 73
    Caption = 'Apply'
    DoubleBuffered = True
    Enabled = False
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = [fsBold]
    ParentDoubleBuffered = False
    ParentFont = False
    TabOrder = 3
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton3: tMSButton
    Left = 272
    Top = 32
    Width = 75
    Height = 73
    Caption = 'Undo'
    DoubleBuffered = True
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = [fsBold]
    ParentDoubleBuffered = False
    ParentFont = False
    TabOrder = 4
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1



//Set Event Handlers for the button's OnClick events
AddDialogHandler>Dialog1,MSButton1,OnClick,DoBrowse
AddDialogHandler>Dialog1,MSButton2,OnClick,Apply
AddDialogHandler>Dialog1,MSButton3,OnClick,Undo



Show>Dialog1,r
 
//Here we perform the file browse, then get the filename and output it to an edit box
SRT>DoBrowse
SetDialogProperty>Dialog1,MSButton1,DoBrowse,True
GetDialogProperty>Dialog1,MSButton1,Filename,Msched_Dir
SetDialogProperty>Dialog1,Edit1,Text,Msched_Dir

IfFileExists>%Msched_Dir%\msched.exe
SetDialogProperty>Dialog1,MSButton2,Enabled,True
Endif
END>DoBrowse


//Here we add the Context menu
SRT>Apply
//First Delete existing Registry Entries
RegistryDelKey>HKEY_CLASSES_ROOT,Directory\Background\Shell\MschedShortcuts
RegistryDelKey>HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\mschedexe
RegistryDelKey>HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\mschededit

//Here we get the selected position of the context
GetDialogProperty>Dialog1,MSRadioGroup1,SelectedItem,PositionInMenu

//Here we write the Context Menu to the Registry
RegistryWriteKey>HKEY_CLASSES_ROOT,Directory\Background\Shell\MschedShortcuts,MUIVerb,Macro Scheduler
RegistryWriteKey>HKEY_CLASSES_ROOT,Directory\Background\Shell\MschedShortcuts,Icon,%Msched_Dir%\msched.exe
RegistryWriteKey>HKEY_CLASSES_ROOT,Directory\Background\Shell\MschedShortcuts,Position,%PositionInMenu%
RegistryWriteKey>HKEY_CLASSES_ROOT,Directory\Background\Shell\MschedShortcuts,SubCommands,mschedexe;mschededit

//Here we write the cascading/submenu for msched.exe to the registry
//This will run the macro scheduler main program when clicked
RegistryWriteKey>HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\mschedexe,,Macro Scheduler
RegistryWriteKey>HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\mschedexe,Icon,%Msched_Dir%\msched.exe
RegistryWriteKey>HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\mschedexe\command,,%Msched_Dir%\msched.exe

//Here we write the cascading/submenu for the script editor to the registry
//This will run the script editor when clicked
RegistryWriteKey>HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\mschededit,,Script Editor
RegistryWriteKey>HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\mschededit,Icon,%Msched_Dir%\edt_new.ico
RegistryWriteKey>HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\mschededit\command,,%Msched_Dir%\msched.exe -EDITOR
END>Apply



SRT>Undo
//Delete Registry Entry and remove context menu
RegistryDelKey>HKEY_CLASSES_ROOT,Directory\Background\Shell\MschedShortcuts
RegistryDelKey>HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\mschedexe
RegistryDelKey>HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\mschededit
END>Undo



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