how to let shell.SendKeys use unicode on windows in python

Discussion in 'Python' started by oyster, Aug 10, 2010.

  1. oyster

    oyster Guest

    I want to use python to do some automatical operation on windows.
    the following is the code, which try to open a file with unicode
    characters in its filename in msword
    but I can't get it work correctly. Can anybody help me?

    if that is the shortcoming of WScript, is there any other way to do so
    in python?
    (I know there is something like autohotkey, but I am not willing to
    learn a new langauge )

    thanks in advance


    import time
    import win32com.client

    shell = win32com.client.Dispatch("WScript.Shell")
    shell.AppActivate('winword')
    time.sleep(0.1)

    shell.SendKeys('%fo') # Alt+F, O
    time.sleep(0.1)

    path=r'c:\some unicode in file name.doc'
    shell.SendKeys(path) #
    fail on this line, no unicode appeared
    shell.SendKeys('{ENTER}')
     
    oyster, Aug 10, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike John
    Replies:
    0
    Views:
    1,100
    Mike John
    Jul 7, 2003
  2. Luigi Donatello Asero

    Let or not let the text float

    Luigi Donatello Asero, Jan 15, 2004, in forum: HTML
    Replies:
    6
    Views:
    472
    Steve R.
    Jan 15, 2004
  3. Albert Hopkins

    Re: SendKeys and Python 2.7

    Albert Hopkins, Sep 9, 2010, in forum: Python
    Replies:
    0
    Views:
    428
    Albert Hopkins
    Sep 9, 2010
  4. Michel Claveau - MVP

    Re: SendKeys and Python 2.7

    Michel Claveau - MVP, Sep 9, 2010, in forum: Python
    Replies:
    7
    Views:
    3,213
    Lawrence D'Oliveiro
    Sep 11, 2010
  5. Jakson A. Aquino

    Re: SendKeys and Python 2.7

    Jakson A. Aquino, Sep 10, 2010, in forum: Python
    Replies:
    3
    Views:
    652
    Lawrence D'Oliveiro
    Sep 11, 2010
Loading...

Share This Page