Remember and recall window positions...

Developed or developing a new product in PureBasic? Tell the world about it.
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Remember and recall window positions...

Post by Kale »

Because i like nice tidy desktops i've written a very small utility to help me keep all the server displays (open windows) nice and neat at work. It works nicely and contains a few nice procedures.

To add a window(s) to the list just click 'Add...' then click on the windows titlebar or you can click 'Add all windows' to add the lot! You can also pass the string '-tidy' as a program parameter to just move and resize all previously captured windows or the program parameter '-record' to record new or update exisisting windows without opening the GUI. Click the window button (in the middle of the arrows) to resize the windows to the captured settings too. Click the screenshot to download.

Image

of course, critisism and/or improvements are most welcome. :)
Last edited by Kale on Tue Sep 13, 2005 12:18 am, edited 7 times in total.
--Kale

Image
ebs
Enthusiast
Enthusiast
Posts: 561
Joined: Fri Apr 25, 2003 11:08 pm

Post by ebs »

Kale,

I like it! :D

It took me a minute to figure out how to add a window, but I got it.

One suggestion: set the #PB_ListIcon_FullRowSelect flag on the
Captured Windows ListIcon Gadget. It makes it a lot easier to select
a window name from the list, especially if the name is short.

One really handy addition would be a "Capture All Open Windows"
command and/or button, so you can take a "snapshot" of the user's
desktop without having to add the windows manually. Do you have
code to enumerate all open windows?

Regards,
Eric
techjunkie
Addict
Addict
Posts: 1126
Joined: Wed Oct 15, 2003 12:40 am
Location: Sweden
Contact:

Post by techjunkie »

Yeah! :D I like it too... neat and handy...
Image
(\__/)
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

One really handy addition would be a "Capture All Open Windows"
command and/or button, so you can take a "snapshot" of the user's
desktop without having to add the windows manually. Do you have
code to enumerate all open windows?
Good idea! I'll see if i can find anycode like that around here. :)
--Kale

Image
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Post by Beach »

This is really cool Kale. It would also be nice if you could move all windows out of the way like Apple's OS X does. When you move your mouse to a certain spot on the screen, all of the open window move out of the way so you can see the desktop. Just a thought.
-Beach
ebs
Enthusiast
Enthusiast
Posts: 561
Joined: Fri Apr 25, 2003 11:08 pm

Post by ebs »

Kale,

If you haven't already come up with something, here is a simple procedure to list each window's title and class:

Code: Select all

Procedure ListWindows(Window, Parameter) 
  WindowClass.s = Space(255)
  WindowTitle.s = Space(255)
  GetClassName_(Window, WindowClass, 255)
  GetWindowText_(Window, WindowTitle, 255)
  If WindowTitle
    Debug WindowTitle + "|" + WindowClass
  EndIf
  
  ProcedureReturn #True  
EndProcedure 

EnumWindows_(@ListWindows(), 0)
The hard part will be to determine which are the visible application windows.

Regards,
Eric
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

The hard part will be to determine which are the visible application windows.
No Prob! All done, you can now download an updated version from the post above. :)
--Kale

Image
ebs
Enthusiast
Enthusiast
Posts: 561
Joined: Fri Apr 25, 2003 11:08 pm

Post by ebs »

Kale,

That was fast! This is turning out to be a really useful utility!

I found a problem with "Add All Windows" - it doesn't clear the Window linked list, so you get multiple copies of each window in the list. I suggest clearing the list in the AddAllWindows() procedure, like this:

Code: Select all

;add all visible windows
Procedure AddAllWindows()
  ClearList(Window())
  EnumWindows_(@FilterWindows(), 0)
EndProcedure
One other suggestion: Clear the windows details in the bottom section when a window is deleted from the list.

Regards,
Eric
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

I found a problem with "Add All Windows" - it doesn't clear the Window linked list, so you get multiple copies of each window in the list.
Done. :)
One other suggestion: Clear the windows details in the bottom section when a window is deleted from the list.
Done. :twisted:
I also found a little prob with capturing a minimised window so i just grab the window coords for when it is restored instead of the obscure minimised ones. :wink:
--Kale

Image
ebs
Enthusiast
Enthusiast
Posts: 561
Joined: Fri Apr 25, 2003 11:08 pm

Post by ebs »

Kale,
I also found a little prob with capturing a minimised window so i just grab the window coords for when it is restored instead of the obscure minimised ones.
Would that explain getting coordinates like -32000,-32000? I noticed that while I was experimenting.

If you can stand it, I have another suggestion: a command-line parameter, maybe something like "-record". It would take the snapshot of all open windows, save the file and exit without showing the GUI, similiar to the "-tidy" parameter. That way, the snapshot/tidying could be done just using the command line or shortcuts (no GUI), if desired.

If you want to see the code I came up with, let me know. If you'd prefer to do it yourself, I won't be (too) hurt... :cry:

Regards,
Eric
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

Would that explain getting coordinates like -32000,-32000? I noticed that while I was experimenting.
Yeah thems the ones! :? fixed now :)
If you can stand it, I have another suggestion: a command-line parameter, maybe something like "-record". It would take the snapshot of all open windows, save the file and exit without showing the GUI, similiar to the "-tidy" parameter. That way, the snapshot/tidying could be done just using the command line or shortcuts (no GUI), if desired.
Done. :) Grab the new one above!
If you want to see the code I came up with, let me know.
Sure! :D
If you'd prefer to do it yourself, I won't be (too) hurt... :cry:

he he, feel free to modify it in anyway m8, i always feel like im obliged to make changes especially if its handy functionality which really should of been in there in the first place but i was too lazy. :oops: :lol:
--Kale

Image
MrMat
Enthusiast
Enthusiast
Posts: 762
Joined: Sun Sep 05, 2004 6:27 am
Location: England

Post by MrMat »

This is great! Thanks for sharing :D How about making it optionally minimise unlisted windows?
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

I just noticed i left some debug stuff in that last file :oops: I've now updated the link above :)
How about making it optionally minimise unlisted windows?
How do u mean?
--Kale

Image
MrMat
Enthusiast
Enthusiast
Posts: 762
Joined: Sun Sep 05, 2004 6:27 am
Location: England

Post by MrMat »

Hi Kale,
Kale wrote:How do u mean?
I mean when you click on the "Resize and move" button it will currently resize and move all the windows you've told it to and leave any other windows you happen to have open in their current position. It'd be neat if it would also minimise the other open windows on your desktop, so that the windows visible are just the ones you originally listed. Does that make sense? :?

It's just an idea, not sure if anyone else would find it useful or just me! ;-)

Cheers,
Mat
ebs
Enthusiast
Enthusiast
Posts: 561
Joined: Fri Apr 25, 2003 11:08 pm

Post by ebs »

@Kale,

I thought Mat's idea about minimizing other windows was a good one, so I added that feature to your code. I'd be happy to provide you and/or Mat with a copy of my revised code, but there's a problem. I have made changes to your user interface (removed the Close button and added a checkbox), as well as adding and revising the code.

Since this very handy program is your work, I don't want to go handing out my changed version, unless you say it's OK. If you would like a copy of my changes, just let me know. If you say it's OK for me to send a copy to Mat, I'll do that too. If you'd prefer me to keep my hands off of your code in the future, that's fine - just say so. :wink:

@MrMat,

If you'd like a copy of my code, AND if Kale says it's OK, send me a private message with your e-mail address.

Regards,
Eric
Post Reply