473,543 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("WScr ipt.Shell")
shell.Run("Note pad")
win32api.Sleep( 100)
shell.AppActiva te("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.SendKe ys("""^c""")
Thank you!

Jun 27 '08 #1
2 10047
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("WScr ipt.Shell")
shell.Run("Note pad")
win32api.Sleep( 100)
shell.AppActiva te("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.SendKe ys("""^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("WScr ipt.Shell")
shell.Run("Note pad")
win32api.Sleep( 100)
shell.AppActiva te("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.SendKe ys("""^c""")
Thank you!
Your code didn't work for me, either. But shell.SendKeys( "^a^c")
works...go figure.
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
24653
by: baileystuff | last post by:
I have an issue where I have three Cases that SHOULD act the same but don't. If you look at the code below you will see that the general premise is to open a MSWord template and then use SendKey commands to get it to save the file using a new name (NewFName is assigned earlier in the code). A couple of issues to keep in mind. These are...
0
1266
by: Alexander Ovchinnikov | last post by:
Hi All! Is it Possible to send some kind of string from Windows Service to IIS application so the latter can get info through javascript function String.fromCharCode( window.event.keyCode ). I'm trying to use SendKeys but obviously this work only for the same application nut I need to cross boundary between my applications. Any ideas how to...
2
1410
by: Jesse | last post by:
Is there a way to HOLD a key down programatically? I have a listbox that I want to behave as though the user is holding down the CTRL key, so they get a certain behavior w/ regard to multiselecting items in the list. So I would like to have the CTRL key held down (in code) for the duration of the existence of the form. Is this possible?
0
1574
by: angelsoft | last post by:
How to send Microsoft Natural Keyboard keys with sendkey method ej. Windows Logo: Start menú, Windows Logo+R: Run dialog box
0
1825
by: Gunawan | last post by:
Can someone help me how to write console application to sendkey c:>sendkey {ALT}+{TAB} simulate key ALT+TAB TIA Gun
7
7672
by: JV | last post by:
I am running a large Access 2000 application (installed using Access Runtime) that uses many VB SendKeys, primarily to expand combo boxes On Enter. When trying to run it on Vista I get a "Permission denied" (error 70) error whenever entering a combo box. I have already changed the shortcut that starts access and opens the database to "Run as...
2
3075
by: kru | last post by:
Hi All, Simple question yet I can't figure it out. I need to send the TAB key to an external application. It is able to send {ENTER} etc yet no luck with the {TAB}. I have tried the following:
12
19556
by: DAHMB | last post by:
I have a form that calls up a report in the form I have several date fields that have date input masks. I have created a cancel button as: Private Sub btnCancel_Click() On Error GoTo Err_btnCancel_Click Dim stDocName As String DoCmd.Close Exit_btnCancel_Click:
0
1278
by: ngeluis | last post by:
Hello every one.. Im having problems to send a command to Windows - Run... I want to send a command to Windows - Run to the people only have to press the Enter Key... The text that i want to send to Windows - Run is like this -B: \setup.exe +uAEKLX +pc:\TEAMSTM I can do it but if i use my .net code and Vbs... but i wanted to use only...
1
3134
by: John Dio | last post by:
I am trying to create a on screen key board. I simply want to send a key (Simulate the keyboard) to a combo box using the Handle of the control. The below code is not working
0
7410
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7351
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
5276
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4896
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3392
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3392
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
639
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.