|
-
Sep 24th, 2006, 03:26 PM
#1
[RESOLVED] Open an IE Window with a give size and position
Is it possible to create some sort of script that when used as a shortcut on my desktop would open a new IE window of a given size and postition (both constant) for a given site (always the same)?
-
Sep 24th, 2006, 03:37 PM
#2
Re: Open an IE Window with a give size and position
You could do it with a small vb program using some APIs'. Would that be too much?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 24th, 2006, 04:10 PM
#3
Re: Open an IE Window with a give size and position
No, but I wouldn't know how.
-
Sep 24th, 2006, 04:33 PM
#4
Re: Open an IE Window with a give size and position
I don't have VB right now. But it will be something like this,
(typing freehand, so this may not even compile. )
VB Code:
' Add a reference to Microsoft HTML Object Library
Dim IE as InternetExplorer 'or as object - if you want to keep it lite and don't add the reference
Set IE = New InternetExplorer
' or Set IE = CreateObject("InternetExplorer.Application")
With IE
.Top = 100 ' check if the propery names are correct
.Left = 200
.Width = 1000
.Height = 500
.Visible = True
.Navigate2 "http://www.vbforums.com"
End With
-
Sep 24th, 2006, 04:41 PM
#5
Re: Open an IE Window with a give size and position
Why bother so much when it could be done using simple Javascript.
HTML Code:
<html>
<head>
<script type="text/javascript">
function somefunc()
{
top.resizeTo(800,600)
window.navigate('http://www.google.com');
}
</script>
</head>
<body onLoad="somefunc()"/>
</html>
Save the text as HTML on desktop, Dbl-click it to see the effect.
You can also use Top property of JS to set your browser's Top property. Just give me a minute to check it.
-
Sep 24th, 2006, 04:46 PM
#6
Re: Open an IE Window with a give size and position
Or,
Create a html file on your desktop with following code.
HTML Code:
<html>
<body bgcolor="#FFFFFF">
<script language="JavaScript">
<!--
window.moveTo(100,50);
window.resizeTo(300,400);
window.location.href = "http://www.google.com";
-->
</script>
</body>
</html>
edit:
Ahhhhh ! I'm too slow.
-
Sep 24th, 2006, 04:47 PM
#7
Re: Open an IE Window with a give size and position
Here the whole code, and sorry, it was moveTo function and not Top property.
HTML Code:
<html>
<head>
<script type="text/javascript">
function somefunc()
{
window.moveTo(100,100)
window.resizeTo(800,600)
window.navigate('http://www.google.com');
}
</script>
</head>
<body onLoad="somefunc()"/>
</html>
Lightweigt and better than VB crap.
-
Sep 24th, 2006, 04:53 PM
#8
Re: Open an IE Window with a give size and position
...but as the HTML file will open in the default browser,
If you specifically need IE, better create a link to IE and pass the file as argument.
-
Sep 24th, 2006, 05:04 PM
#9
Re: Open an IE Window with a give size and position
 Originally Posted by Harsh Gupta
Here the whole code, and sorry, it was moveTo function and not Top property.
HTML Code:
<html>
<head>
<script type="text/javascript">
function somefunc()
{
window.moveTo(100,100)
window.resizeTo(800,600)
window.navigate('http://www.google.com');
}
</script>
</head>
<body onLoad="somefunc()"/>
</html>
Lightweigt and better than VB crap.
I tried it and IE gives me an "To help protect your security Internet Explorer has restricted active content that could access your computer...." It lets me manually accept the risk but is there any way to avoid the message altogether?
-
Sep 24th, 2006, 05:08 PM
#10
Re: Open an IE Window with a give size and position
May be you have High security enabled ?
-
Sep 24th, 2006, 05:09 PM
#11
Re: Open an IE Window with a give size and position
Too much trouble to use all apis but this is a good mix. Takem script from iPrank.
Note: If running in IE SP-2 you may get the active content blocked toolbar notification. To will have to click to allow the javascript to run.
VB Code:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Const SW_SHOWNORMAL As Long = 1
Private Sub Main()
ShellExecute 0&, "Open", "C:\Program Files\Internet Explorer\IEXPLORE.EXE", "C:\martin.htm", "C:\", SW_SHOWNORMAL
End Sub
'File contents:
<html>
<body bgcolor="#FFFFFF">
<script language="JavaScript">
<!--
window.moveTo(100,50);
window.resizeTo(300,400);
window.location.href = "http://vbforums.com";
-->
</script>
</body>
</html>
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 24th, 2006, 05:11 PM
#12
Re: Open an IE Window with a give size and position
 Originally Posted by Harsh Gupta
Here the whole code, and sorry, it was moveTo function and not Top property.
HTML Code:
<html>
<head>
<script type="text/javascript">
function somefunc()
{
window.moveTo(100,100)
window.resizeTo(800,600)
window.navigate('http://www.google.com');
}
</script>
</head>
<body onLoad="somefunc()"/>
</html>
Lightweigt and better than VB crap.
I thought I could use this but apparently not since it only worked the first time I tried it. After that I tried experimenting with the 100, 100 with no effect and as a matter of fact when I changed it back to 100,100 it opened IE full screen!
-
Sep 24th, 2006, 05:15 PM
#13
Re: Open an IE Window with a give size and position
@RobDog
You don't need an exe. Just create a shortcut to IE passing the file as argument (post#8)
Code:
"I:\Program Files\Internet Explorer\IEXPLORE.EXE" "C:\Martin.htm"
Last edited by iPrank; Sep 24th, 2006 at 05:22 PM.
-
Sep 24th, 2006, 05:16 PM
#14
Re: Open an IE Window with a give size and position
 Originally Posted by MartinLiss
I thought I could use this but apparently not since it only worked the first time I tried it. After that I tried experimenting with the 100, 100 with no effect and as a matter of fact when I changed it back to 100,100 it opened IE full screen!
I don't know, but I posted that code after checking it. I tried different values for moveTo and resizeTo and it worked on my PC without failing.
-
Sep 24th, 2006, 05:19 PM
#15
Re: Open an IE Window with a give size and position
Yes, thats where I referenced your file code from but you would have to create a shortcut to the htm file but that wouldnt guarentee that it be opened in IE if its not the default browser.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 24th, 2006, 05:33 PM
#16
Re: Open an IE Window with a give size and position
This works without any scripting errors.
The hard way.... 
VB Code:
Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type WINDOWPLACEMENT
Length As Long
flags As Long
showCmd As Long
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type
Private Declare Function SetWindowPlacement Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByRef lpwndpl As WINDOWPLACEMENT) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Const SW_SHOWNORMAL As Long = 1
Private Sub Main()
On Error GoTo MyError
Dim lRet As Long
Dim wPlace As WINDOWPLACEMENT
Dim rRect As RECT
lRet = Shell("C:\Program Files\Internet Explorer\IEXPLORE.EXE", vbNormalFocus)
Do While lRet = 0
lRet = FindWindow("IEFrame", "VBForums - Visual Basic and VB .NET Discussions and More! - Microsoft Internet Explorer")
DoEvents
Loop
wPlace.Length = Len(wPlace)
wPlace.showCmd = SW_SHOWNORMAL
rRect.Left = 0
rRect.Top = 0
rRect.Right = (Screen.Width / Screen.TwipsPerPixelX) / 2
rRect.Bottom = (Screen.Height / Screen.TwipsPerPixelY) / 2
wPlace.rcNormalPosition = rRect
lRet = SetWindowPlacement(lRet, wPlace)
Exit Sub
MyError:
MsgBox Err.Number & " - " & Err.Description
End Sub
Last edited by RobDog888; Sep 24th, 2006 at 05:42 PM.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 24th, 2006, 05:36 PM
#17
Re: Open an IE Window with a give size and position
 Originally Posted by RobDog888
This works without any scripting errors.
The hard way....
VB Code:
Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type WINDOWPLACEMENT
Length As Long
flags As Long
showCmd As Long
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type
Private Declare Function SetWindowPlacement Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByRef lpwndpl As WINDOWPLACEMENT) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Const SW_SHOWNORMAL As Long = 1
Private Sub Main()
On Error GoTo MyError
Dim lRet As Long
Dim wPlace As WINDOWPLACEMENT
Dim rRect As RECT
lRet = Shell("C:\Program Files\Internet Explorer\IEXPLORE.EXE", vbNormalFocus)
Do While lRet = 0
lRet = FindWindow("IEFrame", "VBForums - Visual Basic and VB .NET Discussions and More! - Microsoft Internet Explorer")
DoEvents
Loop
wPlace.Length = Len(wPlace)
wPlace.showCmd = SW_SHOWNORMAL
rRect.Left = 0
rRect.Top = 0
rRect.Right = 1000
rRect.Bottom = 1000
wPlace.rcNormalPosition = rRect
lRet = SetWindowPlacement(lRet, wPlace)
Exit Sub
MyError:
MsgBox Err.Number & " - " & Err.Description
End Sub
I'll try that soon.
-
Sep 24th, 2006, 05:46 PM
#18
Re: Open an IE Window with a give size and position
Bah! Had some code missing as I had several methods applied in the temp project. Here is the fully working code.
Place in a standard module and change the window title to what ever site you want.
VB Code:
Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type WINDOWPLACEMENT
Length As Long
flags As Long
showCmd As Long
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type
Private Declare Function SetWindowPlacement Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByRef lpwndpl As WINDOWPLACEMENT) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SetActiveWindow Lib "user32.dll" ( _
ByVal hwnd As Long) As Long
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMINIMIZED As Long = 2
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Sub Main()
On Error GoTo MyError
Dim lRet As Long
Dim lRet2 As Long
Dim wPlace As WINDOWPLACEMENT
Dim rRect As RECT
Shell "C:\Program Files\Internet Explorer\IEXPLORE.EXE", vbNormalFocus
Do While lRet = 0
lRet = FindWindow("IEFrame", "VBForums - Visual Basic and VB .NET Discussions and More! - Microsoft Internet Explorer")
Loop
wPlace.Length = Len(wPlace)
wPlace.showCmd = SW_SHOWNORMAL
rRect.Left = 0
rRect.Top = 0
rRect.Right = (Screen.Width / Screen.TwipsPerPixelX) / 2
rRect.Bottom = (Screen.Height / Screen.TwipsPerPixelY) / 2
wPlace.rcNormalPosition = rRect
lRet2 = SetWindowPlacement(lRet, wPlace)
SetActiveWindow lRet
Exit Sub
MyError:
MsgBox Err.Number & " - " & Err.Description
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 24th, 2006, 06:31 PM
#19
Re: Open an IE Window with a give size and position
Rob that also opens my default home page and puts the target website behind it. Is there a way to prevent that, preferabbly by not opening the default home page?
-
Sep 24th, 2006, 06:34 PM
#20
Re: Open an IE Window with a give size and position
Try changing your shell line of code to this...
Pass the site as a parameter.
VB Code:
Shell "C:\Program Files\Internet Explorer\IEXPLORE.EXE [b]http://vbforums.com[/b]", vbNormalFocus
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 24th, 2006, 07:04 PM
#21
Re: Open an IE Window with a give size and position
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|