?
Solved

Software for storing, selecting, and sending keystrokes to applications

Posted on 2007-08-06
18
Medium Priority
?
509 Views
Last Modified: 2008-01-09
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
0
Comment
Question by:mranders
  • 9
  • 8
18 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 19643083
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
 

Author Comment

by:mranders
ID: 19643276
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
 
LVL 65

Expert Comment

by:RobSampson
ID: 19643280
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:mranders
ID: 19643307
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
 
LVL 63

Expert Comment

by:SysExpert
ID: 19647193
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
 

Author Comment

by:mranders
ID: 19647811
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
 
LVL 65

Expert Comment

by:RobSampson
ID: 19652101
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
 

Author Comment

by:mranders
ID: 19656447
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
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 19668151
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
 
LVL 65

Expert Comment

by:RobSampson
ID: 19668158
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
 

Author Comment

by:mranders
ID: 19672113
Wow! Thanks  a million! I will take look later this evening.
0
 

Author Comment

by:mranders
ID: 19676826
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
 
LVL 65

Expert Comment

by:RobSampson
ID: 19680844
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
 

Author Comment

by:mranders
ID: 19689268
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
 

Author Comment

by:mranders
ID: 19689316
I am going to take a closer look at your code also. Thanks I am learning a lot from this.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 19689705
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
 

Author Comment

by:mranders
ID: 19710387
I am very interested in what you do with his. Thanks Rob.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 19715027
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Know the reasons and solutions to move/import EDB to New Exchange Server. Also, find out how to recover an Exchange .edb file and to restore the file back.
This article is about my experience upgrading my consulting machine to Windows 10 Version 1709 (The Fall 2017 Creator Update)
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decadeā€¦

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question