@Ghisler
Thank you for your reply - i had misunderstand the usage of placeholders and now all are clear to me!
ghisler(Author) wrote: 2019-03-13, 08:16 UTC
...It receives the first path, then character #13 (not 0x13, 0x0D)...
Is this wrong? For AutoHotkey, the escaped r [`r] i am using to separate 1st and 2nd path is the CR "carriage return", ASCII DEC=13, ASCII HEX=0x0D.
Additionally, by using `r TC handle the paths correctly.
ghisler(Author) wrote: 2019-03-13, 08:16 UTC
2. Unicode can be handled by sending either UTF-8 or UTF-16 text WITH byte order marker (BOM).
I didn't try to send unicode before. Until now I convert all the [LeftPath `r RightPath] string to the system's default ANSI code page (CP0).
This is working for Eng and Greek language paths.
In the following script:
-- any number of placeholders (i call them Flags) must send correctly to TC now.
-- there are 5 tests (Modes) for testing to send the paths as UTF-8 and UTF-16. The last mode is sending paths in system's default ANSI code page.
-- there are 4 paths for test - 2 with English characters only and 2 with Greek characters.
Modes:
Mode=1 ["UTF-8 BOM" Path1 "`r" "UTF-8 BOM" Path2] converted to UTF-8
Mode=2 ["UTF-8 BOM" Path1 "`r" "UTF-8 BOM" Path2] converted to UTF-8 (2nd way)
Mode=3 ["UTF-16 BOM" Path1 "`r" "UTF-16 BOM" Path2] converted to UTF-8
Mode=4 ["UTF-16 BOM" Path1 "`r" "UTF-16 BOM" Path2] converted to UTF-16
Mode=5 [Path1 "`r" Path2] converted to the system's default ANSI code page (CP0).
Results:
Mode=1: EN_Paths=OK, GR_Paths=FAIL
Mode=2: EN_Paths=FAIL, GR_Paths=FAIL
Mode=3: EN_Paths=OK, GR_Paths=OK, Flags=OK (For some reason, UTF-8 but with UTF-16 BOM, working OK !!!)
Mode=4: EN_Paths=OK, GR_Paths=OK, Flags=FAIL
Mode=5: EN_Paths=OK, GR_Paths=OK, Flags=OK
Christian, can you please test the script (and with other than Greek characters in paths), mainly Modes 3 and 5 that are working to me?
I will clean up the script to use only the Mode you will suggest.
Thank you very much
Best Regards
Code: Select all
#SingleINSTANCE, Force
P1_EN := "D:\__APPS__\"
P1_GR := "D:\__ΕΓΓΡΑΦΑ___\ΑΙΤΗΣΗ-ΔΗΛΩΣΗ-ΕΞΟΥΣΙΟΔΟΤΗΣΗ\"
P2_EN := "C:\FirefoxDownloads\!TC\"
P2_GR := "D:\__ΘΕΜΑΤΑ____\ΔΙΑΣΚΕΔΑΣΗ\ΑΝΕΚΔΟΤΑ\"
Return
F5::
WinActivate, ahk_class TTOTAL_CMD
LOOP, 5
{
IF A_INDEX IN 1,2,4 ; ByPass/Dissable FAIL Modes
Continue
TC_WMCopyData( P1_EN, P1_GR, "LT", A_INDEX )
MsgBox,4096,Mode = %A_INDEX%,*[%P1_EN%]`n`n[%P1_GR%]
TC_WMCopyData( P2_GR, P2_EN, "RT", A_INDEX )
MsgBox,4096, Mode = %A_INDEX%,[%P2_GR%]`n`n*[%P2_EN%]
}
Return
/*
Mode=1 ["UTF-8 BOM" Path1 "`r" "UTF-8 BOM" Path2] converted to UTF-8
Mode=2 ["UTF-8 BOM" Path1 "`r" "UTF-8 BOM" Path2] converted to UTF-8 (2nd way)
Mode=3 ["UTF-16 BOM" Path1 "`r" "UTF-16 BOM" Path2] converted to UTF-8
Mode=4 ["UTF-16 BOM" Path1 "`r" "UTF-16 BOM" Path2] converted to UTF-16
Mode=5 [Path1 "`r" Path2] converted to the system's default ANSI code page (CP0).
*/
TC_WMCopyData( Path1, Path2, Flags="", Mode=1 ) {
Critical
IF A_IsUnicode ; AutoHotkey Unicode version
{
IF Mode=1
cmd := Chr(0xEFBBBF) Path1 "`r" Chr(0xEFBBBF) Path2, VarSetCapacity(cmdA, StrPut(cmd, "UTF-8"), 0), Len:=StrPut(cmd, &cmdA, "UTF-8")
Else IF Mode=2
cmd := Chr(0xEF) Chr(0xBB) Chr(0xBF) Path1 "`r" Chr(0xEF) Chr(0xBB) Chr(0xBF) Path2, VarSetCapacity(cmdA, StrPut(cmd, "UTF-8"), 0), Len:=StrPut(cmd, &cmdA, "UTF-8")
Else IF Mode=3
cmd := Chr(0xFEFF) Path1 "`r" Chr(0xFEFF) Path2, VarSetCapacity(cmdA, StrPut(cmd, "UTF-8"), 0), Len:=StrPut(cmd, &cmdA, "UTF-8")
Else IF Mode=4
cmd := Chr(0xFEFF) Path1 "`r" Chr(0xFEFF) Path2, VarSetCapacity(cmdA, StrPut(cmd, "UTF-16")*2, 0), Len:=StrPut(cmd, &cmdA, "UTF-16")*2
Else IF Mode=5
cmd := Path1 "`r" Path2, VarSetCapacity(cmdA, StrPut(cmd, "cp0"), 0), Len:=StrPut(cmd, &cmdA, "cp0")
}
Else
cmd := Path1 "`r" Path2, Len:=StrLen(cmd)+1
VarSetCapacity( CopyDataStruct, A_PtrSize * 3, 0 )
NumPut( Asc("C") + 256 * Asc("D"), CopyDataStruct,0 )
NumPut( Len + 5 * (A_IsUnicode ? 2 : 1), CopyDataStruct, A_PtrSize )
NumPut((A_IsUnicode ? &cmdA : &cmd), CopyDataStruct, A_PtrSize * 2)
Loop, % StrLen(Flags)
NumPut(Asc(SubStr(Flags,A_Index,1)),(A_IsUnicode ? cmdA : cmd),Len+A_Index-1, "Char")
SendMessage, 0x4A,, &CopyDataStruct,, ahk_class TTOTAL_CMD
}