wordpad and special characters

G

Guest

Can one enter special characters in Word Pad by using shortcuts? Suppose I
want to insert a special character z with an accent, Unicode 017A (Hex) or
0378 (Dec). Is there a way to attach it to a shortcut rather than typing Alt
+ 377? This is to help a friend who does not have an Office, writes using
WordPad, and needs to use special diacritic characters. The computer she uses
runs under Win XP.
Thanks,
 
D

David Candy

Yes. Type 0377 then press Alt + X or hold Alt and press 0377 on numeric keypad.

Entering International Characters - Character Map
Start - All Programs - Accessories - System Tools - Character Map (or type charmap in Start - Run) and transfer via the clipboard or drag from Character Map into your document.

Run Character Map

[Back to International Contents]

Alt + Character Code
Holding down alt and pressing the character code on the numeric keypad will enter that character. The keyboard language in use must support entering that character. If your keyboard supports it the code is shown on the right hand side of the status bar in Character Map else this section of the status bar is empty.

However there is two ways of entering codes. The point to remember here that the characters are the same for the first 127 codes. The difference is if the first number typed is a zero of not. If it is then the code will insert the character from the current character set else it will insert a character from the OEM character set. Codes over 255 enter the unicode character and are in decimal. See the next section for converting hexidecimal to decimal.

E.G., Alt + 0 then 6 then 5 then release Alt enters the letter A

[Back to International Contents]

Hex To Unicode IME
In programs based on the Rich Edit 3 control, such as Wordpad, enter a unicode number in hexidecimal format into the document then press Alt + X. This will convert the number typed into the unicode character. Select a character and press Alt + X to convert that character into it's unicode number.

Selecting letters A to E will result in it being considered a hexidecimal number and it will convert to the unicode characters (which are things like form feed and the enter key).

To convert hexidecimal to decimal start Windows Calculator (type calc in Start - Run or Start - All Programs - Accessories - Calculator) and choose Scientific from the View menu. Select Hex, enter the number, and click Dec. Hex and Decimal are also on the View menu.

Run Calculator

Run Wordpad

[Back to International Contents]

Entering International Characters - US International Keyboards
Install the US International keyboard. Start - Control Panel - Regional And Language Options - Languages - Details - Add. While here review the Key Settings to switch keyboards or turn on the Language Bar (Advanced Text Services must not be disabled).

Run Language Dialog

This works in two modes. Right Alt or Shift + Right Alt + another key and also by pressing dead keys (such as accents). On non US Keyboards the Right Alt key is called Alt Gr.

Right Alt is the same key as Ctrl + Left Alt on the US International keyboards, and on almost all keyboards except the standard US keyboards where left and right keys are treated the same . This is a reason why Ctrl + Alt should not be used to set hotkeys. Also F12 should also not be used for hotkeys as it's reserved for attaching a debugger.

[Back to International Contents]

The Right Alt Keys
Key Description
Right Alt + 1 i
Right Alt + 2 ²
Right Alt + 3 ³
Right Alt + 4 ¤
Right Alt + 5 €
Right Alt + 6 1/4
Right Alt + 7 1/2
Right Alt + 8 3/4
Right Alt + 9 '
Right Alt + 0 '
Right Alt + - ¥
Right Alt + = ×
Right Alt + Q ä
Right Alt + W å
Right Alt + E é
Right Alt + R (r)
Right Alt + T þ
Right Alt + Y ü
Right Alt + U ú
Right Alt + I í
Right Alt + O ó
Right Alt + P ö
Right Alt + [ <<
Right Alt + ] >>
Right Alt + \ Not Sign
Right Alt + A á
Right Alt + S ß
Right Alt + D ð
Right Alt + L ø
Right Alt + ; Pilcrow Sign
Right Alt + ' ´
Right Alt + Z æ
Right Alt + C (c)
Right Alt + N ñ
Right Alt + M µ
Right Alt + , ç
Right Alt + / ¿
Shift + Right Alt + 1 ¹
Shift + Right Alt + 4 £
Shift + Right Alt + = ÷
Shift + Right Alt + Q Ä
Shift + Right Alt + W Ã…
Shift + Right Alt + E É
Shift + Right Alt + T Þ
Shift + Right Alt + Y Ü
Shift + Right Alt + U Ú
Shift + Right Alt + I Ã
Shift + Right Alt + O Ó
Shift + Right Alt + P Ö
Shift + Right Alt + \ ¦
Shift + Right Alt + A Ã
Shift + Right Alt + S §
Shift + Right Alt + D Ã
Shift + Right Alt + L Ø
Shift + Right Alt + ; °
Shift + Right Alt + ' ¨
Shift + Right Alt + Z Æ
Shift + Right Alt + C ¢
Shift + Right Alt + N Ñ
Shift + Right Alt + , Ç

[Back to International Contents]

The Dead Keys
The dead keys are the apostrophe ('), quotation mark ("), accent grave (`), tilde (~), and caret (^). If these are pressed the system waits for the next key. If it is in the list below then it enters the symbol character else it enters both keys seperately. These work with uppercase where appropiate.

Key Description
' then C Ç
' then e é
' then y ý
' then u ú
' then i í
' then o ó
' then a á
" then e ë
" then u ü
" then i ï
" then o ö
" then a ä
` then e è
` then u ù
` then i ì
` then o ò
~ then o õ
~ then n ñ
^ then e ê
^ then u û
^ then i î
^ then o ô
^ then a â

[Back to International Contents]

Switching Keyboards
Key Description
Left Alt + Shift Switches keyboard layout or language (default).
Control + Shift Switches keyboard layout (default) or language.
Left Alt + Shift + <a number, tilde (~), or accent grave (`)> Switches to a specific keyboard layout or language (default).
Control + Shift + <a number, tilde (~), or accent grave (`)> Switches to a specific keyboard layout (default) or language.

On the advanced tab turn on both Advanced Text Services and Extend Support To All Programs to enable Left Alt + Shift support.

Keys to switch layouts are set at Start - Control Panel - Regional Options - Languages - Details - Key Settings.

Run Language Dialog then click Advanced tab or Key Settings button.

[Back to International Contents]

[Back to Contents]

Tips
Like Accessibility there is a trick here with general applicability. Normally Caps Lock is on or off and stays on or off untill the key is pressed again. This can be changed to act like a typewriter at Start - Control Panel - Regional And Language Options - Languages - Details - Key Settings and one can select whether another Caps Lock press will turn off Caps Lock or if pressing the Shift key will turn it off like on a typewriter.

Run Language Dialog then click Key Settings button.
 
U

Unk

Can one enter special characters in Word Pad by using shortcuts? Suppose I
want to insert a special character z with an accent, Unicode 017A (Hex) or
0378 (Dec). Is there a way to attach it to a shortcut rather than typing Alt
+ 377? This is to help a friend who does not have an Office, writes using
WordPad, and needs to use special diacritic characters. The computer she uses
runs under Win XP.
Thanks,

The simplest way would be to create a short text file with the characters she needs. Then just
copy & paste the characters as needed.

Example:

¢
½
¼
°
±
²
¼
¾
®
©
 
G

Guest

Thank you both for your replies, esp. David for very extensive information.
My question however was meant to be slightly different: Is it possible to
assign a special character to a shortcut, such that, e.g. entering Alt+z
would enter a z with a dot (U+017C) or Alt+x would result in a z with an
accent (U+017A)? This is all in WordPad. See also my other posting re. if it
is possible to write a macro for Word Pad.

Thank you again,
 
D

David Candy

Create a shortcut and create a hotkey in the shortcut's properties.

Or if above is too easy ...

Create a text file and paste these lines in and name it WhateverYouWant.vbs. In this example it cuts and pastes between two windows. See below for sendkeys docs.


set WshShell = WScript.CreateObject("WScript.­Shell")
WshShell.SendKeys "%{TAB}^c%{TAB}^v"
[above sends Alt + Tab, Ctrl + C, Alt + Tab, then Ctrl + V]


Then set a shortcut to the scripts (right click it and choose Copy, go to the Desktop, a sub folder of the desktop, or on the Start Menu somewhere [right click Start and choose Open] and right click a blank area and choose Paste Shortcut) and set a hotkey for the shortcut (see help - but right click shortcut and choose Properties and look on the general tab - a lot of keys aren't available).


You may want to know these additional commands.


WSHShell.Run("c:\command.exe", 0, True)
==============================­===
With Param 1 being the command, Param 2 the window style (see below), and Param 3 a flag to indicate if to wait at this command untill the program started has exited - True it does and false it doesn't. Look in the Shortcut's Properties of the Start Menu shortcuts to see some command lines. You can also put document names in and have the Open command run on them.


Window Style
------------------
0 Hides the window and activates another window.
1 Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
2 Activates the window and displays it as a minimized window.
3 Activates the window and displays it as a maximized window.
4 Displays a window in its most recent size and position. The active window remains active.
5 Activates the window and displays it in its current size and position.
6 Minimizes the specified window and activates the next top-level window in the Z order.
7 Displays the window as a minimized window. The active window remains active.
8 Displays the window in its current state. The active window remains active.
9 Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
10 Sets the show-state based on the state of the program that started the application.


WSHShell.AppActivate "window title"


==============================


In determining which application to activate, the specified title is compared to the title string of each running application. If no exact match exists, any application whose title string begins with title is activated. If an application still cannot be found, any application whose title string ends with title is activated. If more than one instance of the application named by title exists, one instance is arbitrarily activated.


Use this to switch between windows and to make sure your sendkeys go to the right window.


WScript.Sleep 50
==============


Sends your program to sleep for the milliseconds specified. Sometimes you may need to do this to give the recieving program the ability to process your commands (as you are blocking it from running by sending it keystrokes) or more frequently to give a process enough time to complete.


SendKeys Syntax
==============


Sends one or more keystrokes to the active window (as if typed on the keyboard).


object.SendKeys(string)Argumen­ts
object
WshShell object.
string
String value indicating the keystroke(s) you want to send.
Remarks
Use the SendKeys method to send keystrokes to applications that have no automation interface. Most keyboard characters are represented by a single keystroke. Some keyboard characters are made up of combinations of keystrokes (CTRL+SHIFT+HOME, for example). To send a single keyboard character, send the character itself as the string argument. For example, to send the letter x, send the string argument "x".


Note To send a space, send the string " ".
You can use SendKeys to send more than one keystroke at a time. To do this, create a compound string argument that represents a sequence of keystrokes by appending each keystroke in the sequence to the one before it. For example, to send the keystrokes a, b, and c, you would send the string argument "abc". The SendKeys method uses some characters as modifiers of characters (instead of using their face-values). This set of special characters consists of parentheses, brackets, braces, and the:


a.. plus sign "+",
b.. caret "^",
c.. percent sign "%",
d.. and tilde "~"
Send these characters by enclosing them within braces "{}". For example, to send the plus sign, send the string argument "{+}". Brackets "[ ]" have no special meaning when used with SendKeys, but you must enclose them within braces to accommodate applications that do give them a special meaning (for dynamic data exchange (DDE) for example).


a.. To send bracket characters, send the string argument "{[}" for the left bracket and "{]}" for the right one.
b.. To send brace characters, send the string argument "{{}" for the left brace and "{}}" for the right one.
Some keystrokes do not generate characters (such as ENTER and TAB). Some keystrokes represent actions (such as BACKSPACE and BREAK). To send these kinds of keystrokes, send the arguments shown in the following table:


Key Argument
BACKSPACE {BACKSPACE}, {BS}, or {BKSP}
BREAK {BREAK}
CAPS LOCK {CAPSLOCK}
DEL or DELETE {DELETE} or {DEL}
DOWN ARROW {DOWN}
END {END}
ENTER {ENTER} or ~
ESC {ESC}
HELP {HELP}
HOME {HOME}
INS or INSERT {INSERT} or {INS}
LEFT ARROW {LEFT}
NUM LOCK {NUMLOCK}
PAGE DOWN {PGDN}
PAGE UP {PGUP}
PRINT SCREEN {PRTSC}
RIGHT ARROW {RIGHT}
SCROLL LOCK {SCROLLLOCK}
TAB {TAB}
UP ARROW {UP}
F1 {F1}
F2 {F2}
F3 {F3}
F4 {F4}
F5 {F5}
F6 {F6}
F7 {F7}
F8 {F8}
F9 {F9}
F10 {F10}
F11 {F11}
F12 {F12}
F13 {F13}
F14 {F14}
F15 {F15}
F16 {F16}


To send keyboard characters that are comprised of a regular keystroke in combination with a SHIFT, CTRL, or ALT, create a compound string argument that represents the keystroke combination. You do this by preceding the regular keystroke with one or more of the following special characters:


Key Special Character
SHIFT +
CTRL ^
ALT %


Note When used this way, these special characters are not enclosed within a set of braces.
To specify that a combination of SHIFT, CTRL, and ALT should be held down while several other keys are pressed, create a compound string argument with the modified keystrokes enclosed in parentheses. For example, to send the keystroke combination that specifies that the SHIFT key is held down while:


a.. e and c are pressed, send the string argument "+(ec)".
b.. e is pressed, followed by a lone c (with no SHIFT), send the string argument "+ec".
You can use the SendKeys method to send a pattern of keystrokes that consists of a single keystroke pressed several times in a row. To do this, create a compound string argument that specifies the keystroke you want to repeat, followed by the number of times you want it repeated. You do this using a compound string argument of the form {keystroke number}. For example, to send the letter "x" ten times, you would send the string argument "{x 10}". Be sure to include a space between keystroke and number.


Note The only keystroke pattern you can send is the kind that is comprised of a single keystroke pressed several times. For example, you can send "x" ten times, but you cannot do the same for "Ctrl+x".
Note You cannot send the PRINT SCREEN key {PRTSC} to an application.
 
D

David Candy

Ignore first two lines - it was an answer I gave to someone else's question.

--
--------------------------------------------------------------------------------------------------
How to lose a war in Iraq
http://webdiary.com.au/cms/?q=node/1335#comment-48641
=================================================
"David Candy" <.> wrote in message Create a shortcut and create a hotkey in the shortcut's properties.

Or if above is too easy ...

Create a text file and paste these lines in and name it WhateverYouWant.vbs. In this example it cuts and pastes between two windows. See below for sendkeys docs.


set WshShell = WScript.CreateObject("WScript.­Shell")
WshShell.SendKeys "%{TAB}^c%{TAB}^v"
[above sends Alt + Tab, Ctrl + C, Alt + Tab, then Ctrl + V]


Then set a shortcut to the scripts (right click it and choose Copy, go to the Desktop, a sub folder of the desktop, or on the Start Menu somewhere [right click Start and choose Open] and right click a blank area and choose Paste Shortcut) and set a hotkey for the shortcut (see help - but right click shortcut and choose Properties and look on the general tab - a lot of keys aren't available).


You may want to know these additional commands.


WSHShell.Run("c:\command.exe", 0, True)
==============================­===
With Param 1 being the command, Param 2 the window style (see below), and Param 3 a flag to indicate if to wait at this command untill the program started has exited - True it does and false it doesn't. Look in the Shortcut's Properties of the Start Menu shortcuts to see some command lines. You can also put document names in and have the Open command run on them.


Window Style
------------------
0 Hides the window and activates another window.
1 Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
2 Activates the window and displays it as a minimized window.
3 Activates the window and displays it as a maximized window.
4 Displays a window in its most recent size and position. The active window remains active.
5 Activates the window and displays it in its current size and position.
6 Minimizes the specified window and activates the next top-level window in the Z order.
7 Displays the window as a minimized window. The active window remains active.
8 Displays the window in its current state. The active window remains active.
9 Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
10 Sets the show-state based on the state of the program that started the application.


WSHShell.AppActivate "window title"


==============================


In determining which application to activate, the specified title is compared to the title string of each running application. If no exact match exists, any application whose title string begins with title is activated. If an application still cannot be found, any application whose title string ends with title is activated. If more than one instance of the application named by title exists, one instance is arbitrarily activated.


Use this to switch between windows and to make sure your sendkeys go to the right window.


WScript.Sleep 50
==============


Sends your program to sleep for the milliseconds specified. Sometimes you may need to do this to give the recieving program the ability to process your commands (as you are blocking it from running by sending it keystrokes) or more frequently to give a process enough time to complete.


SendKeys Syntax
==============


Sends one or more keystrokes to the active window (as if typed on the keyboard).


object.SendKeys(string)Argumen­ts
object
WshShell object.
string
String value indicating the keystroke(s) you want to send.
Remarks
Use the SendKeys method to send keystrokes to applications that have no automation interface. Most keyboard characters are represented by a single keystroke. Some keyboard characters are made up of combinations of keystrokes (CTRL+SHIFT+HOME, for example). To send a single keyboard character, send the character itself as the string argument. For example, to send the letter x, send the string argument "x".


Note To send a space, send the string " ".
You can use SendKeys to send more than one keystroke at a time. To do this, create a compound string argument that represents a sequence of keystrokes by appending each keystroke in the sequence to the one before it. For example, to send the keystrokes a, b, and c, you would send the string argument "abc". The SendKeys method uses some characters as modifiers of characters (instead of using their face-values). This set of special characters consists of parentheses, brackets, braces, and the:


a.. plus sign "+",
b.. caret "^",
c.. percent sign "%",
d.. and tilde "~"
Send these characters by enclosing them within braces "{}". For example, to send the plus sign, send the string argument "{+}". Brackets "[ ]" have no special meaning when used with SendKeys, but you must enclose them within braces to accommodate applications that do give them a special meaning (for dynamic data exchange (DDE) for example).


a.. To send bracket characters, send the string argument "{[}" for the left bracket and "{]}" for the right one.
b.. To send brace characters, send the string argument "{{}" for the left brace and "{}}" for the right one.
Some keystrokes do not generate characters (such as ENTER and TAB). Some keystrokes represent actions (such as BACKSPACE and BREAK). To send these kinds of keystrokes, send the arguments shown in the following table:


Key Argument
BACKSPACE {BACKSPACE}, {BS}, or {BKSP}
BREAK {BREAK}
CAPS LOCK {CAPSLOCK}
DEL or DELETE {DELETE} or {DEL}
DOWN ARROW {DOWN}
END {END}
ENTER {ENTER} or ~
ESC {ESC}
HELP {HELP}
HOME {HOME}
INS or INSERT {INSERT} or {INS}
LEFT ARROW {LEFT}
NUM LOCK {NUMLOCK}
PAGE DOWN {PGDN}
PAGE UP {PGUP}
PRINT SCREEN {PRTSC}
RIGHT ARROW {RIGHT}
SCROLL LOCK {SCROLLLOCK}
TAB {TAB}
UP ARROW {UP}
F1 {F1}
F2 {F2}
F3 {F3}
F4 {F4}
F5 {F5}
F6 {F6}
F7 {F7}
F8 {F8}
F9 {F9}
F10 {F10}
F11 {F11}
F12 {F12}
F13 {F13}
F14 {F14}
F15 {F15}
F16 {F16}


To send keyboard characters that are comprised of a regular keystroke in combination with a SHIFT, CTRL, or ALT, create a compound string argument that represents the keystroke combination. You do this by preceding the regular keystroke with one or more of the following special characters:


Key Special Character
SHIFT +
CTRL ^
ALT %


Note When used this way, these special characters are not enclosed within a set of braces.
To specify that a combination of SHIFT, CTRL, and ALT should be held down while several other keys are pressed, create a compound string argument with the modified keystrokes enclosed in parentheses. For example, to send the keystroke combination that specifies that the SHIFT key is held down while:


a.. e and c are pressed, send the string argument "+(ec)".
b.. e is pressed, followed by a lone c (with no SHIFT), send the string argument "+ec".
You can use the SendKeys method to send a pattern of keystrokes that consists of a single keystroke pressed several times in a row. To do this, create a compound string argument that specifies the keystroke you want to repeat, followed by the number of times you want it repeated. You do this using a compound string argument of the form {keystroke number}. For example, to send the letter "x" ten times, you would send the string argument "{x 10}". Be sure to include a space between keystroke and number.


Note The only keystroke pattern you can send is the kind that is comprised of a single keystroke pressed several times. For example, you can send "x" ten times, but you cannot do the same for "Ctrl+x".
Note You cannot send the PRINT SCREEN key {PRTSC} to an application.
 
D

David Candy

Also be wary in copying and pasting as an extra character gets added before Shell.

--
--------------------------------------------------------------------------------------------------
How to lose a war in Iraq
http://webdiary.com.au/cms/?q=node/1335#comment-48641
=================================================
"David Candy" <.> wrote in message Create a shortcut and create a hotkey in the shortcut's properties.

Or if above is too easy ...

Create a text file and paste these lines in and name it WhateverYouWant.vbs. In this example it cuts and pastes between two windows. See below for sendkeys docs.


set WshShell = WScript.CreateObject("WScript.­Shell")
WshShell.SendKeys "%{TAB}^c%{TAB}^v"
[above sends Alt + Tab, Ctrl + C, Alt + Tab, then Ctrl + V]


Then set a shortcut to the scripts (right click it and choose Copy, go to the Desktop, a sub folder of the desktop, or on the Start Menu somewhere [right click Start and choose Open] and right click a blank area and choose Paste Shortcut) and set a hotkey for the shortcut (see help - but right click shortcut and choose Properties and look on the general tab - a lot of keys aren't available).


You may want to know these additional commands.


WSHShell.Run("c:\command.exe", 0, True)
==============================­===
With Param 1 being the command, Param 2 the window style (see below), and Param 3 a flag to indicate if to wait at this command untill the program started has exited - True it does and false it doesn't. Look in the Shortcut's Properties of the Start Menu shortcuts to see some command lines. You can also put document names in and have the Open command run on them.


Window Style
------------------
0 Hides the window and activates another window.
1 Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
2 Activates the window and displays it as a minimized window.
3 Activates the window and displays it as a maximized window.
4 Displays a window in its most recent size and position. The active window remains active.
5 Activates the window and displays it in its current size and position.
6 Minimizes the specified window and activates the next top-level window in the Z order.
7 Displays the window as a minimized window. The active window remains active.
8 Displays the window in its current state. The active window remains active.
9 Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
10 Sets the show-state based on the state of the program that started the application.


WSHShell.AppActivate "window title"


==============================


In determining which application to activate, the specified title is compared to the title string of each running application. If no exact match exists, any application whose title string begins with title is activated. If an application still cannot be found, any application whose title string ends with title is activated. If more than one instance of the application named by title exists, one instance is arbitrarily activated.


Use this to switch between windows and to make sure your sendkeys go to the right window.


WScript.Sleep 50
==============


Sends your program to sleep for the milliseconds specified. Sometimes you may need to do this to give the recieving program the ability to process your commands (as you are blocking it from running by sending it keystrokes) or more frequently to give a process enough time to complete.


SendKeys Syntax
==============


Sends one or more keystrokes to the active window (as if typed on the keyboard).


object.SendKeys(string)Argumen­ts
object
WshShell object.
string
String value indicating the keystroke(s) you want to send.
Remarks
Use the SendKeys method to send keystrokes to applications that have no automation interface. Most keyboard characters are represented by a single keystroke. Some keyboard characters are made up of combinations of keystrokes (CTRL+SHIFT+HOME, for example). To send a single keyboard character, send the character itself as the string argument. For example, to send the letter x, send the string argument "x".


Note To send a space, send the string " ".
You can use SendKeys to send more than one keystroke at a time. To do this, create a compound string argument that represents a sequence of keystrokes by appending each keystroke in the sequence to the one before it. For example, to send the keystrokes a, b, and c, you would send the string argument "abc". The SendKeys method uses some characters as modifiers of characters (instead of using their face-values). This set of special characters consists of parentheses, brackets, braces, and the:


a.. plus sign "+",
b.. caret "^",
c.. percent sign "%",
d.. and tilde "~"
Send these characters by enclosing them within braces "{}". For example, to send the plus sign, send the string argument "{+}". Brackets "[ ]" have no special meaning when used with SendKeys, but you must enclose them within braces to accommodate applications that do give them a special meaning (for dynamic data exchange (DDE) for example).


a.. To send bracket characters, send the string argument "{[}" for the left bracket and "{]}" for the right one.
b.. To send brace characters, send the string argument "{{}" for the left brace and "{}}" for the right one.
Some keystrokes do not generate characters (such as ENTER and TAB). Some keystrokes represent actions (such as BACKSPACE and BREAK). To send these kinds of keystrokes, send the arguments shown in the following table:


Key Argument
BACKSPACE {BACKSPACE}, {BS}, or {BKSP}
BREAK {BREAK}
CAPS LOCK {CAPSLOCK}
DEL or DELETE {DELETE} or {DEL}
DOWN ARROW {DOWN}
END {END}
ENTER {ENTER} or ~
ESC {ESC}
HELP {HELP}
HOME {HOME}
INS or INSERT {INSERT} or {INS}
LEFT ARROW {LEFT}
NUM LOCK {NUMLOCK}
PAGE DOWN {PGDN}
PAGE UP {PGUP}
PRINT SCREEN {PRTSC}
RIGHT ARROW {RIGHT}
SCROLL LOCK {SCROLLLOCK}
TAB {TAB}
UP ARROW {UP}
F1 {F1}
F2 {F2}
F3 {F3}
F4 {F4}
F5 {F5}
F6 {F6}
F7 {F7}
F8 {F8}
F9 {F9}
F10 {F10}
F11 {F11}
F12 {F12}
F13 {F13}
F14 {F14}
F15 {F15}
F16 {F16}


To send keyboard characters that are comprised of a regular keystroke in combination with a SHIFT, CTRL, or ALT, create a compound string argument that represents the keystroke combination. You do this by preceding the regular keystroke with one or more of the following special characters:


Key Special Character
SHIFT +
CTRL ^
ALT %


Note When used this way, these special characters are not enclosed within a set of braces.
To specify that a combination of SHIFT, CTRL, and ALT should be held down while several other keys are pressed, create a compound string argument with the modified keystrokes enclosed in parentheses. For example, to send the keystroke combination that specifies that the SHIFT key is held down while:


a.. e and c are pressed, send the string argument "+(ec)".
b.. e is pressed, followed by a lone c (with no SHIFT), send the string argument "+ec".
You can use the SendKeys method to send a pattern of keystrokes that consists of a single keystroke pressed several times in a row. To do this, create a compound string argument that specifies the keystroke you want to repeat, followed by the number of times you want it repeated. You do this using a compound string argument of the form {keystroke number}. For example, to send the letter "x" ten times, you would send the string argument "{x 10}". Be sure to include a space between keystroke and number.


Note The only keystroke pattern you can send is the kind that is comprised of a single keystroke pressed several times. For example, you can send "x" ten times, but you cannot do the same for "Ctrl+x".
Note You cannot send the PRINT SCREEN key {PRTSC} to an application.
 
G

Guest

Thank you a lot David. I do appreciate.
--
JanAdam


David Candy said:
Also be wary in copying and pasting as an extra character gets added before Shell.

--
--------------------------------------------------------------------------------------------------
How to lose a war in Iraq
http://webdiary.com.au/cms/?q=node/1335#comment-48641
=================================================
"David Candy" <.> wrote in message Create a shortcut and create a hotkey in the shortcut's properties.

Or if above is too easy ...

Create a text file and paste these lines in and name it WhateverYouWant.vbs. In this example it cuts and pastes between two windows. See below for sendkeys docs.


set WshShell = WScript.CreateObject("WScript.­Shell")
WshShell.SendKeys "%{TAB}^c%{TAB}^v"
[above sends Alt + Tab, Ctrl + C, Alt + Tab, then Ctrl + V]


Then set a shortcut to the scripts (right click it and choose Copy, go to the Desktop, a sub folder of the desktop, or on the Start Menu somewhere [right click Start and choose Open] and right click a blank area and choose Paste Shortcut) and set a hotkey for the shortcut (see help - but right click shortcut and choose Properties and look on the general tab - a lot of keys aren't available).


You may want to know these additional commands.


WSHShell.Run("c:\command.exe", 0, True)
==============================­===
With Param 1 being the command, Param 2 the window style (see below), and Param 3 a flag to indicate if to wait at this command untill the program started has exited - True it does and false it doesn't. Look in the Shortcut's Properties of the Start Menu shortcuts to see some command lines. You can also put document names in and have the Open command run on them.


Window Style
------------------
0 Hides the window and activates another window.
1 Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
2 Activates the window and displays it as a minimized window.
3 Activates the window and displays it as a maximized window.
4 Displays a window in its most recent size and position. The active window remains active.
5 Activates the window and displays it in its current size and position.
6 Minimizes the specified window and activates the next top-level window in the Z order.
7 Displays the window as a minimized window. The active window remains active.
8 Displays the window in its current state. The active window remains active.
9 Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
10 Sets the show-state based on the state of the program that started the application.


WSHShell.AppActivate "window title"


==============================


In determining which application to activate, the specified title is compared to the title string of each running application. If no exact match exists, any application whose title string begins with title is activated. If an application still cannot be found, any application whose title string ends with title is activated. If more than one instance of the application named by title exists, one instance is arbitrarily activated.


Use this to switch between windows and to make sure your sendkeys go to the right window.


WScript.Sleep 50
==============


Sends your program to sleep for the milliseconds specified. Sometimes you may need to do this to give the recieving program the ability to process your commands (as you are blocking it from running by sending it keystrokes) or more frequently to give a process enough time to complete.


SendKeys Syntax
==============


Sends one or more keystrokes to the active window (as if typed on the keyboard).


object.SendKeys(string)Argumen­ts
object
WshShell object.
string
String value indicating the keystroke(s) you want to send.
Remarks
Use the SendKeys method to send keystrokes to applications that have no automation interface. Most keyboard characters are represented by a single keystroke. Some keyboard characters are made up of combinations of keystrokes (CTRL+SHIFT+HOME, for example). To send a single keyboard character, send the character itself as the string argument. For example, to send the letter x, send the string argument "x".


Note To send a space, send the string " ".
You can use SendKeys to send more than one keystroke at a time. To do this, create a compound string argument that represents a sequence of keystrokes by appending each keystroke in the sequence to the one before it. For example, to send the keystrokes a, b, and c, you would send the string argument "abc". The SendKeys method uses some characters as modifiers of characters (instead of using their face-values). This set of special characters consists of parentheses, brackets, braces, and the:


a.. plus sign "+",
b.. caret "^",
c.. percent sign "%",
d.. and tilde "~"
Send these characters by enclosing them within braces "{}". For example, to send the plus sign, send the string argument "{+}". Brackets "[ ]" have no special meaning when used with SendKeys, but you must enclose them within braces to accommodate applications that do give them a special meaning (for dynamic data exchange (DDE) for example).


a.. To send bracket characters, send the string argument "{[}" for the left bracket and "{]}" for the right one.
b.. To send brace characters, send the string argument "{{}" for the left brace and "{}}" for the right one.
Some keystrokes do not generate characters (such as ENTER and TAB). Some keystrokes represent actions (such as BACKSPACE and BREAK). To send these kinds of keystrokes, send the arguments shown in the following table:


Key Argument
BACKSPACE {BACKSPACE}, {BS}, or {BKSP}
BREAK {BREAK}
CAPS LOCK {CAPSLOCK}
DEL or DELETE {DELETE} or {DEL}
DOWN ARROW {DOWN}
END {END}
ENTER {ENTER} or ~
ESC {ESC}
HELP {HELP}
HOME {HOME}
INS or INSERT {INSERT} or {INS}
LEFT ARROW {LEFT}
NUM LOCK {NUMLOCK}
PAGE DOWN {PGDN}
PAGE UP {PGUP}
PRINT SCREEN {PRTSC}
RIGHT ARROW {RIGHT}
SCROLL LOCK {SCROLLLOCK}
TAB {TAB}
UP ARROW {UP}
F1 {F1}
F2 {F2}
F3 {F3}
F4 {F4}
F5 {F5}
F6 {F6}
F7 {F7}
F8 {F8}
F9 {F9}
F10 {F10}
F11 {F11}
F12 {F12}
F13 {F13}
F14 {F14}
F15 {F15}
F16 {F16}


To send keyboard characters that are comprised of a regular keystroke in combination with a SHIFT, CTRL, or ALT, create a compound string argument that represents the keystroke combination. You do this by preceding the regular keystroke with one or more of the following special characters:


Key Special Character
SHIFT +
CTRL ^
ALT %


Note When used this way, these special characters are not enclosed within a set of braces.
To specify that a combination of SHIFT, CTRL, and ALT should be held down while several other keys are pressed, create a compound string argument with the modified keystrokes enclosed in parentheses. For example, to send the keystroke combination that specifies that the SHIFT key is held down while:


a.. e and c are pressed, send the string argument "+(ec)".
b.. e is pressed, followed by a lone c (with no SHIFT), send the string argument "+ec".
You can use the SendKeys method to send a pattern of keystrokes that consists of a single keystroke pressed several times in a row. To do this, create a compound string argument that specifies the keystroke you want to repeat, followed by the number of times you want it repeated. You do this using a compound string argument of the form {keystroke number}. For example, to send the letter "x" ten times, you would send the string argument "{x 10}". Be sure to include a space between keystroke and number.


Note The only keystroke pattern you can send is the kind that is comprised of a single keystroke pressed several times. For example, you can send "x" ten times, but you cannot do the same for "Ctrl+x".
Note You cannot send the PRINT SCREEN key {PRTSC} to an application.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top