469,327 Members | 1,219 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

sendKey

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!

Jun 27 '08 #1
2 9393
Gandalf wrote:
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.
import SendKeys
SendKeys.SendKeys("""^c""")
Thank you!
--
Kam-Hung Soh <a href="http://kamhungsoh.com/blog">Software Salariman</a>

Jun 27 '08 #2
Gandalf wrote:
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.
Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by baileystuff | last post: by
reply views Thread by Alexander Ovchinnikov | last post: by
2 posts views Thread by Jesse | last post: by
reply views Thread by Gunawan | last post: by
2 posts views Thread by kru | last post: by
reply views Thread by ngeluis | last post: by
1 post views Thread by John Dio | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.