1

I'm trying to use SendKeys to send some special characters, for example é.

If I use

set mySendKeys = CreateObject("WScript.shell")
mySendKeys.SendKeys "é"

For sure it won't work...

I'm thinking that interpret the character by using asc("é"), get its result is chr(233), then mySendKeys.SendKeys chr(233)

Sounds good?... But it will generate an error Invalid procedure call or argument

I found a similar question here

Or is there any other way to simulate keyboard to input special character like this?

Community
  • 1
  • 1
nwpulele
  • 211
  • 3
  • 12
  • This is not a key on the keyboard and doesn't have a virtual key code. SendKeys is not international-aware and a poor solution to most problems. Any test automation tool should have a more robust facility for doing this, like Microsoft's own UI Automation. – Cody Gray - on strike Jun 21 '16 at 16:16
  • I noticed you tagged this as an UFT question. Is there a special reason to use `SendKeys` instead of using the `.Set` method of the object? As mentioned by @Cody, `SendKeys` is a poor solution and I would avoid it – Victor Moraes Jun 21 '16 at 17:32

1 Answers1

1

You should try it like this :

set ws = CreateObject("WScript.shell")
ws.SendKeys chr(233)

EDIT :

Dim i,x,a,ws
i = InputBox("Entrer un caractère ou une phrase pour obtenir son Code Unicode Correspondant !","test","éè@!%")
If i <> "" Then
    For x = 1 To Len(i)
        If x <> Len(i) Then
            a = a & "ChrW(" & AscW(Mid(i,x,1)) & ")" & "&"
        Else
            a = a & "ChrW(" & AscW(Mid(i,x,1)) & ")"
        End if
    Next
    Inputbox "Le Code Unicode Correspondant pour " & qq(i) & " est:",,a
End If

wscript.sleep 5000
set ws = CreateObject("WScript.shell")
ws.SendKeys qq(i)
'******************************************************************
Function qq(strIn)
    qq = Chr(34) & strIn & Chr(34)
End Function
'******************************************************************
Hackoo
  • 18,337
  • 3
  • 40
  • 70
  • @nwpulele i don't understand your aim, but anyway, try my edit ! – Hackoo Jun 21 '16 at 16:21
  • Thanks for your help!! I executed your code and it only output `"@!` seems still can't send `éè` and `%` is missing... I'll continue try... – nwpulele Jun 21 '16 at 17:33
  • @nwpulele Can you edit your question and paste your hole code, because for me it works and i get `éè@!%` – Hackoo Jun 21 '16 at 17:56