Search code examples
pythonsendkeys

How can I select and delete all (ctrl + shift + left arrow + del) with shell.SendKeys?


Hey, I'm having some trouble here...

How can I delete an entire text from a field with the sendkeys ?

How can I send the ctrl+shift pressed with the left arrow and delete key after?

edit:

for example, I have this part of the code

ctypes.windll.user32.SetCursorPos(910,475)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0)
time.sleep(0.1)
shell.SendKeys(inf_firstname)

This part select a field and paste the firstname information (just like a macro), but I want to do something before paste the information that deletes the content of the field, if it has one...

capiche?


Solution

  • Might want to do Ctrl+A instead? Can you give a short example of the code that isn't working for you?

    Depending on the implementation of SendKeys, it might not accept all those at once. It might require multiple SendKeys invocations. You could try doing one at a time, in separate calls to SendKeys.

    Edit:

    http://msdn.microsoft.com/en-us/library/8c6yea83.aspx

    It seems to me you should be able to do this:

    shell.SendKeys("^a")
    shell.SendKeys("{DELETE}")