| View previous topic :: View next topic |
| Author |
Message |
rjwilmsi
Joined: 18 May 2005 Posts: 13
|
Posted: Wed May 18, 2005 10:06 am Post subject: Inserting ASCII characters |
|
|
First of all, I've only been using AutoHotkey for a few days, but it's a great little application. I've been getting along with it pretty well, except for inserting ASCII characters using hotstrings.
I have the following working perfectly for getting French accents:
| Code: | :?*C:a\::{ASC 0224}
:?*C:a^::{ASC 0226}
:?*C:c/::{ASC 0231}
:?*C:c^::{ASC 0231}
:?*C:e/::{ASC 0233}
:?*C:e\::{ASC 0232}
:?*C:e^::{ASC 0234}
:?*C:i^::{ASC 0238}
:?*C:o\::{ASC 0242}
:?*C:o^::{ASC 0244}
:?*C:u\::{ASC 0249}
:?*C:u^::{ASC 0251} |
However, to get unicode characters with code numbers above 255, I'm struggling. For example I want my deliberate misspelling of ohms to give me the capital omega that's used as the ohms resistance symbol for electronics:
| Code: | | :*C:ohmss::{ASC 937} |
But this gives me the registered copyright symbol ® instead. I've got the number from converting the hexadecimal code (03A9) for the symbol given in OpenOffice. So obviously I'm missing something here? |
|
| Back to top |
|
 |
toralf as guest Guest
|
Posted: Wed May 18, 2005 11:37 am Post subject: |
|
|
| Please have a look, if "Transform" with "Unicode" helps in this case. |
|
| Back to top |
|
 |
rjwilmsi
Joined: 18 May 2005 Posts: 13
|
Posted: Wed May 18, 2005 1:11 pm Post subject: |
|
|
| toralf as guest wrote: | | Please have a look, if "Transform" with "Unicode" helps in this case. |
Quote the help file:
| Quote: | | Unicode [, String] [v1.0.24+]: Retrieves or stores Unicode text on the clipboard. |
I'm pretty sure it doesn't do what I want to do, as I need to generate Unicode characters, not copy them. |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3841 Location: Bremen, Germany
|
Posted: Wed May 18, 2005 1:52 pm Post subject: |
|
|
then you haven't read the manual completly.
| Code: | | Transform, Clipboard, Unicode, %MyUTF_String% ; Places Unicode text onto the clipboard. |
With you can then send the unicode character to the editor/window. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Wed May 18, 2005 3:20 pm Post subject: Re: Inserting ASCII characters |
|
|
| rjwilmsi wrote: | :*C:ohmss::{ASC 937}
But this gives me the registered copyright symbol ® instead. | Strange, I tried that hotstring in Word and another editor and it did yield the ohm symbol. Maybe it's some kind of keyboard layout issue. You could try putting a leading 0 in front of 937. |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Wed May 18, 2005 6:06 pm Post subject: |
|
|
| This comes up so often that maybe a help section could be devoted to it. See my notes in http://www.autohotkey.com/forum/viewtopic.php?t=3513. The problem is that {ASC 937} is equivalent to pressing Alt-Numpad 9,3,7. This method works for some Windows applications, like MS Word or WordPad, but not being a standard Windows feature, it almost never works elsewhere, like in Notepad, PowerPoint, etc. |
|
| Back to top |
|
 |
rjwilmsi
Joined: 18 May 2005 Posts: 13
|
Posted: Thu May 19, 2005 9:26 am Post subject: |
|
|
Ok, thanks for your help Laszlo and toralf. I've worked out how to do what I want. If anybody else is interested I'm using this code:
| Code: | :*C:ohmss::
Transform, Clipboard, Unicode, Ω
Send, ^v
Exit |
So when I type ohmss I get the symbol Ω. It seems work in all applications that support display of the symbol (OpenOffice, Firefox, Notepad etc.).
I think it would be really helpful if something like this could be added to the (already very comprehensive) help file, as the {ASC nnnnn} option isn't as universal. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Thu May 19, 2005 12:36 pm Post subject: |
|
|
| Laszlo wrote: | | This comes up so often that maybe a help section could be devoted to it. | Thanks. I've added this valuable info to the Send command's "Send {Asc nnnnn}" section: | Quote: | | To generate Unicode characters, specify a number between 256 and 65535 (without a leading zero). However, this is not supported by all applications. Therefore, for greater compatibility and easier sending of long Unicode strings, use "Transform Unicode". |
By the way, I haven't forgotten about the ClipboardCore improvement to work around the MS Word bookmark problem you mentioned. It should be done soon, but I'm not sure whether to do it as a new variable (ClipboardCore) or a directive that alters the nature of ClipboardAll for the entire script. A new variable is probably more flexible. |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Thu May 19, 2005 4:47 pm Post subject: |
|
|
I used the following script to collect the string equivalents of Unicode characters I often need (before I wrote my own keyboard driver). | Code: | SetFormat Integer, hex
Loop
{
ClipWait
Transform ClipUTF, Unicode
ClipBoard =
Transform a1, ASC, %ClipUTF%
StringTrimLeft c2, ClipUTF, 1
Transform a2, ASC, %c2%
a2 += 256*a1
MsgBox %ClipUTF% = %a2%
} | In the Windows character map double-click on the desired symbol and the MsgBox tells the transformed string, which you have to put in the clipboard if you want the Unicode symbol pasted in the application with | Code: | Transform Clipboard, Unicode, %ClipUTF%
Send ^v | I hoped to find a simple relationship between ClipUTF and the Windows code U+xxxx, but I could not find any. |
|
| Back to top |
|
 |
|