473,378 Members | 1,360 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Help me. How to open a new IE window?

Hi

I want python(win32com) to open a new IE window.
Source is:
/******/
import win32com.client
msie = win32com.client.Dispatch("InternetExplorer.Applica tion")
msie.Visible = 1
msie.Naviagte(http://www.python.org)
/******/
The problem is the program always grabs a existed IExplorer window or
Explorer window. It never opens a new window.

Please help me. Thanx
Victor


Jul 18 '05 #1
6 3262
angel wrote:
I want python(win32com) to open a new IE window.
Source is:
/******/
import win32com.client
msie = win32com.client.Dispatch("InternetExplorer.Applica tion")
msie.Visible = 1
msie.Naviagte(http://www.python.org)
/******/
The problem is the program always grabs a existed IExplorer window or
Explorer window. It never opens a new window.


I ran into that same problem. Try this:

msie = win32com.client.DispatchEx('InternetExplorer.Appli cation.1')

It seems to work for me.

-Dave

Jul 18 '05 #2

"angel" <da*******@yahoo.com> wrote in message
news:c7***********@news.f.de.plusline.net...
Hi

I want python(win32com) to open a new IE window.
Source is:
/******/
import win32com.client
msie = win32com.client.Dispatch("InternetExplorer.Applica tion")
msie.Visible = 1
msie.Naviagte(http://www.python.org)
/******/
The problem is the program always grabs a existed IExplorer window or
Explorer window. It never opens a new window.

Please help me. Thanx
Victor

Hi. Perhaps you may want to check out the webbrowser module:
import webbrowser as browser
browser.open("www.python.org", new=True)
OR
browser.open_new(url)

OR
IE = browser.WindowsDefault()
IE.open_new(url)

HTH,
Sean
Jul 18 '05 #3
It's work. Thanx again!
angel

"Dave Brueck" <da**@pythonapocrypha.com>
??????:ma**************************************@py thon.org...
angel wrote:
I want python(win32com) to open a new IE window.
Source is:
/******/
import win32com.client
msie = win32com.client.Dispatch("InternetExplorer.Applica tion")
msie.Visible = 1
msie.Naviagte(http://www.python.org)
/******/
The problem is the program always grabs a existed IExplorer window or
Explorer window. It never opens a new window.


I ran into that same problem. Try this:

msie = win32com.client.DispatchEx('InternetExplorer.Appli cation.1')

It seems to work for me.

-Dave

Jul 18 '05 #4
angel wrote:
Hi

I want python(win32com) to open a new IE window.
Source is:
/******/
import win32com.client
msie = win32com.client.Dispatch("InternetExplorer.Applica tion")
msie.Visible = 1
msie.Naviagte(http://www.python.org)
/******/
The problem is the program always grabs a existed IExplorer window or
Explorer window. It never opens a new window.

Please help me. Thanx
Victor


import webbrowser
webbrowser.open_new("www.python.org")

it will work fine with IE (if IE is the default browser)
Jul 18 '05 #5
Vladimir wrote:
angel wrote:
I want python(win32com) to open a new IE window.
Source is:
/******/
import win32com.client
msie = win32com.client.Dispatch("InternetExplorer.Applica tion")
msie.Visible = 1
msie.Naviagte(http://www.python.org)
/******/
The problem is the program always grabs a existed IExplorer window or
Explorer window. It never opens a new window.


import webbrowser
webbrowser.open_new("www.python.org")

it will work fine with IE (if IE is the default browser)


I guess the OP didn't specify, but the above won't work if you need to control
the browser from then on (which is what I assume he was trying to do by
obtaining an IDispatch pointer to it).

-Dave
Jul 18 '05 #6
"Dave Brueck" <da**@pythonapocrypha.com> wrote in message news:<ma**************************************@pyt hon.org>...
Vladimir wrote:
angel wrote:
I want python(win32com) to open a new IE window.
Source is:
/******/
import win32com.client
msie = win32com.client.Dispatch("InternetExplorer.Applica tion")
msie.Visible = 1
msie.Naviagte(http://www.python.org)
/******/
The problem is the program always grabs a existed IExplorer window or
Explorer window. It never opens a new window.


import webbrowser
webbrowser.open_new("www.python.org")

it will work fine with IE (if IE is the default browser)


I guess the OP didn't specify, but the above won't work if you need to control
the browser from then on (which is what I assume he was trying to do by
obtaining an IDispatch pointer to it).

-Dave


Here is how you do it:

Here is a quick way to do it but it works!
If you want to learn more go to pamie.sourceforge.net
This has a class file that helps you automate I.E.

# DispatchEX allows you to open a new window

from win32com.client import DispatchEx

import time

def wait(ie): # very important!!! you have to wait for each page to load
"Given an IE object, wait until the object is ready for input."
while ie.Busy: time.sleep(0.1)

doc = ie.Document
while doc.ReadyState != 'complete': time.sleep(0.1)
return doc

def ClickLink(ie, mylink):
#hrefs = []
for link in ie.Document.links:
if link is None: break # needed for browser bug

if link.innerText == mylink:
link.Click()
# Here is what you need
ie = DispatchEx('InternetExplorer.Application')
ie.Visible = 1
ie.Navigate ('www.python.org')

# Some extra
wait(ie)# Very Important!
ClickLink(ie,'Search')
#later
#RLM
Jul 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: fabien | last post by:
Hi, I am writing a POV-RAY editor with Python using either QT or GTK as GUI 'wrapper'. ( I am still trying both ) * * * * PYGTK * * * * I have downloaded PygtkScintilla-1.99.5. There is a...
3
by: Steve | last post by:
Hi, I have a nice little script that works well displaying images on my website. It's a script where if you clik a thumbnail image a pop up window opens that contains a larger version of the same...
5
by: TrvlOrm | last post by:
Can any one please help me...I am new to JavaScript and I have been struggling with this code for days now and can't figure it out. I would like to get the Buttons to correspond with the action...
1
by: - Dazed | last post by:
The following works well while using NS or IE but not Opera. In Opera, a blank window is opened. Anyone have a suggestion on what to change to make it work in all three? Thanks for any and all...
1
by: Medical Watch | last post by:
Can anyone help me on this: I want to be able to open my paypal "view shopping cart" window with. window.open(url, cartid,window attrb) but it gets blocked by the popup blockers. window size is...
2
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at...
1
by: bucrepus | last post by:
I know response.redirect doesn't open a new page. I have read many posts on how to fix this but I can't get the first one to work. Please help.. I have tried on 2 diff dev machines with no success...
1
by: ipellew | last post by:
Hi; I open another browser window for help. It stays open untill I press help on my main web window again to close this help. If I "reload" the main window with this help page open in the...
5
by: althafexcel | last post by:
hi everyone Im trying to include an external js in my aspx page under the head tag, it doesn't load or it displays an object expected error whenver the function from the .js is called. Actually...
7
by: gubbachchi | last post by:
Hi all, In my application I need to display the data fetched from mysql database after the user selects date from javascript calender. I have written the code in which after the user selects the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.