FAQ

Veelgestelde vragen voor zelfhulp.

Bekijk snel de veelgestelde vragen (en antwoorden) in de standaardlijst. Als u niet kunt vinden wat u zoekt, begin dan met het selecteren van uw Ability Office -versie en verfijn deze dan door zoektekst en/of categorie in te voeren.

Kennisbank artikel 93

Sending "any" keys to an application

To program Ability, use the OLE Automation features in combination with macros. This is described in the on-line help.

For functionality not supported by OLE Automation, you can use a general routine to send keyboard characters to Ability. You can do this from both inside Ability and outside Ability. The method is "SendKeys" and it's part of Windows Scripting Host that comes with Microsoft Windows (98 and later).

Example:

Sub SendAbilityKeys
  Set WshShell = CreateObject("WScript.Shell")
  WshShell.AppActivate "Ability Write"

  WshShell.SendKeys "Any old plain text"    ' Some text in the document
 
End Sub

To access special characters, use the following key codes:

Key Key code
Alt %
Ctrl ^
Shift +
Esc {ESC}
Ins {INS}
Functions keys {Fn} eg {F1}. {F12}
Home {HOME}
End {END}
Delete {DEL}
Enter {ENTER}

To use Alt, Ctrl or Shift in combination with other characters, simply precede the character with the Alt, Ctrl or Shift key code from the above table.

Examples

Sub SendAbilityKeys
  Set WshShell = CreateObject("WScript.Shell")
  WshShell.AppActivate "Ability Write"

  WshShell.SendKeys "^P"                ' Displays the Print dialog (Ctrl-P)
  WshShell.SendKeys "+{F3}%U{ENTER}"    ' Converts selected text to uppercase
  WshShell.SendKeys "%{F4}Y"            ' Exit and answer "Yes" to save changes 

End Sub

References

For general info on scripting, including latest downloads, see:
http://msdn.microsoft.com/scripting/

For more info on "Sendkeys" in particular see:
http://msdn.microsoft.com/scripting/windowshost/doc/wsMthSendKeys.htm