Can I use python for this .. ??

Discussion in 'Python' started by san, May 4, 2006.

  1. san

    san Guest

    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.
     
    san, May 4, 2006
    #1
    1. Advertising

  2. san

    san Guest

    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
     
    san, May 4, 2006
    #2
    1. Advertising

  3. 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
     
    BartlebyScrivener, May 4, 2006
    #3
  4. san

    Petr Jakes Guest

    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
     
    Petr Jakes, May 4, 2006
    #4
  5. san

    san Guest

    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 ..
     
    san, May 4, 2006
    #5
  6. san

    san Guest

    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 .. ??
     
    san, May 4, 2006
    #6
  7. 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
     
    BartlebyScrivener, May 5, 2006
    #7
  8. 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=windows gui automation python&btnG=Google Search

    It looks like pywinauto seems to be a good candidate.

    hth

    --
    mph
     
    Martin P. Hellwig, May 5, 2006
    #8
  9. san

    placid Guest

    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
     
    placid, May 5, 2006
    #9
  10. san

    Terry Reedy Guest

    "placid" <> wrote in message
    news:...
    ..)
    >
    > 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
     
    Terry Reedy, May 5, 2006
    #10
  11. san

    nikie Guest

    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 ;-)
     
    nikie, May 5, 2006
    #11
  12. san

    placid Guest

    Terry Reedy wrote:
    > "placid" <> wrote in message
    > news:...
    > .)
    > >
    > > 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
     
    placid, May 8, 2006
    #12
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?ZGF2aWQ=?=
    Replies:
    1
    Views:
    3,810
    Ken Cox [Microsoft MVP]
    Apr 19, 2005
  2. Chris S
    Replies:
    0
    Views:
    476
    Chris S
    Dec 13, 2006
  3. Robert
    Replies:
    1
    Views:
    332
    Martin v. Löwis
    Apr 16, 2008
  4. Ting Wang
    Replies:
    5
    Views:
    202
    John Bokma
    Oct 6, 2005
  5. robertospara
    Replies:
    14
    Views:
    298
    robertospara
    Dec 10, 2006
Loading...

Share This Page