AutoHotkey Community

It is currently May 27th, 2012, 12:41 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: December 18th, 2009, 12:11 pm 
Offline

Joined: February 2nd, 2008, 4:35 am
Posts: 643
Hello
What i am trying to achieve is send a character from a certain font set to the currently active window
But i'm afraid i don't understand fonts very well ׃(

This is what i have done so far:
I have a .txt file (saved as UTF-8`), within which i pasted the character (copied from the Windows "Character Map" app), and it shows as a (box)
But if i open the file, copy it to clipboard, & then paste it into app's window, it appears as i want it to (a "ל")
But when i put it into a script, it doesn't send the correct char (even though the char is in the exact same font as in the target window)
Is this due to Autohotkey script not able to be an UTF-8 file?

Here's my (UTF-8`) script
Code:
clipboard := "ל"      ;= a (box) in notepad (as want to keep my current notepad font (Lucida Console))
Send ^v            ;sends "ל"  (× = couldn't find; œ = U+0153)

char := Chr(E804)     ;got hex value "U+E804" from "Character Map" app (does U = Unicode ??)
Send % char           ;sends nothing


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 19th, 2009, 2:35 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
AutoHotkey doesn't support Unicode. AutoHotkeyU does.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 19th, 2009, 7:14 pm 
Offline

Joined: October 25th, 2009, 6:10 pm
Posts: 17
I didn't write this. I'm new. It's copied from another forum post, and I had it lying around in a script. I've tried it and it works. SendInputU(2211) inserts a capital Sigma. I'm to lazy to look up the post for proper attribution, but I think that it's one of the AHK gods.
Code:
EncodeInteger( p_value, p_size, p_address, p_offset )
{
   loop, %p_size%
      DllCall( "RtlFillMemory"
         , "uint", p_address+p_offset+A_Index-1
         , "uint", 1
         , "uchar", ( p_value >> ( 8*( A_Index-1 ) ) ) & 0xFF )
}

SendInputU( p_text )
{
   StringLen, len, p_text

   INPUT_size = 28
   
   event_count := ( len//4 )*2
   VarSetCapacity( events, INPUT_size*event_count, 0 )

   loop, % event_count//2
   {
      StringMid, code, p_text, ( A_Index-1 )*4+1, 4
     
      base := ( ( A_Index-1 )*2 )*INPUT_size+4
         EncodeInteger( 1, 4, &events, base-4 )
         EncodeInteger( "0x" code, 2, &events, base+2 )
         EncodeInteger( 4, 4, &events, base+4 ) ; KEYEVENTF_UNICODE

      base += INPUT_size
         EncodeInteger( 1, 4, &events, base-4 )
         EncodeInteger( "0x" code, 2, &events, base+2 )
         EncodeInteger( 2|4, 4, &events, base+4 ) ; KEYEVENTF_KEYUP|KEYEVENTF_UNICODE
   }
   
   result := DllCall( "SendInput", "uint", event_count, "uint", &events, "int", INPUT_size )
   if ( ErrorLevel or result < event_count )
   {
      MsgBox, [SendInput] failed: EL = %ErrorLevel% ~ %result% of %event_count%
      return, false
   }
   
   return, true
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 20th, 2009, 1:16 am 
Offline

Joined: October 25th, 2009, 6:10 pm
Posts: 17
The attribution is http://www.autohotkey.com/forum/viewtopic.php?t=7328&highlight=unicode+character


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Leef_me, Ohnitiel, XstatyK, Yahoo [Bot] and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group