Can I use python for this .. ??

S

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.
 
S

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
 
B

BartlebyScrivener

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
 
P

Petr Jakes

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
 
S

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 ..
 
S

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 .. ??
 
B

BartlebyScrivener

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
 
M

Martin P. Hellwig

san said:
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=windows+gui+automation+python&btnG=Google+Search

It looks like pywinauto seems to be a good candidate.

hth
 
P

placid

Petr said:
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...
 
T

Terry Reedy

..)
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
 
N

nikie

san said:
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 ;-)
 
P

placid

Terry said:
.)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top