AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Inserting ASCII characters

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
rjwilmsi



Joined: 18 May 2005
Posts: 13

PostPosted: Wed May 18, 2005 10:06 am    Post subject: Inserting ASCII characters Reply with quote

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
View user's profile Send private message
toralf as guest
Guest





PostPosted: Wed May 18, 2005 11:37 am    Post subject: Reply with quote

Please have a look, if "Transform" with "Unicode" helps in this case.
Back to top
rjwilmsi



Joined: 18 May 2005
Posts: 13

PostPosted: Wed May 18, 2005 1:11 pm    Post subject: Reply with quote

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
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3841
Location: Bremen, Germany

PostPosted: Wed May 18, 2005 1:52 pm    Post subject: Reply with quote

then you haven't read the manual completly.
Code:
Transform, Clipboard, Unicode, %MyUTF_String% ; Places Unicode text onto the clipboard.


With
Code:
Send, %clipboard%
you can then send the unicode character to the editor/window.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Wed May 18, 2005 3:20 pm    Post subject: Re: Inserting ASCII characters Reply with quote

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
View user's profile Send private message Send e-mail
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Wed May 18, 2005 6:06 pm    Post subject: Reply with quote

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
View user's profile Send private message
rjwilmsi



Joined: 18 May 2005
Posts: 13

PostPosted: Thu May 19, 2005 9:26 am    Post subject: Reply with quote

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
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Thu May 19, 2005 12:36 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Thu May 19, 2005 4:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group