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

message getting displayed in another window when invoked

P: 17
I am invoking a cygwin session by the following code

Expand|Select|Wrap|Line Numbers
  1. from win32com.client import *
  3. a = Dispatch("Wscript.Shell")
  5. a.Run("C:/cygwin/cygwin.bat");  
  7. a.SendKeys ("cd D:/temp/code" + "{Enter}")
  9. a.SendKeys ("ls -lrt?" + "{Enter}")
Scenario: If another window namely NOTEPAD is invoked during the course of the script execution

Expected result: The entire script (commands) should be executed in the cygwin window regardless of any external application.

Result obtained: The current command executed is copied into the invoked window rather than at the cygwin prompt (i.e "ls -lrt" command is issued in the Notepad window.)

Thus what i intended to happen at cygwin prompt didnt happen completely.

How do i ensure that the command that i am issuing is executed in the window where in i need it. Why does this happen and How do i handle this situation?

Kindly guide me accordingly.

Nov 22 '06 #1
Share this Question
Share on Google+
2 Replies

Expert 5K+
P: 6,596
It seems to me that much depends on how you do this:

Scenario: If another window namely NOTEPAD is invoked during the course of the script execution
Help us help you by supplying a little more info. Thanks.
Nov 22 '06 #2

P: 17
The problem i am facing is it that during the course of the execution of the script, if knowingly or unknowingly any text editor is opened, the remaining command inside the "a.SendKeys" command is displayed there.

I have no clue why is such a thing happening.

Expand|Select|Wrap|Line Numbers
  1. a.Run("C:/cygwin/cygwin.bat");   #invokes the cygwin session
  2. a.SendKeys ("cd D:/temp/code" + "{Enter}") #executes the cd command 
now when i invoke a text editor (knowingly or unknowingly) the remaining command in the code below is printed in the editor.

Expand|Select|Wrap|Line Numbers
  1. a.SendKeys ("ls -lrt?" + "{Enter}")
I just want the commands to be executed in the cygwin prompt which is invoked as shown in the code section of the 1st post. But when a text editor is invoked the issue persists.

Is it something to do with handling with active window or something?

i hope i am able to convey the problem i am facing.

Nov 28 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.