sendKey

G

Gandalf

I found some script that send keys , But I couldn't manage to send
CTRL+c with none of them

can any one tell me what i'm doing wrong:

import win32api
import win32com.client

shell = win32com.client.Dispatch("WScript.Shell")
shell.Run("Notepad")
win32api.Sleep(100)
shell.AppActivate("Notepad")
win32api.Sleep(100)
shell.SendKeys("112435435")
win32api.Sleep(100)

shell.SendKeys("^a") # that wouldn't select all
win32api.Sleep(100)
shell.SendKeys("^c")# that wouldn't copy




import SendKeys
SendKeys.SendKeys("""^c""")


Thank you!
 
K

Kam-Hung Soh

Gandalf said:
I found some script that send keys , But I couldn't manage to send
CTRL+c with none of them

can any one tell me what i'm doing wrong:

import win32api
import win32com.client

shell = win32com.client.Dispatch("WScript.Shell")
shell.Run("Notepad")
win32api.Sleep(100)
shell.AppActivate("Notepad")
win32api.Sleep(100)
shell.SendKeys("112435435")
win32api.Sleep(100)

shell.SendKeys("^a") # that wouldn't select all
win32api.Sleep(100)
shell.SendKeys("^c")# that wouldn't copy

Works for me, using Vista and ActiveState Python 2.5.1.1.
 
S

Steve McKay

Gandalf said:
I found some script that send keys , But I couldn't manage to send
CTRL+c with none of them

can any one tell me what i'm doing wrong:

import win32api
import win32com.client

shell = win32com.client.Dispatch("WScript.Shell")
shell.Run("Notepad")
win32api.Sleep(100)
shell.AppActivate("Notepad")
win32api.Sleep(100)
shell.SendKeys("112435435")
win32api.Sleep(100)

shell.SendKeys("^a") # that wouldn't select all
win32api.Sleep(100)
shell.SendKeys("^c")# that wouldn't copy




import SendKeys
SendKeys.SendKeys("""^c""")


Thank you!
Your code didn't work for me, either. But shell.SendKeys("^a^c")
works...go figure.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top