DonationCoder.com Forum

DonationCoder.com Software => Coding Snacks => Post New Requests Here => Topic started by: artis on February 15, 2007, 08:50 AM

Title: IDEA: Send a window to the Next or Previous Monitor in the same position.
Post by: artis on February 15, 2007, 08:50 AM
I would like to be able to send a window to the the monitor right or left of it's current one with a shortcut.  I would like it to keep it's relative position on the new monitor.

There is a program called MultiMon that has this function but it also does a lot of other things I don't really need.  It uses a small button on the Title Bar just the the left of the minimize button.  This would be ideal but a shortcut would be a good start!

Thanks.  I'm new to AutoHotKey and I tried a script I found on another site but it didn't work.
Title: Re: IDEA: Send a window to the Next or Previous Monitor in the same position.
Post by: jgpaiva on February 15, 2007, 03:33 PM
You have 2 screens that have the same resolution?
Title: Re: IDEA: Send a window to the Next or Previous Monitor in the same position.
Post by: artis on February 15, 2007, 03:38 PM
You have 2 screens that have the same resolution?

Yes I do...17" Monitors...1152 x 864

I don't know if it makes a difference but Monitor1 is on the right and Montor2 is on the left.  BUT Monitor2 is set to be the Primary Monitor (taskbar and icons, and where new programs open) by Windows XP.

Thanks
Title: Re: IDEA: Send a window to the Next or Previous Monitor in the same position.
Post by: jgpaiva on February 15, 2007, 04:25 PM
Ok... The file i attached to this post is supposed to work. But i can't test it, has i don't have 2 monitors (right now).
If you already have ahk already installed, you only have to download it and run it.
Also, if you would please invent a name for it, i'd be pleased :)
(yeah, i have a hard time at finding names for programs :) )
Title: Re: IDEA: Send a window to the Next or Previous Monitor in the same position.
Post by: artis on February 15, 2007, 05:57 PM
How about SnapNextMonitor.ahk?

Oh...I think there is a typo in line 20.  I got an error trying to run the script then I changed ModeWindow to MoveWindow and it worked fine.

It works great for non-maximized windows!  If a window is maximized on the left monitor it will move it to the right one still maximized.  But if a window is maximized on the right monitor it disappears completely instead of moving it to the left one.  I can't seem to figure out where it's going.  I have to right click on the taskbar title and select "restore" to get it back.

Thanks a ton for the help!

Art

Title: Re: IDEA: Send a window to the Next or Previous Monitor in the same position.
Post by: jgpaiva on February 15, 2007, 06:15 PM
Ok, fixed typo and added maximize recognition. (or so i hope ;) )
Title: Re: IDEA: Send a window to the Next or Previous Monitor in the same position.
Post by: artis on February 16, 2007, 08:34 AM
I'm getting the hang of this now.

I went through and simplified a little bit of the code to work on my Monitors the way I wanted.  I also set the Test to be which monitor the MIDPOINT of the active window is on.  That way I can have windows that hang off the ends of the screen if need be.

Lastly I added some code to the top function to make it work no matter which Left/Right placement someone has. Monitor2 can be to the left or the right of Monitor1.

ANYONE INTERESTED IN USING THIS SCRIPT:
   1. It ONLY works with Two(2) Monitors, NOT Three(3) or more
   2. It ONLY works on Right/Left positioned monitors, NOT Top/Bottom
   3. It does NOT matter which monitor is on the left and which is on the right.
   4. The script uses the midpoint of the top edge of the active window to determine which monitor it is on.  Then it moves that window to the other monitor in exactly the same position relative to the monitor edges.
   5. This script has not been tested with two monitors with different resolutions.  It should work as long as the windows are near the top of the screens.
   6. It does move maximized windows (first un-maximizing, then moving, the re-maximizing), but will NOT move windows minimized to the taskbar.  (By un-maximizing and re-maximizing this allows the window to use the full screen when being moved from the monitor with the taskbar to the monitor without the taskbar)
   7. The hotkey is Window+Q

Hope this is as usefull to someone else as it is to me!
Thanks jgpaiva for coding this for us!

Artis

   
Title: Re: IDEA: Send a window to the Next or Previous Monitor in the same position.
Post by: mouser on February 16, 2007, 08:40 AM
nice to see this worked out well  :up: :up:
Title: Re: IDEA: Send a window to the Next or Previous Monitor in the same position.
Post by: jgpaiva on February 16, 2007, 11:57 AM
Cool, Artis!
It looks good ;)
(btw.. the code i posted before didn't work if you had the second screen on the left of the first screen?)
Title: Re: IDEA: Send a window to the Next or Previous Monitor in the same position.
Post by: artis on February 16, 2007, 01:09 PM
Cool, Artis!
It looks good ;)
(btw.. the code i posted before didn't work if you had the second screen on the left of the first screen?)

Oh it worked just fine!  I just didn't know if worked the other way around.  I probably butchered your code but I was just trying to write it so that I could understand what it was doing.
Title: Re: IDEA: Send a window to the Next or Previous Monitor in the same position.
Post by: jgpaiva on February 16, 2007, 05:36 PM
Oh it worked just fine!  I just didn't know if worked the other way around.  I probably butchered your code but I was just trying to write it so that I could understand what it was doing.
;D ;D ;D Ok, no problem!! I was just wondering since i can't test it ;)
Title: Re: IDEA: Send a window to the Next or Previous Monitor in the same position.
Post by: mmdoogie on February 23, 2007, 08:06 PM
jgpaiva, I keep finding your scripts to be ones I can't live without.
artis, your work on this was nice as well.

I took the scripts you two wrote and rewrote them, with some new ideas in mind.
My version purely uses monitor numbers, so those with unique setups will appreciate it,
and it also works with more than 2 monitors.

Ctrl-Alt-Keypad+ moves the window to the next highest number
Ctrl-Alt-Keypad- moves the window to the next lowest number

This is actually the first thing I have written using AHK, its flexibility is pretty amazing.

Enjoy,
--matthew
Title: Re: IDEA: Send a window to the Next or Previous Monitor in the same position.
Post by: jgpaiva on February 24, 2007, 04:26 AM
Good idea, mmdoogie! Having 2 hotkeys allows the program to work even when the person has more than 2 screens, good point ;)
I guess i'll have to give it a go when i have my second monitor  :Thmbsup:
Title: Re: IDEA: Send a window to the Next or Previous Monitor in the same position.
Post by: artis on February 24, 2007, 09:29 AM
mmdoogie... AWESOME!  :Thmbsup:

I was thinking that adjustments like what you did would complete the script while I was working on it.  But I didn't have the skill to pull it off.  Plus I got it working well on my configuration and didn't have much incentive to go very far beyond.  :-[

I'm glad to see you used the midpoint calculations for determining which monitor the window is on.  This is one of my favorite features because I like to "hang" windows off the edges of the monitor.

And it sure does help us new AHKers to stand on the shoulders of GIANTS! (jgpaiva)

Thanks to both of you.
Artis
Title: Re: IDEA: Send a window to the Next or Previous Monitor in the same position.
Post by: lanux128 on January 23, 2008, 08:37 PM
cool script! i can't believe i just found this.. :up:
Title: Re: IDEA: Send a window to the Next or Previous Monitor in the same position.
Post by: 3of0 on April 07, 2009, 08:19 PM
This is pretty slick! :D  Is there maybe a way to easily change the keys used?  I don't have a num pad easily accessable.  Strange gaming keyboard and all. :P

Thanks! :D
Title: Re: IDEA: Send a window to the Next or Previous Monitor in the same position.
Post by: mmdoogie on April 07, 2009, 09:00 PM
Is there maybe a way to easily change the keys used?

There isn't any way from the interface, but its easy enough to edit the script.
Just open up the .ahk file with notepad.

You will see a few lines that look like this:
^!NumpadAdd::

Change that to whatever you want the hotkey to be.
# stands for the windows key, ! is alt, ^ is control, + is shift.
If you want a letter on the keyboard, you can use that directly.
The special keys that have the names are listed here http://www.autohotkey.com/docs/KeyList.htm

--matt

edit: fixed typo as pointed out by tomos
Title: Re: IDEA: Send a window to the Next or Previous Monitor in the same position.
Post by: tomos on April 08, 2009, 03:25 AM
^ stands for the windows key, ! is alt, ^ is control, + is shift.

small mistake there!
# is the Win key

see also
http://www.autohotkey.com/docs/Hotkeys.htm
Title: Re: IDEA: Send a window to the Next or Previous Monitor in the same position.
Post by: skrommel on April 08, 2009, 07:28 PM
 :) Try MaxMove posted at https://www.donationcoder.com/forum/index.php?topic=15072.msg135424#msg135424 (https://www.donationcoder.com/forum/index.php?topic=15072.msg135424#msg135424)

Skrommel