AutoHotkey Community

It is currently May 26th, 2012, 3:33 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: March 16th, 2009, 10:38 am 
Offline

Joined: June 1st, 2006, 5:04 pm
Posts: 45
Location: Denmark
Hi,

I've tried searching the forum for a solution, but I haven't been able to find any.

Seems to me, that if I take a copied text (f.x. czech characters) and place it in a variable, then it is translated into western characters!

The below is just an exampel - if I mark a czech letter like č and run the code, then I'm seeing a normal c

Code:
Send, {Ctrl Down}c{Ctrl Up} ; copy
Sleep, 200
Textcopy=%clipboard% ;put copied text to variable

msgbox, %Textcopy% ;now it's translated to western characters :-(

return


Is there a workaround to this, which I'm just oblivious to?

_________________
Casper


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2009, 11:04 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
Interestingly, č turns into c( on my system. Unfortunately, AutoHotkey does not support unicode, which is used by the OS to support many languages. There are workarounds, but they depend on what you're trying to accomplish.

If you simply want to save and restore the clipboard contents, preserving unicode, use ClipboardAll instead of Clipboard.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2009, 11:15 am 
Offline

Joined: June 1st, 2006, 5:04 pm
Posts: 45
Location: Denmark
Lexikos wrote:
Interestingly, č turns into c( on my system. Unfortunately, AutoHotkey does not support unicode, which is used by the OS to support many languages. There are workarounds, but they depend on what you're trying to accomplish.

If you simply want to save and restore the clipboard contents, preserving unicode, use ClipboardAll instead of Clipboard.


Thanks for the reply!

The purpose of the script is to copy the text from a excel field and paste it to a field on a intranet site (I'm creating users from a excel sheet)

I'm not able to make this clipboardall thing to work tho. If I try to replace clipboard with clipboardall, then it almost seems random what I get.. either way it doesn't work for me :-(

Code:
#y::

Send, {Ctrl Down}c{Ctrl Up} ; copy
Sleep, 200
Textcopy=%clipboardall%

msgbox, %Textcopy%

return

_________________
Casper


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2009, 12:09 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
ClipboardAll retrieves all of the clipboard contents, in every format available. It is not text, so cannot be displayed by MsgBox. var:=ClipboardAll ... Clipboard:=var will work.

If you only need to copy and paste, why even bring the text into AutoHotkey? That is, would Send ^c ... Send ^v do the job?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2009, 1:57 pm 
Offline

Joined: June 1st, 2006, 5:04 pm
Posts: 45
Location: Denmark
Lexikos wrote:
ClipboardAll retrieves all of the clipboard contents, in every format available. It is not text, so cannot be displayed by MsgBox. var:=ClipboardAll ... Clipboard:=var will work.

If you only need to copy and paste, why even bring the text into AutoHotkey? That is, would Send ^c ... Send ^v do the job?


Ah oki, i can see ^c and ^v works.

It is sort of an issue for me still tho, since I'll have to bring multipal fields from excel to the webpage - and now I have to tap between the two windows constantly :?

How do I do the ClipboardAll to var thing before pasting it? - I just can't seem to figure it out.

_________________
Casper


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2009, 2:22 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
Quote:
and now I have to tap between the two windows constantly
You could copy each field into its own variable before switching windows, or use ControlSend to avoid ever activating the windows.
Quote:
How do I do the ClipboardAll to var thing before pasting it?
I've already said, var:=ClipboardAll ... Clipboard:=var. The first part copies the current clipboard contents into a variable, and the second copies it back into the clipboard. (... denotes code between the two to make it useful.)

Here is an example which I've tested in the forum reply box:
Code:
KeyWait, RCtrl, D
KeyWait, RCtrl
; Save initial clipboard contents.
FirstClip := ClipboardAll
; Start of document.
Send ^{Home}
Loop 5
{
    Clipboard =
    ; Select and copy line.
    Send {Home 2}+{End}^c
    ClipWait, 1, 1
    if ErrorLevel
        break
    ; Save line in variable.
    line%A_Index% := ClipboardAll
    ; Move to next line.
    Send {Down}
}
Run notepad
WinWaitActive, ahk_class Notepad
Loop 5
{
    ; Paste line.
    Clipboard := line%A_Index%
    Send ^v`n
    ; Give some time for the target to process it (not always necessary).
    Sleep, 500
}
; Restore initial clipboard contents.
Clipboard := FirstClip
Run the script, then activate an edit box and press RCtrl to begin.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2009, 5:38 pm 
Offline

Joined: November 4th, 2008, 9:23 am
Posts: 1045
You might want to check out Transform -> Unicode.

_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Yahoo [Bot] and 15 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