Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

automatically resize a window ? (xp)

459 views
Skip to first unread message

Mad Scientist Jr

unread,
Nov 30, 2005, 10:03:40 AM11/30/05
to
I need to automatically size all open and non-mimized windows
(specifically Explorer folder navigation) to the specified height/width
(in twips or whatever unit). Also maybe include a function that reports
the height/width in twips or whatever of the topmost open non-mimized
window. Any idea how to do this from code in either vb.net, vb6,
vbscript...

Karl E. Peterson

unread,
Nov 30, 2005, 12:50:54 PM11/30/05
to

Lots of ideas. Basically, you'd call EnumWindows, test IsIconic/IsZoomed,
call ShowWindow(SW_RESTORE) if maximized, call MoveWindow or SetWindowPos as
desired. GetWindowRect will give you current coords, and
GetForegroundWindow will tell you what's in front.

None of these suggestions will fly in vbscript, though, and you're otherwise
posting to ClassicVB groups so don't expect much in the VFred realm either.

HTH!
--
Working without a .NET?
http://classicvb.org/


Mad Scientist Jr

unread,
Nov 30, 2005, 1:16:23 PM11/30/05
to
Thanks for your reply - that is definitely helpful. I will have to do
some research on how to use those windows methods (EnumWindows etc) -
if you can give a couple concrete examples that would be great but I
can look them up.

PS

I am looking for something to do something like this

1. user minimizes all windows except the one you want the size of

2. user runs "Get Size" utility, which has code like:
myHeight = fnGetHeightOfTopWindow
myWidth = fnGetWidthOfTopWindow
MsgBox "height=" & myheight & vbcrlf & "width=" & mywidth

3. user minimizes all windows except the ones you want resized

4. user runs "Set size" utility - it prompts for height/width (or gets
them from a prefs file), you type the numbers, click OK, and it sets
the height/width of all open windows to
that

Karl E. Peterson

unread,
Nov 30, 2005, 1:51:36 PM11/30/05
to
Mad Scientist Jr wrote:
> Thanks for your reply - that is definitely helpful. I will have to do
> some research on how to use those windows methods (EnumWindows etc) -
> if you can give a couple concrete examples that would be great but I
> can look them up.

Here ya go: http://vb.mvps.org/samples/apixref.asp

(Become one with Control-F!)

mayayana

unread,
Nov 30, 2005, 2:00:56 PM11/30/05
to
If you just need this for Explorer folders you
can use VBScript with the Shell.Application
object. Shell.Application is what MSDN refers
to as the "Shell Object". It's the functionality
in SHDOC401.dll that provides Active Desktop
operations.
Shell.app has a Windows collection, which is
all open folder windows. Each item in the
collection is actually an IE object, as opposed
to a file system folder object. There is a method
to minimize all folders and you can treat each item
as an InternetExplorer.Application object. For instance,
you can close all folders by looping through and
using: item(index).Quit

The following script will resize all folders to 400 x 400
and line them up in a stepdown fashion from the
upper left of the screen:

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

Dim shl, wins, i, sl, Wid, Ht, Top, Left
Set shl = CreateObject("Shell.Application")
Set wins = shl.windows

Top = 0
Left = 0
Wid = 400
Ht = 400
For i = 0 to wins.count - 1
sl = wins.item(i).Left
If sl < 2900 Then '--minmized window returns 3000 in Win9x, 32000
in WinNT.
With wins.item(i)
.Left = Left
.Top = Top
.Width = Wid
.Height = Ht
End With
Top = Top + 100
Left = Left + 100
End If
Next

Set wins = Nothing
Set shl = Nothing


--
mayaya...@mindXXspring.com
(Remove Xs for return email.)
Mad Scientist Jr <usenet_...@yahoo.com> wrote in message
news:1133374583.0...@g14g2000cwa.googlegroups.com...

ramki...@gmail.com

unread,
Nov 22, 2012, 9:14:57 AM11/22/12
to
Hi Mayayana,

I really like your code for explorer resizing to top left corner.

Do you have a similar code for mouse clicking at 500,200 position on the sc=
reen OR if i have created an Internet Explorer object, how do i click within the webpage using vbscript at a particular x, y (pixel position) or twips?

Please let me know.
Thanks.
Ram

Mayayana

unread,
Nov 23, 2012, 3:02:09 PM11/23/12
to
Your posting to a discussion from 7 years ago!
Please get a decent newsreader and stop using
Google Groups. It'll make life easier for you *and*
for everyone else.

See document.elementFromPoint to get the object
at a location in a webpage. Most elements then have
a click method. For more info. you may want to get
a copy of the IE document object model docs.

--
--
<ramki...@gmail.com> wrote in message
news:6eb3eff7-06a8-4968...@googlegroups.com...
0 new messages