473,288 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,288 software developers and data experts.

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 9952
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
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...
0
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...
2
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...
0
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
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
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...
2
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...
12
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...
0
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...
1
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
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.