Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #24966 > unrolled thread
| Started by | Chirag B <chirag.b.93@gmail.com> |
|---|---|
| First post | 2012-07-06 04:53 -0700 |
| Last post | 2012-07-08 18:45 -0700 |
| Articles | 6 — 6 participants |
Back to article view | Back to comp.lang.python
stuck in files!! Chirag B <chirag.b.93@gmail.com> - 2012-07-06 04:53 -0700
Re: stuck in files!! Thomas Jollans <t@jollybox.de> - 2012-07-06 16:56 +0200
Re: stuck in files!! andrea crotti <andrea.crotti.0@gmail.com> - 2012-07-06 17:46 +0100
Re: stuck in files!! "Alex" <foo@email.invalid> - 2012-07-06 18:21 +0000
Re: stuck in files!! Chris Angelico <rosuav@gmail.com> - 2012-07-07 08:13 +1000
Re: stuck in files!! alex23 <wuwei23@gmail.com> - 2012-07-08 18:45 -0700
| From | Chirag B <chirag.b.93@gmail.com> |
|---|---|
| Date | 2012-07-06 04:53 -0700 |
| Subject | stuck in files!! |
| Message-ID | <5ddf03db-a5b1-4996-b9ce-6447ad89a3df@nw7g2000pbb.googlegroups.com> |
i want to kno how to link two applications using python for eg:notepad txt file and some docx file. like i wat to kno how to take path of those to files and run them simultaneously.like if i type something in notepad it has to come in wordpad whenever i run that code.
[toc] | [next] | [standalone]
| From | Thomas Jollans <t@jollybox.de> |
|---|---|
| Date | 2012-07-06 16:56 +0200 |
| Message-ID | <mailman.1861.1341586609.4697.python-list@python.org> |
| In reply to | #24966 |
On 07/06/2012 01:53 PM, Chirag B wrote: > i want to kno how to link two applications using python for eg:notepad > txt file and some docx file. like i wat to kno how to take path of > those to files and run them simultaneously.like if i type something in > notepad it has to come in wordpad whenever i run that code. > Not possible. (okay, within certain restrictions it might not be completely impossible) What are you trying to achieve?
[toc] | [prev] | [next] | [standalone]
| From | andrea crotti <andrea.crotti.0@gmail.com> |
|---|---|
| Date | 2012-07-06 17:46 +0100 |
| Message-ID | <mailman.1863.1341593198.4697.python-list@python.org> |
| In reply to | #24966 |
2012/7/6 Chirag B <chirag.b.93@gmail.com>: > i want to kno how to link two applications using python for eg:notepad > txt file and some docx file. like i wat to kno how to take path of > those to files and run them simultaneously.like if i type something in > notepad it has to come in wordpad whenever i run that code. > -- > http://mail.python.org/mailman/listinfo/python-list I don't think that "I want to know" ever lead to some useful answers, it would be not polite even if people were actually paid to answer ;) Anyway it's quite an application-os specific question, probably not very easy either..
[toc] | [prev] | [next] | [standalone]
| From | "Alex" <foo@email.invalid> |
|---|---|
| Date | 2012-07-06 18:21 +0000 |
| Message-ID | <jt7aai$bu5$1@dont-email.me> |
| In reply to | #24966 |
Chirag B wrote: > i want to kno how to link two applications using python for eg:notepad > txt file and some docx file. like i wat to kno how to take path of > those to files and run them simultaneously.like if i type something in > notepad it has to come in wordpad whenever i run that code. Text and docx files are not "applications"; you don't "run" them. You can "open" them with applications like Notepad or Microsoft Word, and you can open two files simultaneously in two different applications (or in two windows within the same application). Other than that, I don't understand what you mean by "link" them or what it means for something typed in Notepad to "come in wordpad."
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2012-07-07 08:13 +1000 |
| Message-ID | <mailman.1875.1341612834.4697.python-list@python.org> |
| In reply to | #24983 |
On Sat, Jul 7, 2012 at 4:21 AM, Alex <foo@email.invalid> wrote: > Chirag B wrote: > >> i want to kno how to link two applications using python for eg:notepad >> txt file and some docx file. like i wat to kno how to take path of >> those to files and run them simultaneously.like if i type something in >> notepad it has to come in wordpad whenever i run that code. > > Text and docx files are not "applications"; you don't "run" them. You > can "open" them with applications like Notepad or Microsoft Word, and > you can open two files simultaneously in two different applications (or > in two windows within the same application). > > Other than that, I don't understand what you mean by "link" them or > what it means for something typed in Notepad to "come in wordpad." The nearest I can think of has nothing to do with Python, but all to do with the applications concerned: DDE. Back in the early 90s it was a much-touted technology on OS/2 - you could fire up Mesa (spreadsheet), hotlink a particular group of cells to a table in DeScribe, edit one and see the other change instantly. It was pretty cool for its day. How you'd go about implementing it today I don't know, but there's a few options available. Really depends on what the OP actually wants to achieve: Duplicate typing, shared text, simultaneous editing? ChrisA
[toc] | [prev] | [next] | [standalone]
| From | alex23 <wuwei23@gmail.com> |
|---|---|
| Date | 2012-07-08 18:45 -0700 |
| Message-ID | <1710b9e3-164f-4e45-827d-cd7b9bb5e868@y3g2000pbc.googlegroups.com> |
| In reply to | #24966 |
On Jul 6, 9:53 pm, Chirag B <chirag.b...@gmail.com> wrote:
> i want to kno how to link two applications using python for eg:notepad
> txt file and some docx file. like i wat to kno how to take path of
> those to files and run them simultaneously.like if i type something in
> notepad it has to come in wordpad whenever i run that code.
Here's an approach that opens Notepad & Word, then monitors Notepad
for any changes, updating the open Word document when they occur. This
hasn't been tested in any great depth, and I wouldn't run it anywhere
with existing instances of Notepad or Word open without testing what
happens first, but it should get you started.
For the most part this uses standard library files, although I did go
with WinGuiAuto as a quick and dirty wrapper around the win32gui
complexity. If you don't want to introduce it as a dependency, you can
extract the functionality you need: http://www.brunningonline.net/simon/blog/archives/winGuiAuto.py.html
import os
import time
from win32com.client import Dispatch
from winguiauto import (
findTopWindow,
findControl,
getEditText,
WinGuiAutoError
)
# conditional for main loop
def window_is_open(hwnd):
try:
findTopWindow(selectionFunction=lambda ohwnd: hwnd ==
ohwnd)
return True
except WinGuiAutoError:
return False
# start Notepad
os.system('start notepad')
time.sleep(0.1) # give it time to open or we don't get the handleW
npad = findTopWindow(wantedText='Untitled - Notepad')
ndoc = findControl(npad, wantedClass='Edit') # edit control for
Notepad
# start Word
word = Dispatch("Word.Application")
word.Visible = True
wdoc = word.Documents.Add() # edit control (new document) for Word
# update Word when Notepad changes
MEMORY = None
while window_is_open(npad):
ntxt = getEditText(ndoc)
if ntxt != MEMORY:
wdoc.Content.Text = os.linesep.join(ntxt)
MEMORY = ntxt
time.sleep(1)
wdoc.Close() # opens a save dialogue
wdoc.Quit()
Hope this helps.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web