forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Auto position/size any active window

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code
View previous topic :: View next topic  
Author Message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Jan 11, 2002 10:59 am    Post subject: Auto position/size any active window Reply with quote

-- VDS3 and VDS4 compatible --

Here's a little utility that runs in the taskbar and autosizes any
active window (my IE4 only remembers the size of the original
window, and any subsequent windows are tiny).

I added a few windows for it NOT to resize, such as "Help Topics",
"dsc" files (it kept resizing it's own dsc file while I was testing it. lol),
and a few others. You may want to add or remove some of them,
I used %1 thru %5 for this. It also skips very short windows (to
hopefully avoid resizing message boxes).

*** NOTE: I added a second version below the first that only
resizes windows with strings you DO specify.

It sets the window position as follows:
Y=10, X=0, width=screen width, height=screen height minus 36

I like to open windows down slightly from the top of the screen
so I can access utility icons at the top of my desktop. You may
want to change these settings.

It has a popup menu that allows you to choose either "Monitor" or
"Standby" mode, and the menu shows which mode it's in.

I set the priority to "idle", and it has a timer loop to resume its'
current state (Monitor or Standby) if the user clicks off the popup
menu to close it (prevents it from just waiting for an event).
__________________________________________________________________________________________________________________________
Code:

TITLE "By Mac"
if @winexists("WinPosMonitor")
   INFO Program is running. @tab()
   EXIT
end

OPTION PRIORITY, IDLE
OPTION SCALE, 96
OPTION DECIMALSEP, "."
DIALOG CREATE,"WinPosMonitor",0,0,0,0
  DIALOG ADD,TASKICON,TaskBar,," Window Auto Position "
rem -- No reason to show dialog --

%%height = @diff(@sysinfo(SCREENHEIGHT), 36)
%%width = @sysinfo(SCREENWIDTH)

:> MonitorMENU
:MonitorMENU
  %%status = 1
  REPEAT
    if @winactive()
       %a = @winactive()
       rem -- Strings in Windows we don't want resized --
       %1 = @pos("dsc", %a)
       %2 = @pos("Open", %a)
       %3 = @pos("Save", %a)
       %4 = @pos("Create EXE", %a)
       %5 = @pos("Help Topics", %a)
       if @greater(%1, 0)@greater(%2, 0)@greater(%3, 0)@greater(%4, 0)@greater(%5, 0)
          goto SKIP
       end
       %w = @winpos(%a, W)
       %h = @winpos(%a, H)
       rem -- Try to avoid message boxes --
       if @greater(%h, 150)
          if @both(@not(@equal(%w, %%width)), @not(@equal(%h, %%height)))
             rem -- Final check for window to exist and be active --
             if @winactive(%a)
                WINDOW POSITION,%a,10,0,%%width,%%height
             end
          end
       end
    end
    :SKIP
    WAIT ".5"
  UNTIL @event()
:TaskBarCLICK
  %b = @click(B)
  if @equal(%b, "RIGHT")
     if %%status
        DIALOG POPUP,Standby|> Monitor|Cancel|-|Exit
     else
        DIALOG POPUP,> Standby|Monitor|Cancel|-|Exit
     end
     goto EVLOOP
  end
  goto MonitorMENU

:> StandbyMENU
:StandbyMENU
  %%status = ""
:EVLOOP
  rem -- In case user clicks off of popup menu --
  WAIT EVENT, 3
  goto @event()

:TIMER
:CancelMENU
  if %%status
     goto MonitorMENU
  else
     rem -- Standby mode --
     WAIT EVENT
     goto @event()
  end

:ExitMENU
:CLOSE
  EXIT


OK, here's a version that only resizes windows containing strings
you DO specify ("Internet Explorer" and "Netscape" in this case).

Code:

TITLE "By Mac"
if @winexists("WinPosMonitor")
   INFO Program is running. @tab()
   EXIT
end

OPTION PRIORITY, IDLE
OPTION SCALE, 96
OPTION DECIMALSEP, "."
DIALOG CREATE,"WinPosMonitor",0,0,0,0
  DIALOG ADD,TASKICON,TaskBar,," Window Auto Position "
rem -- No reason to show dialog --

%%height = @diff(@sysinfo(SCREENHEIGHT), 36)
%%width = @sysinfo(SCREENWIDTH)

:> MonitorMENU
:MonitorMENU
  %%status = 1
  REPEAT
    if @winactive()
       %a = @winactive()
       rem -- Don't resize error messages --
       if @greater(@pos("error", %a), 0)
          goto SKIP
       end
       rem -- Strings in Windows we DO want resized --
       %1 = @pos("Internet Explorer", %a)
       %2 = @pos("Netscape", %a)
       if @greater(%1, 0)@greater(%2, 0)
          %w = @winpos(%a, W)
          %h = @winpos(%a, H)
          if @both(@not(@equal(%w, %%width)), @not(@equal(%h, %%height)))
             rem -- Final check for window to exist and be active --
             if @winactive(%a)
                WINDOW POSITION,%a,10,0,%%width,%%height
             end
          end
       end
    end
    :SKIP
    WAIT ".5"
  UNTIL @event()
:TaskBarCLICK
  %b = @click(B)
  if @equal(%b, "RIGHT")
     if %%status
        DIALOG POPUP,Standby|> Monitor|Cancel|-|Exit
     else
        DIALOG POPUP,> Standby|Monitor|Cancel|-|Exit
     end
     goto EVLOOP
  end
  goto MonitorMENU

:> StandbyMENU
:StandbyMENU
  %%status = ""
:EVLOOP
  rem -- In case user clicks off of popup menu --
  WAIT EVENT, 3
  goto @event()

:TIMER
:CancelMENU
  if %%status
     goto MonitorMENU
  else
     rem -- Standby mode --
     WAIT EVENT
     goto @event()
  end

:ExitMENU
:CLOSE
  EXIT


[EDIT]
Added a second version of the program...
Added code (second version) to skip resizing windows
containing the word "error"...

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361


Last edited by Mac on Sun Jan 13, 2002 11:20 am; edited 6 times in total
Back to top
View user's profile Send private message Send e-mail
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Fri Jan 11, 2002 8:55 pm    Post subject: Reply with quote

This works good for new IE windows..but can get annoying for others Smile
I think there is an easier fix for IE though.
Try having only one IE window open, and hitting Restore(between Minimize and Close), then size and position that the way you want it, then close it. Start IE again and maximize the window..all new windows should be the size/position of the one you closed. I wish you could open new windows maximized..but it doesn't seem that you can.

I have seen a couple sites that say hold shift while closing the window and it will save the size/position, but this doesn't seem to work for new windows. You could try it anyway and see if it works for you and let me know.

_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Jan 11, 2002 9:45 pm    Post subject: Reply with quote

SnarlingSheep wrote:

This works good for new IE windows..but can get annoying for others Smile
I think there is an easier fix for IE though.
Try having only one IE window open, and hitting Restore(between Minimize and Close), then size and position that the way you want it, then close it. Start IE again and maximize the window..all new windows should be the size/position of the one you closed. I wish you could open new windows maximized..but it doesn't seem that you can.

Hey Sheep, Smile

That doesn't work on my system. I've tried all kinds of different
solutions for the problem, but no luck. The first window remembers
its' position, and others will if I resize them manually. However,
if I have two or three open and don't open them in the original
order (or if I close and reopen IE), it forgets all of them except
the original window position again.

I can push F11 to maximize the active IE window, but like I said,
I want the top of my desktop accessible.

I put a "standby" mode in the utility so I could disable it when
opening windows that I didn't want maximized (without exiting).
It's not a perfect solution (and others may not even like it), but
so far I'm pretty happy with it. Smile

Cheers, Mac

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Fri Jan 11, 2002 9:54 pm    Post subject: Reply with quote

Seems like even IE 4 saved the Restored window size..maybe not.
Oh well Smile

_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Jan 11, 2002 10:23 pm    Post subject: Reply with quote

Hey Sheep, Smile

I tried it again and it kinda worked for a while, but somewhat
different from what you mentioned. All the windows opened full
screen, but when I closed and re-opened IE, it stopped even
doing that again.

The difference may just be in Win95.

Thanks, Mac

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Fri Jan 11, 2002 10:26 pm    Post subject: Reply with quote

Did you try it on just one window and then closing and re-opening like I said?
_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Jan 11, 2002 10:30 pm    Post subject: Reply with quote

Yep. That's when it maximized all the subsequent windows.
But when I closed them all (including the first one) and
re-opened IE, it stopped again. I didn't want them completely
maximized anyway... Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Fri Jan 11, 2002 10:37 pm    Post subject: Reply with quote

If you closed the window after sizing it..how did you have subsequent windows until you closed and reopened? Smile
I hate IE Wink

_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Jan 11, 2002 10:52 pm    Post subject: Reply with quote

LOL, I did like you said then closed the whole thing.
THEN I reopened IE, THEN opened subsequent
windows. I'm not too crazy about IE either... Smile

I added a second program to the original post,
that ONLY resizes the windows you list ("Internet
Explorer" and "Netscape" in the example)...

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Fri Jan 11, 2002 10:55 pm    Post subject: Reply with quote

LoL, alrighty then Smile
_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Thu Jan 17, 2002 1:09 am    Post subject: Reply with quote

OK, a slightly more streamlined version for "Netscape" and "Internet
Explorer" windows. This one resizes the window if either the width or
height are off.
__________________________________________________________________________________________________________________________
Code:

TITLE "By Mac"
if @winexists("WinPosMonitor")
   INFO Program is running. @tab()
   EXIT
end

OPTION PRIORITY, IDLE
OPTION SCALE, 96
OPTION DECIMALSEP, "."
DIALOG CREATE,"WinPosMonitor",0,0,0,0
  DIALOG ADD,TASKICON,TaskBar,," Window Auto Position "
rem -- No reason to show dialog --

%%height = @diff(@sysinfo(SCREENHEIGHT), 36)
%%width = @sysinfo(SCREENWIDTH)

:ContinueMENU
  REPEAT
    if @winactive()
       %a = @winactive()
       if @greater(@pos("Internet Explorer", %a), 0)@greater(@pos("Netscape", %a), 0)
          rem -- Don't resize error messages --
          if @equal(@pos("error", %a), 0)
             if @not(@equal(@winpos(%a, W), %%width))@not(@equal(@winpos(%a, H), %%height))
                rem -- Final check for window to exist and be active --
                if @winactive(%a)
                   WINDOW POSITION,%a,10,0,%%width,%%height
                end
             end
          end
       end
    end
    WAIT ".5"
  UNTIL @event()
  DIALOG POPUP,Continue|Exit
  %e = @event()
  if %e
     goto %e
  end
  goto ContinueMENU

:ExitMENU
:CLOSE
  EXIT

[EDIT]
Corrected code to continue if popup menu is not clicked on.

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Mon Jan 28, 2002 11:35 pm    Post subject: Reply with quote

I use this all the time and keep tweaking it, so here's one more
that allows some choices where top of browser window is set. It
doesn't resize browser "chat" windows either...
____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Code:

TITLE "By Mac"
if @winexists("WinPosMonitor")
   INFO Program is running. @tab()
   EXIT
end

OPTION PRIORITY, IDLE
OPTION SCALE, 96
OPTION DECIMALSEP, "."
DIALOG CREATE,"WinPosMonitor",0,0,0,0
  DIALOG ADD,TASKICON,TaskBar,," Window Auto Position "
rem -- No reason to show dialog --

%%top = 10

:ContinueMENU
  %%height = @diff(@sysinfo(SCREENHEIGHT), 26)
  %%height = @diff(%%height, %%top)
  %%width = @sysinfo(SCREENWIDTH)
  REPEAT
    if @winactive()
       %a = @winactive()
       if @greater(@pos("Internet Explorer", %a), 0)@greater(@pos("Netscape", %a), 0)
          rem -- Don't resize these windows --
          if @greater(@pos("error", %a), 0)@greater(@pos("chat", %a), 0)
             rem -- Do nothing --
          else
             if @not(@equal(@winpos(%a, W), %%width))@not(@equal(@winpos(%a, H), %%height))@not(@equal(@winpos(%a, T), %%top))
                rem -- Final check for window to exist and be active --
                if @winactive(%a)
                   WINDOW POSITION,%a,%%top,0,%%width,%%height
                end
             end
          end
       end
    end
    WAIT ".5"
  UNTIL @event()
  DIALOG POPUP,Continue|Top 10|Top 50|Top 80|-|Exit
  %e = @event()
  if %e
     goto %e
  end
  goto ContinueMENU

:Top 10MENU
  %%top = 10
  goto ContinueMENU

:Top 50MENU
  %%top = 50
  goto ContinueMENU

:Top 80MENU
  %%top = 80
  goto ContinueMENU

:ExitMENU
:CLOSE
  EXIT

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Tue Jul 30, 2002 5:28 am    Post subject: Reply with quote

I added a popup killer routine that closes windows
without a toolbar. IT ONLY WORKS IN IE. And I have
IE4, so you may have to make adjustments.

The popup menu has options to stop/start the popup
killer routine. It kills without remorse, and ya might
want to get popups to inform ya of PMs etc. at some
sites.

There's also some other stuff I've been adding along,
such as autoclosing IE script error messages.

I also posted the popup killer as a standalone program
that runs in the systray. It's the same routine that I used
here.
__________________________________________________________________________________________________________________________
Code:

TITLE "By Mac"
if @winexists("WinPosMonitor")
   INFO Program is running. @tab()
   EXIT
end
OPTION PRIORITY, IDLE
OPTION SCALE, 96
OPTION DECIMALSEP, "."
DIALOG CREATE,"WinPosMonitor",0,0,0,0
  DIALOG ADD,TASKICON,TaskBar,," Window Auto Position "
rem -- No reason to show dialog --

rem -- WINLIST and Child list for popup killer --
LIST CREATE, 1
LIST CREATE, 2

%%top = 10
%%left = 0
rem -- Toggles popup killer on/off --
%%popup = 1
rem -- For those who renamed the IE title bar in the reg --
%%IEtitle = @REGREAD(CURUSER,Software\Microsoft\Internet Explorer\Main,"Window Title","Internet Explorer")

:ContinueMENU
  %%height = @diff(@sysinfo(SCREENHEIGHT), 26)
  %%height = @diff(%%height, %%top)
  %%width = @sysinfo(SCREENWIDTH)
  %s = ""
  REPEAT
    if @winactive()
       %a = @winactive()
       if @greater(@pos(%%IEtitle, %a), 0)@greater(@pos("Netscape", %a), 0)@greater(@pos("OffByOne", %a), 0)
          rem -- Don't resize these windows --
          if @greater(@pos("error", %a), 0)@greater(@pos("chat", %a), 0)
             rem -- Do nothing --
          else
             if @not(@equal(@winpos(%a, W), %%width))@not(@equal(@winpos(%a, H), %%height))@not(@equal(@winpos(%a, T), %%top))
                rem -- Final check for window to exist and be active --
                if @winactive(%a)
                   WINDOW POSITION,%a,%%top,%%left,%%width,%%height
                   WAIT ".2"
                end
             end
          end

          rem ============== Popup Killer Routine ==============
          if %%popup
             rem -- Update current IE list --
             if @greater(@count(2), 0)
                %x = 0
                REPEAT
                  if @not(@winexists(@item(2, %x)))
                     LIST DELETE, 2
                  end
                %x = @succ(%x)
                UNTIL @equal(%x, @count(2))@greater(%x, @count(2))
             end

             rem -- Check WINLIST (1) against IE list (2) for new IE windows --
             LIST WINLIST, 1
             %x = 0
             REPEAT
               %%window = @item(1, %x)
               if @greater(@pos(%%IEtitle, %%window), 0)
                  %%found = ""
                  %y = 0
                  REPEAT
                    if @equal(@item(2, %y), %%window)
                       %%found = 1
                       %y = @pred(@count(2))
                    end
                    %y = @succ(%y)
                  UNTIL @equal(%y, @count(2))@greater(%y, @count(2))

                  rem -- If new window, close if no toolbar  --
                  if @not(%%found)
                     %%status = @winpos(%%window,S)
                     WINDOW ACTIVATE, %%window
                     WAIT ".2"
                     PARSE "%t;%l", @winpos(%%window,TL)
                     %c = @winclass(@winatpoint(@sum(%l, 35), @sum(%t, 35)))
                     WAIT ".2"
                     if @not(@equal(%c, "ToolbarWindow32"))
                        WINDOW SEND, %%window, @alt(@key(f4))
                        rem -- Check if second attempt is needed --
                        if @winexists(%%window)
                           WAIT ".2"
                           WINDOW SEND, %%window, @alt(@key(f4))
                        end
                     else
                        rem -- Restore to previous status --
                        if @equal(%%status, 1)
                           WINDOW NORMAL, %%window
                        end
                        if @equal(%%status, 2)
                           WINDOW ICONIZE, %%window
                        end
                        if @equal(%%status, 3)
                           WINDOW MAXIMIZE, %%window
                        end
                        LIST ADD, 2, %%window
                     end
                  end
               end
               %x = @succ(%x)
             UNTIL @equal(%x, @count(1))@greater(%x, @count(1))
             rem -- Restore active window --
             if @not(@equal(@winactive(), %a))
                if @winexists(%a)
                   WINDOW ACTIVATE, %a
                   WAIT ".5"
                end
             end
          end
          rem ==================================================

          rem -- Close IE script error window with "yes" --
          if @winexists("Internet Explorer Script Error")
             WINDOW SEND, "Internet Explorer Script Error", @cr()
          end
       end
    end
    WAIT ".1"
  UNTIL @event()
  if %%popup
     DIALOG POPUP,Continue|Top 0|Top 10|Top 50|Top 80|Stop Popup Killer|-|Exit
  else
     DIALOG POPUP,Continue|Top 0|Top 10|Top 50|Top 80|Start Popup Killer|-|Exit
  end
  %e = @event()
  %s = "Top 0MENU Top 10MENU Top 50MENU Top 80MENU ExitMENU CLOSE Stop Popup KillerMENU Start Popup KillerMENU"
  if @greater(@pos(%e, %s), 0)
     goto %e
  end
  goto ContinueMENU

:Top 0MENU
  %%top = 0
  goto ContinueMENU

:Top 10MENU
  %%top = 10
  goto ContinueMENU

:Top 50MENU
  %%top = 50
  goto ContinueMENU

:Top 80MENU
  %%top = 80
  goto ContinueMENU

:Stop Popup KillerMENU
  %%popup = ""
  goto ContinueMENU

:Start Popup KillerMENU
  %%popup = 1
  goto ContinueMENU

:ExitMENU
:CLOSE
  EXIT

[EDIT1] Changed some WAIT times from ".1" to".2" to allow
more time for toolbar checking on faster systems.

[EDIT2] Added code to restore the active window if popup
routine leaves another window active.

[EDIT3] Modified the restore active window code just added.

[EDIT4] Added code to restore windows to their previous status
(normal, minimized, maximized), and checks reg in case user
has renamed IE title bar (Thanks to Dread and Tommy for this).

[EDIT5] Changed popup menu to reflect current popup status
(offers "Stop Popup Killer" if running, "Start Popup Killer" if not).
Another idea from Dread.

[EDIT6] Added one more WAIT ".2" after repositioning window
to allow for reposition before popup kicks in.

Cheers, Mac

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group