470,841 Members | 948 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,841 developers. It's quick & easy.

Can I use python for this .. ??

san
Hi

I am using windows xp and have installed python and win32. I am
familiar with basic Python. I wanted to control some of the
applications via python script.

I would like to write a python script to say:
1. Open firefox and log on to gmail
2. Another firefox window to visit slickdeals
3. Open winamp and tune in to a shoutcast station
4. Open groupwise ...
etc ..

These are the task I do every day whenever I log on my computer .. it
just seems repetitive and hence probably can be coded in python.

Can I do this in python? Where do I find the COM objects/interfaces for
all these different programs? Are there any sample codes ?

Thanks.
Santosh.

May 4 '06 #1
11 1445
san
btw i got the firefox to open and access some webpage and winamp
running ..

code below
----------
import os
import os.path
import subprocess

# Web pages
ffox_exe = r'C:\Program Files\Mozilla Firefox\firefox.exe'
assert os.path.exists(ffox_exe)
# open gmail
url = "http://www.gmail.com"
child = subprocess.Popen( (ffox_exe, url), executable = ffox_exe)
rc = child.wait()

# Winamp
wamp_exe = r'C:\Program Files\Winamp\winamp.exe'
assert os.path.exists(wamp_exe)
url = "http://64.236.34.97:80/stream/1040"
child = subprocess.Popen( (wamp_exe, url), executable = wamp_exe)

------------

now is there anyway i can enter user name and password and then click
okay .. (not for gmail but for other similar webpages which require
loggin) .. ??

how to open pages in tabs .. ??

San

May 4 '06 #2
For starters, you need the os and webbrowser modules

import os
import webbrowser

webbrowser.open("http://mail.google.com/mail")

# need to know the shell keyword for starting the app
os.system('start ' + 'Winword')

# the equivalent of double-clicking on the doc or file
os.startfile("c:/MyFiles/MyTextFile.txt")

If you actually want to log onto password-protected sites it gets
gnarly fast (beyond me). You can read about by perusing the urllib2
module or search this list at groups.google.com/group/comp.lang.python

Hope this helps.

rick

May 4 '06 #3
Why using Python?
What about?
1. Open Power Options in Control Panel. (Click Start, click Control
Panel, and then double-click Power Options.)
2.Click the Hibernate tab, select the Enable hibernate support check
box, and then click Apply.
(If the Hibernate tab is unavailable, your computer does not support
this feature.)

then:
1: Click Start and Shut Down,
2: Point the standby button and maintain the shift key pushed,
3: A new hibernation button appears: click it while still holding the
shift key: voila your PC will hibernate (it mens computer will save
your current setting and will switch off).

Petr Jakes

May 4 '06 #4
san
Petr I dont want hibernation .. its more like starting a list of
programs when i want to have fun time on my pc...

but thanx for ur reply ..

May 4 '06 #5
san
Rick

Thanks for your reply .. didnt quite get your point in loggin into
password protected site.
Will try to seach this group for more ..

Still looking for tab browsing and logging in password protected site
...

can i use ctype or something like that .. some modute that will
introduce key strokes .. so that i can do "username" "tab" "password"
"enter" so that i can log in .. ??

May 4 '06 #6
san,

Take a look at this thread which features some smart and helpful people
and good links.

http://tinyurl.com/ggn5e

I'm wagering you'll make more sense of it than I did. I have my hands
full just making my way through tutorials and books at the moment.

rick

May 4 '06 #7
san wrote:
Hi

I am using windows xp and have installed python and win32. I am
familiar with basic Python. I wanted to control some of the
applications via python script.

I would like to write a python script to say:
1. Open firefox and log on to gmail
2. Another firefox window to visit slickdeals
3. Open winamp and tune in to a shoutcast station
4. Open groupwise ...
etc ..

These are the task I do every day whenever I log on my computer .. it
just seems repetitive and hence probably can be coded in python.

Can I do this in python? Where do I find the COM objects/interfaces for
all these different programs? Are there any sample codes ?

Thanks.
Santosh.


What you want looks like a way to automate the windows gui using python.
Since I never done this myself I gave google a try with this query:
http://www.google.com/search?hl=en&q...=Google+Search

It looks like pywinauto seems to be a good candidate.

hth

--
mph
May 4 '06 #8

Petr Jakes wrote:
Why using Python?
What about?
1. Open Power Options in Control Panel. (Click Start, click Control
Panel, and then double-click Power Options.)
2.Click the Hibernate tab, select the Enable hibernate support check
box, and then click Apply.
(If the Hibernate tab is unavailable, your computer does not support
this feature.)
When you hibernate/boot up/hibernate for a long time without a clean
reboot, Windows becomes unstable...


then:
1: Click Start and Shut Down,
2: Point the standby button and maintain the shift key pushed,
3: A new hibernation button appears: click it while still holding the
shift key: voila your PC will hibernate (it mens computer will save
your current setting and will switch off).

Petr Jakes


May 5 '06 #9

"placid" <Bu****@gmail.com> wrote in message
news:11*********************@y43g2000cwc.googlegro ups.com...
..)

When you hibernate/boot up/hibernate for a long time without a clean
reboot, Windows becomes unstable...


This seems to depend on the system. I have gone at least a week, maybe
two, with nightly hibernations and no problems. Maybe you meant much
longer than that. But installs and updates often require reboots anyway.

tjr

May 5 '06 #10
san wrote:
Hi

I am using windows xp and have installed python and win32. I am
familiar with basic Python. I wanted to control some of the
applications via python script.

I would like to write a python script to say:
1. Open firefox and log on to gmail
2. Another firefox window to visit slickdeals
3. Open winamp and tune in to a shoutcast station
4. Open groupwise ...
etc ..

These are the task I do every day whenever I log on my computer .. it
just seems repetitive and hence probably can be coded in python.

Can I do this in python? Where do I find the COM objects/interfaces for
all these different programs? Are there any sample codes ?


I just googled for "iTunes com python", there are lots of samples. If
you can't find any, or want to find out about an applications
interfaces yourself, you can sill use MakePy to find out what com
interfaces are installed on your computer, and simply use the "dir" and
"help" commands in the interactive console on those interfaces to find
out what they do. (There are other tools to explore COM interfaces,
like OleView, but if you're familiar with Python already, using
dir/help is probably going to be easier)
Reading Mark Hammond's excellent book (or at least the sample chapter
on automation) wouldn't hurt either ;-)

May 5 '06 #11

Terry Reedy wrote:
"placid" <Bu****@gmail.com> wrote in message
news:11*********************@y43g2000cwc.googlegro ups.com...
.)

When you hibernate/boot up/hibernate for a long time without a clean
reboot, Windows becomes unstable...
This seems to depend on the system. I have gone at least a week, maybe
two, with nightly hibernations and no problems. Maybe you meant much
longer than that. But installs and updates often require reboots anyway.


well, on my laptop its seems that if i hibernate more then a week, it
becomes unstable

tjr


May 7 '06 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Olaf Meyer | last post: by
reply views Thread by Kurt B. Kaiser | last post: by
1 post views Thread by Jerald | last post: by
reply views Thread by Kurt B. Kaiser | last post: by
reply views Thread by Kurt B. Kaiser | last post: by
reply views Thread by Kurt B. Kaiser | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.