Sendkeys with non-English characters
Sendkeys function since version 3.1a is able to type characters from any language. If your language is not English or Western European language, you have to encode your script in Unicode, menu File/Save as and in Encoding, take 16-bit Unicode.
In versions before 3.1a, use the SUB send_string(string$) below.
dim tab_car$(100)
'-----------------------------------
'In this subroutine, ALL the specials
'characters must bee listed (increase index number
'when adding a new character)
sub init()
tab_car$()=""
tab_car$(0)="É"
tab_car$(1)="æ"
tab_car$(2)="Æ"
tab_car$(3)="ô"
tab_car$(4)="ö"
tab_car$(5)="ò"
tab_car$(6)="û"
endsub
'------------------------------------
'this subroutine counts the number of special characters
sub count_nbcar_part()
local i, a$
i=0
repeat
a$=tab_car$(i)
if a$="" then
exit=1
else
i=i+1
endif
until exit=1
nb_car=i
endsub
'------------------------------------
'this subroutine uses the shortcut "paste" for sending "car$" in the 'application. The application must support this function. Wintask sends 'to the clipboard the special character and uses the copy function to 'send it in the 'application. If it is a normal character, "sendkeys" 'is used. Two window names are used, the window application name '(parent window) and the client window name (child window). In many 'applications, the same name may be used. But you have to check using 'Spy.
sub send_char(car$)
local i, find
find=0
i=0
repeat
if car$=tab_car$(i) then
find=1
a=asc(tab_car$(i))
a$=chr$(a)
setclipboard(a$)
UseWindow(parent_window$)
'IN THE NEXT SENDKEYS, PUT THE APPLICATION SHORTCUT FOR ' 'PASTE OPTION IN EDIT MENU
sendkeys("<Ctrl v>")
else
i=i+1
endif
until i = nb_car or find=1
if find=0 then
usewindow(child_window$)
sendkeys(car$)
endif
endsub
'-------------------------------------
'use this subroutine in place of sendkeys function (string$ : string to 'send to the application)
sub send_string(string$)
local lg, i
lg=len(string$)
if lg > 0 then
i=1
repeat
car$=mid$(string$,i,1)
send_char(car$)
i=i+1
until i >lg
endif
endsub
'***********************************************************
'	INITIALIZATIONS
'***********************************************************
'example in NOTEPAD application
parent_window$="NOTEPAD.EXE|Notepad|Untitled - Notepad"
child_window$="NOTEPAD.EXE|Edit|Untitled - Notepad|1"
init()
count_nbcar_part()
'************************************************************
'	MAIN PROGRAM '
'************************************************************
string$="ÉæÆôöòûabcde"
send_string(string$)