How to send a compsite key to window

Discussion in 'Python' started by zhouhaifeng, May 21, 2009.

  1. zhouhaifeng

    zhouhaifeng Guest

    just like "ctrl + A",

    I want to select all the text in a window, now , I operate right menu to
    get it, but it can not work all the time.
    so I want to send "ctrl + a" to the window


    blow is my code
    thanks


    hWnd = win32gui.FindWindow(None, "¡°Öлª»á¼ÆÍøУ¡±²ÆË°·¨¹æ¿âÏÂÔØ°æV1.09-·¨
    ¹æÔĶÁÆ÷")
    print hWnd
    if hWnd <> 0:
    print "½«½¹µãÒÆÖÁ´°¿ÚÄÚ"
    point = (755, 175)
    x, y = point
    win32api.SetCursorPos(point)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x, y, 0, 0)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
    print "ÓÒ¼ü²Ëµ¥"
    win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN,x, y, 0, 0)
    win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, x, y, 0, 0)

    win32api.Sleep(1000)

    #µ¥»÷"È«Ñ¡"
    x = x + 10
    y = y + 115
    point = (x, y)
    win32api.SetCursorPos(point)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x, y, 0, 0)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)

    win32api.Sleep(500)

    #ÓÒ¼ü²Ëµ¥
    point = (455, 175)
    x, y = point
    win32api.SetCursorPos(point)
    win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN,x, y, 0, 0)
    win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, x, y, 0, 0)
    #win32api.SendMessage(hwnd, win32con.WM_KEYDOWN, win32con.VK_CONTROL, 0)
    #win32api.SendMessage(hwnd, win32con.WM_KEYUP, win32con.VK_CONTROL, 0)
    win32api.Sleep(500)

    #µ¥»÷"¸´ÖÆ"
    x = x + 10
    y = y + 25
    point = (x, y)
    win32api.SetCursorPos(point)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x, y, 0, 0)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
    zhouhaifeng, May 21, 2009
    #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. Frank
    Replies:
    1
    Views:
    672
    William Ryan
    Dec 31, 2003
  2. Alvin Bruney

    Re: Send Info from Window to Window

    Alvin Bruney, Aug 24, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    375
    Alvin Bruney
    Aug 24, 2003
  3. chuckdfoster

    Send Info From PopUp Window To Parent Window

    chuckdfoster, Dec 6, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    714
    =?Utf-8?B?SmVk?=
    Dec 6, 2005
  4. zhouhaifeng

    How to send a compsite key to window

    zhouhaifeng, May 21, 2009, in forum: Python
    Replies:
    0
    Views:
    320
    zhouhaifeng
    May 21, 2009
  5. M P
    Replies:
    1
    Views:
    466
Loading...

Share This Page