By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,551 Members | 1,127 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,551 IT Pros & Developers. It's quick & easy.

sendKey

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.