Software for storing, selecting, and sending keystrokes to applications

Hi
Is there a software that will let you store, then select keystroke combinations from a menu and send the to the active window?

The problem I am trying to solve is this: I can't remember all of my shortcut combinations and so I would like to install a software that allows me to store them, select them and send them to applications like: Word, Internet Explorer etc.

Now a programmable keypad might be the solution, but I would prefer not to, my desk is already messy. But, if anyone knows of a really good one that could be interesting too. Is there one with bluetooth?

Thanks
mrandersAsked:
Who is Participating?
 
RobSampsonConnect With a Mentor Commented:
Hi, here's something I've started working on, which is actually more difficult than I thought, in terms of getting the keystrokes to work correctly with some applications, but maybe I'll keep working it.
I also have no function to add custom keystrokes other than manually editing the config.keystrokes file.

Here is the HTA (paste into a text file called Keystrokes.hta):
'===============
<head>
<title>HotKey_Storing_And_Activating_Program</title>
<HTA:APPLICATION
     APPLICATIONNAME="HotKey_Storing_And_Activating_Program"
     BORDER="thin"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
>
</head>

<script language="VBScript">

' This array will be structured in Columns, not Rows, because VBScript does
' not support resizing an Array by the first dimension, so to add data, we
' increase the amount of columns, and the Hotkeys will read downwards
ReDim arrHotKeys(2, 0) ' global variable to store the hotkeys, with three rows and one column

Sub Window_onLoad
      intWidth = 800
      intHeight = 600
      Me.ResizeTo intWidth, intHeight
    Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
    lst_activeprograms.Style.Width = 700
    lst_hotkeys.Style.Width = 700
    arrHotKeys(0, 0) = "NULL"
    Call GetHotKeysFromFile
    Call GetActivePrograms
    Call ShowHotKeys
End Sub

Sub GetHotKeysFromFile
      Const intForReading = 1
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      If objFSO.FileExists("config.hotkeys") = True Then
            Set objConfig = objFSO.OpenTextFile("config.hotkeys", intForReading, False)
            While Not objConfig.AtEndOfStream
                  strHotKey = objConfig.ReadLine
                  If InStr(strHotKey, "|-->|") > 0 Then
                        If arrHotKeys(0, 0) <> "NULL" Then ReDim Preserve arrHotKeys(UBound(arrHotKeys), UBound(arrHotKeys, 2) + 1)
                        If Split(strHotKey, "|-->|")(0) = "" Then
                              arrHotKeys(0, UBound(arrHotKeys, 2)) = "Unspecified"
                        Else
                              arrHotKeys(0, UBound(arrHotKeys, 2)) = Split(strHotKey, "|-->|")(0)
                        End If
                        arrHotKeys(1, UBound(arrHotKeys, 2)) = Split(strHotKey, "|-->|")(1)
                        arrHotKeys(2, UBound(arrHotKeys, 2)) = Split(strHotKey, "|-->|")(2)
                  End If
            Wend
            objConfig.Close
            Set objConfig = Nothing
            Set objFSO = Nothing
      Else
            MsgBox "The config file ""config.hotkeys"" could not be found. Exiting application."
            window.close
      End If
End Sub

Sub GetActivePrograms
      ' Source: http://www.microsoft.com/technet/scriptcenter/topics/office/tasks.mspx
      ' Tasks Collection: http://msdn2.microsoft.com/en-us/library/aa212447(office.11).aspx
      Set objWord = CreateObject("Word.Application")
      objWord.Visible = False
      Set colActiveApps = objWord.Tasks
      For Each objApp In colActiveApps
            boolAppKnown = False
            If objApp.Visible = True Then
              For intCol = LBound(arrHotKeys, 2) To UBound(arrHotKeys, 2)
                    If InStr(LCase(objApp.Name), LCase(arrHotKeys(0, intCol))) > 0 Then
                          strParentAppName = arrHotKeys(0, intCol)
                          boolAppKnown = True
                    End If
              Next
                  If boolAppKnown = False Then strParentAppName = ""
              strOption = strParentAppName & " |-->| " & objApp.Name
              Set objOption = Document.CreateElement("OPTION")
              objOption.Text = strOption
              objOption.Value = strOption
              lst_activeprograms.Add(objOption)
            End If
      Next
      objWord.Quit
End Sub

Sub ShowHotKeys
      strWhichProgram = Trim(Split(lst_activeprograms.Value, "|-->|")(0))
         For intCount = 1 To lst_hotkeys.Length
               lst_hotkeys.Remove 0
         Next
      If strWhichProgram = "AllPrograms" Then
        For intCol = LBound(arrHotKeys, 2) To UBound(arrHotKeys, 2)
              Set objOption = Document.CreateElement("OPTION")
              objOption.Text = arrHotKeys(1, intCol) & " |-->| " & arrHotKeys(2, intCol)
              objOption.Value = arrHotKeys(1, intCol)
              lst_hotkeys.Add(objOption)
            Next
      ElseIf strWhichProgram = "" Then
        For intCol = LBound(arrHotKeys, 2) To UBound(arrHotKeys, 2)
              If LCase(arrHotKeys(0, intCol)) = LCase("Unspecified") Then
                    Set objOption = Document.CreateElement("OPTION")
                    objOption.Text = arrHotKeys(1, intCol) & " |-->| " & arrHotKeys(2, intCol)
                    objOption.Value = arrHotKeys(1, intCol) & " |-->| " & arrHotKeys(2, intCol)
                    lst_hotkeys.Add(objOption)
                  End If
            Next
      Else
        For intCol = LBound(arrHotKeys, 2) To UBound(arrHotKeys, 2)
              If LCase(arrHotKeys(0, intCol)) = LCase(strWhichProgram) Then
                    Set objOption = Document.CreateElement("OPTION")
                    objOption.Text = arrHotKeys(1, intCol) & " |-->| " & arrHotKeys(2, intCol)
                    objOption.Value = arrHotKeys(1, intCol) & " |-->| " & arrHotKeys(2, intCol)
                    lst_hotkeys.Add(objOption)
                  End If
            Next
      End If
End Sub

Sub SendHotkey
      If lst_activeprograms.Value = "AllPrograms" Or lst_hotkeys.SelectedIndex = -1 Then
            If lst_activeprograms.Value = "AllPrograms" Then
                  MsgBox "Please select a specific application to send the Hotkeys to."
            Else
                  MsgBox "Please select a specific HotKey combination to send to the selected application."
            End If
      Else
            strAppTitle = Trim(Split(lst_activeprograms.value, "|-->|")(1))
            strSendKeysCmd = ParseHotKeys(strAppTitle, Trim(Split(lst_hotkeys.value, "|-->|")(0)))
            MsgBox "Hotkeys will be sent to " & strAppTitle & VbCrLf & VbCrLf & "Commands:" & VbCrLf & strSendKeysCmd
            Execute strSendKeysCmd
      End If
End Sub

Function ParseHotKeys(strApplication, strHotKeys)
      'SendKeys method: http://msdn2.microsoft.com/en-us/library/8c6yea83.aspx
      arrSegments = Split(strHotKeys, ",")
      strCmdString = "Dim objAutoShell" & VbCrLf
      'strCmdString = strCmdString & "Set objAutoShell = CreateObject(""WScript.Shell"")" & VbCrLf
      strCmdString = strCmdString & "Set objAutoShell = CreateObject(""WSHExtend.WinExt"")" & VbCrLf
      'strCmdString = strCmdString & "objAutoShell.AppActivate """ & strApplication & """" & VbCrLf
      strCmdString = strCmdString & "objAutoShell.WSHAppActivate """ & strApplication & """" & VbCrLf
      strCmdString = strCmdString & "objAutoShell.WSHWait 100" & VbCrLf
      For intCount = LBound(arrSegments) To UBound(arrSegments)
            arrSegments(intCount) = "(" & Replace(arrSegments(intCount), "+", "") & ")"
            arrSegments(intCount) = Replace(arrSegments(intCount), "SHIFT", "+")
            arrSegments(intCount) = Replace(arrSegments(intCount), "CTRL", "^")
            arrSegments(intCount) = Replace(arrSegments(intCount), "ALT", "%")
      Next
      For intCount = LBound(arrSegments) To UBound(arrSegments)
            strCmdString = strCmdString & "objAutoShell.WSHSendKeys """ & arrSegments(intCount) & """, True" & VbCrLf
            strCmdString = strCmdString & "objAutoShell.WSHWait 100" & VbCrLf
      Next
      ParseHotKeys = strCmdString
End Function

Sub Default_Buttons
      If Window.Event.KeyCode = 13 Then
            btn_update.Click
      End If
End Sub

</script>

<body STYLE="font:14 pt arial; color:white;filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Buttons'>
      <table width='90%' height = '100%' align='center' border='0'>
            <tr>
                  <td align="center">
                        <br><h2>HotKey Storing And Activating Program</h2>
                  </td>
            </tr>
            <tr>
                  <td align='center'>
                        Currently Active Programs:<br>
                        <select name="lst_activeprograms" size="10" onclick="vbs:ShowHotKeys">
                              <option selected value='AllPrograms'>&nbsp&nbsp&nbsp&nbsp&nbsp-- View Hotkeys for All Programs --</option>
                        </select>
                  </td>
            </tr>
            <tr>
                  <td align='center'>
                        <br>
                        Hotkeys Available:<br>
                        <select name="lst_hotkeys" size="10">
                        </select>
                  </td>
            </tr
            <tr>
                  <td align='center'>
                        <br><br><input type="button" value="Send Hotkey" name="btn_SendHotkey"  onClick="vbs:SendHotkey"><br><br>
                  </td>
            </tr>
      </table>

</body>
'===============

And here is the config.keystrokes file (must be exactly that name), which must be stored in the same folder as the HTA file:

[Program | Hotkey | Description]
PrimalScript Professional|-->|ALT+F|-->|Save the current open file
|-->|ALT+{F4}|-->|Close the application

Note that the fields in it MUST be separated by the five characters:  |-->|  

Regards,

Rob.
0
 
RobSampsonCommented:
If you need to store things, you could try AutoIt:
http://www.autoitscript.com/autoit3/

Sending it to the "active" window doesn't seem like it would work though......how do you want the program to remember these shortcuts?  Wouldn't it be the case that if you "switched" to this program that remembers your shortcuts, then *that* would become the active window?

Maybe what you need is some sort of menu thing, where on one side you have a list of the currently active program windows, and the other side a list of keyboards commands to send to it.  Then, you could select an application, select a keyboard command, and click Send.

Just a few thoughts......please clarify how you envisage this to work.....

Regards,

Rob.
0
 
mrandersAuthor Commented:
Thanks rob.
This is how I would like to Work with the envisioned application:
Let's say I am working in Word and I can't remember my previously assigned keystroke combination for a style that I want to use. I press a global key combination (works in any application), up pops an application window with all my keystroke combinations and I drill down through the menu structure to the right keystroke combination, select it and it is sent to word. AutoIt looks pretty cool.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
RobSampsonCommented:
How would you populate that menu structure in the first place?  Each time you set up one of these custom keystrokes, would you duplicate that in this other program, so that it remembers it?

Rob.
0
 
mrandersAuthor Commented:
Yes that is right, I would copy keystroke combinations from Word, and other applications as long as I could have them accesible in one organized place - I guess one big menu structure.
0
 
SysExpertCommented:
Then all you need is either a text list showing all the keystrokes, or a menu using auto-it showing the list and  allowing you to choose one.

I hope this helps !
0
 
mrandersAuthor Commented:
So both of you are suggesting AutoIt .. what is the learning curve? I dabbled with http://www.autohotkey.com/ for some time and considered it for building my keysender application. Do you two know autohotkey? Which tool do you think would be best in that case? Thanks.
0
 
RobSampsonCommented:
Hi, I haven't actually personally used AutoIt, but one of my colleagues has, but he is on holiday for three weeks at the moment.

The AutoHotKey looks good though, what does it "not" do for you?

Still, I don't think something like this would be too hard to write in a primitive sort of way, just with an HTA, and using AppActivate and SendKeys.....maybe if I have some time.....

Regards,

Rob.
0
 
mrandersAuthor Commented:
Thanks rob, autohotkey might be fine for building an application. I just haven't had much time to get proficient with it.

Best,
Anders
0
 
RobSampsonCommented:
Oh, and this requires that you download and install the WSHExtend control from
http://freenet-homepage.de/gborn/WSHBazaar/WSHExtend.htm

Make sure you get the VERSION 2 file.

and register it.  All you need to do is place the WinExtend.ocx file in your System32 directory, then use RegSvr32 to register it.

Regards,

Rob.
0
 
mrandersAuthor Commented:
Wow! Thanks  a million! I will take look later this evening.
0
 
mrandersAuthor Commented:
Hi Rob, I get this error message when I try to register WinExtend.ocx:

http://cid-4a5bd8b45b10cb2b.skydrive.live.com/self.aspx/Public/error.gif

I am running Windows Vista Business.
(I was able to register it on an XP machine.)

Thanks
Anders
0
 
RobSampsonCommented:
Hmmm, I don't use Vista, but I think that due to it's new security model, it doesn't necessarily run such a command as an Administrator.
Apparently, the fact that a local account you are using is a member of the local administrator group doesn't mean that Vista executes the process with those privileges. You need to explicity tell Vista to run it as an administrator (right click on the process and choose <Run As Administrator>.

So, if you use that process to execute a Command Prompt as Administrator, then type
regsvr32 winextend.ocx.

Hope that helps......but maybe this HTA isn't what you're looking for anyway.....but worth a look....I'll keep working on it if I get some time....

Regards,

Rob.
0
 
mrandersAuthor Commented:
Hi Rob, I tried running it as an administrator and I get the same error message. Anyway I tried your application on my XP machine and I think it is great.
0
 
mrandersAuthor Commented:
I am going to take a closer look at your code also. Thanks I am learning a lot from this.
0
 
RobSampsonCommented:
No, problem.  I will eventually develop this a bit further...my main problem is with the actual format of the SendKeys commands.  I was originally thinking the *easiest* way would be to have the user enter the key strokes exactly as you would in a SendKeys commands, so for example, to send ALT + F, then S, you would actually put %F, S
That way, splitting the string into the various SendKeys command would be easy, rather than trying to take out the plus signs, change the word ALT to a percent sign, etc.

But, for ease of use on the user side of things, I tried to do the latter, which has been a bit trickier.

And obviously, I need to build in the ability to add new shortcuts from the GUI, instead of directly editing the config file.

Regards,

Rob.
0
 
mrandersAuthor Commented:
I am very interested in what you do with his. Thanks Rob.
0
 
RobSampsonCommented:
Hi mranders,
Here's another slight re-work that I got time to do today. I have added two new buttons, one to Remove a hotkey from the list, and another to add one.  It's not the best interface, just an Input Box, but I may be able to make it more graphical later....

'===============
<head>
<title>HotKey_Storing_And_Activating_Program</title>
<HTA:APPLICATION
     APPLICATIONNAME="HotKey_Storing_And_Activating_Program"
     BORDER="thin"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
>
</head>

<script language="VBScript">

' This array will be structured in Columns, not Rows, because VBScript does
' not support resizing an Array by the first dimension, so to add data, we
' increase the amount of columns, and the Hotkeys will read downwards
ReDim arrHotKeys(2, 0) ' global variable to store the hotkeys, with three rows and one column

Sub Window_onLoad
      intWidth = 800
      intHeight = 600
      Me.ResizeTo intWidth, intHeight
    Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
    lst_activeprograms.Style.Width = 700
    lst_hotkeys.Style.Width = 700
      
      Refresh_Application
End Sub

Sub GetHotKeysFromFile
      Const intForReading = 1
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      If objFSO.FileExists("config.hotkeys") = True Then
            Set objConfig = objFSO.OpenTextFile("config.hotkeys", intForReading, False)
            While Not objConfig.AtEndOfStream
                  strHotKey = objConfig.ReadLine
                  If InStr(strHotKey, "|-->|") > 0 Then
                        If arrHotKeys(0, 0) <> "NULL" Then ReDim Preserve arrHotKeys(UBound(arrHotKeys), UBound(arrHotKeys, 2) + 1)
                        If Split(strHotKey, "|-->|")(0) = "" Then
                              arrHotKeys(0, UBound(arrHotKeys, 2)) = "Unspecified"
                        Else
                              arrHotKeys(0, UBound(arrHotKeys, 2)) = Split(strHotKey, "|-->|")(0)
                        End If
                        arrHotKeys(1, UBound(arrHotKeys, 2)) = Split(strHotKey, "|-->|")(1)
                        arrHotKeys(2, UBound(arrHotKeys, 2)) = Split(strHotKey, "|-->|")(2)
                  End If
            Wend
            objConfig.Close
            Set objConfig = Nothing
            Set objFSO = Nothing
      Else
            MsgBox "The config file ""config.hotkeys"" could not be found. Exiting application."
            window.close
      End If
End Sub

Sub GetActivePrograms
      ' Source: http://www.microsoft.com/technet/scriptcenter/topics/office/tasks.mspx
      ' Tasks Collection: http://msdn2.microsoft.com/en-us/library/aa212447(office.11).aspx
      Set objWord = CreateObject("Word.Application")
      objWord.Visible = False
      Set colActiveApps = objWord.Tasks
      For Each objApp In colActiveApps
            boolAppKnown = False
            If objApp.Visible = True Then
              For intCol = LBound(arrHotKeys, 2) To UBound(arrHotKeys, 2)
                    If InStr(LCase(objApp.Name), LCase(arrHotKeys(0, intCol))) > 0 Then
                          strParentAppName = arrHotKeys(0, intCol)
                          boolAppKnown = True
                    End If
              Next
                  If boolAppKnown = False Then strParentAppName = ""
              strOption = strParentAppName & " |-->| " & objApp.Name
              Set objOption = Document.CreateElement("OPTION")
              objOption.Text = strOption
              objOption.Value = strOption
              lst_activeprograms.Add(objOption)
            End If
      Next
      objWord.Quit
End Sub

Sub ShowHotKeys
      If InStr(lst_activeprograms.Value, "|-->|") > 0 Then
            strWhichProgram = Trim(Split(lst_activeprograms.Value, "|-->|")(0))
      Else
            strWhichProgram = lst_activeprograms.Value
      End If
         For intCount = 1 To lst_hotkeys.Length
               lst_hotkeys.Remove 0
         Next
      If strWhichProgram = "AllPrograms" Then
        For intCol = LBound(arrHotKeys, 2) To UBound(arrHotKeys, 2)
              Set objOption = Document.CreateElement("OPTION")
              objOption.Text = arrHotKeys(1, intCol) & " |-->| " & arrHotKeys(2, intCol)
              objOption.Value = arrHotKeys(1, intCol)
              lst_hotkeys.Add(objOption)
            Next
      ElseIf strWhichProgram = "" Then
        For intCol = LBound(arrHotKeys, 2) To UBound(arrHotKeys, 2)
              If LCase(arrHotKeys(0, intCol)) = LCase("Unspecified") Then
                    Set objOption = Document.CreateElement("OPTION")
                    objOption.Text = arrHotKeys(1, intCol) & " |-->| " & arrHotKeys(2, intCol)
                    objOption.Value = arrHotKeys(1, intCol) & " |-->| " & arrHotKeys(2, intCol)
                    lst_hotkeys.Add(objOption)
                  End If
            Next
      Else
        For intCol = LBound(arrHotKeys, 2) To UBound(arrHotKeys, 2)
              If LCase(arrHotKeys(0, intCol)) = LCase(strWhichProgram) Then
                    Set objOption = Document.CreateElement("OPTION")
                    objOption.Text = arrHotKeys(1, intCol) & " |-->| " & arrHotKeys(2, intCol)
                    objOption.Value = arrHotKeys(1, intCol) & " |-->| " & arrHotKeys(2, intCol)
                    lst_hotkeys.Add(objOption)
                  End If
            Next
      End If
End Sub

Sub SendHotkey
      If lst_activeprograms.Value = "AllPrograms" Or lst_hotkeys.SelectedIndex = -1 Then
            If lst_activeprograms.Value = "AllPrograms" Then
                  MsgBox "Please select a specific application to send the Hotkeys to."
            Else
                  MsgBox "Please select a specific HotKey combination to send to the selected application."
            End If
      Else
            strAppTitle = Trim(Split(lst_activeprograms.value, "|-->|")(1))
            strSendKeysCmd = ParseHotKeys(strAppTitle, Trim(Split(lst_hotkeys.value, "|-->|")(0)))
            'MsgBox "Hotkeys will be sent to " & strAppTitle & VbCrLf & VbCrLf & "Commands:" & VbCrLf & strSendKeysCmd
            Execute strSendKeysCmd
      End If
End Sub

Function ParseHotKeys(strApplication, strHotKeys)
      'SendKeys method: http://msdn2.microsoft.com/en-us/library/8c6yea83.aspx
      arrSegments = Split(strHotKeys, ",")
      strCmdString = "Dim objAutoShell" & VbCrLf
      'strCmdString = strCmdString & "Set objAutoShell = CreateObject(""WScript.Shell"")" & VbCrLf
      strCmdString = strCmdString & "Set objAutoShell = CreateObject(""WSHExtend.WinExt"")" & VbCrLf
      'strCmdString = strCmdString & "objAutoShell.AppActivate """ & strApplication & """" & VbCrLf
      strCmdString = strCmdString & "objAutoShell.WSHAppActivate """ & strApplication & """" & VbCrLf
      strCmdString = strCmdString & "objAutoShell.WSHWait 100" & VbCrLf
      For intCount = LBound(arrSegments) To UBound(arrSegments)
            arrSegments(intCount) = "(" & Replace(arrSegments(intCount), "+", "") & ")"
            arrSegments(intCount) = Replace(arrSegments(intCount), "SHIFT", "+")
            arrSegments(intCount) = Replace(arrSegments(intCount), "CTRL", "^")
            arrSegments(intCount) = Replace(arrSegments(intCount), "ALT", "%")
      Next
      For intCount = LBound(arrSegments) To UBound(arrSegments)
            strCmdString = strCmdString & "objAutoShell.WSHSendKeys """ & arrSegments(intCount) & """, True" & VbCrLf
            'strCmdString = strCmdString & "objAutoShell.WSHWait 100" & VbCrLf
      Next
      ParseHotKeys = strCmdString
End Function

Sub Default_Buttons
      If Window.Event.KeyCode = 13 Then
            btn_SendHotKey.Click
      End If
End Sub

Sub AddNewHotkey
      strProgram = InputBox("Please enter the name of the program that the new HotKey relates to, if applicable." & VbCrLf &_
            "If you enter it, type the Program Name exactly as it appears in the Title bar of the program:", "Program Name")
      strHotKeys = InputBox("Please type the HotKeys required for the operation below." & VbCrLf &_
            "For keys pressed together, separate them with a plus sign." & VbCrLf &_
            "For individual keystrokes, separate them with a comma." & VbCrLf &_
            "To represent the Space Bar being pressed, type {SPACE}." & VbCrLf &_
            "For example, to send ALT and F together, then S, type" & VbCrLf &_
            "ALT+F,S", "HotKey Combination")
      strDescription = InputBox("Please enter the description of the task that the new HotKey performs." & VbCrLf &_
            "Program:" & strProgram & VbCrLf & "HotKey combination: " & strHotKeys, "Description")
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      Const intForAppending = 8
      Set objConfigFile = objFSO.OpenTextFile("config.hotkeys", intForAppending, False)
      objConfigFile.Write VbCrLf & strProgram & "|-->|" & strHotKeys & "|-->|" & strDescription
      objConfigFile.Close
      Set objConfigFile = Nothing
      Set objFSO = Nothing
      
      Refresh_Application
End Sub

Sub Refresh_Application
      ReDim arrHotKeys(2, 0)
      arrHotKeys(0, 0) = "NULL"
    Call GetHotKeysFromFile
    Call GetActivePrograms
    Call ShowHotKeys
End Sub

Sub RemoveHotKey
      If lst_hotkeys.SelectedIndex = -1 Then
            MsgBox "Please select a specific HotKey combination to remove."
      Else
            strSelectedHotKey = Replace(lst_hotkeys.Value, " |-->| ", "|-->|")
            Set objFSO = CreateObject("Scripting.FileSystemObject")
            Const intForReading = 1
            Set objConfigFile = objFSO.OpenTextFile("config.hotkeys", intForReading, False)
            strContents = objConfigFile.ReadAll
            objConfigFile.Close
            Set objConfigFile = Nothing
            strNewContents = ""
            For Each strLine In Split(strContents, VbCrLf)
                  If Not InStr(strLine, strSelectedHotKey) > 0 Then
                        If strNewContents = "" Then
                              strNewContents = strLine
                        Else
                              strNewContents = strNewContents & VbCrLf & strLine
                        End If
                  End If
            Next
            Set objConfigFile = objFSO.CreateTextFile("config.hotkeys", True)
            objConfigFile.Write strNewContents
            objConfigFile.Close
            Set objConfigFile = Nothing
            Set objFSO = Nothing
            
            Refresh_Application
      End If
End Sub

</script>

<body STYLE="font:14 pt arial; color:white;filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Buttons'>
      <table width='90%' height = '100%' align='center' border='0'>
            <tr>
                  <td align="center" colspan="2">
                        <h2>HotKey Storing And Activating Program</h2>
                  </td>
            </tr>
            <tr>
                  <td align='center' colspan="2">
                        Currently Active Programs:<br>
                        <select name="lst_activeprograms" size="10" onclick="vbs:ShowHotKeys">
                              <option selected value='AllPrograms'>&nbsp&nbsp&nbsp&nbsp&nbsp-- View Hotkeys for All Programs --</option>
                        </select>
                  </td>
            </tr>
            <tr>
                  <td align='center' colspan="2">
                        Hotkeys Available:<br>
                        <select name="lst_hotkeys" size="10">
                        </select>
                  </td>
            </tr
            <tr>
                  <td align='center' width="50%">
                        <input type="button" value="Remove Hotkey" name="btn_RemoveHotkey"  onClick="vbs:RemoveHotkey">
                  </td>
                  <td align='center' width="50%">
                        <input type="button" value="Add New Hotkey" name="btn_AddNewHotkey"  onClick="vbs:AddNewHotkey">
                  </td>
            </tr>            <tr>
                  <td align='center' colspan="2">
                        <input type="button" value="Send Hotkey" name="btn_SendHotkey"  onClick="vbs:SendHotkey">
                  </td>
            </tr>
      </table>

</body>
'===============

You are welcome to do some testing, and make suggestions if you have any.....

Regards,

Rob.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.