topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Wednesday December 11, 2024, 8:51 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: Send a window to the Next or Previous Monitor in the same position.  (Read 21655 times)

artis

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 6
    • View Profile
    • Donate to Member
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.

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
You have 2 screens that have the same resolution?

artis

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 6
    • View Profile
    • Donate to Member
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

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
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 :) )

artis

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 6
    • View Profile
    • Donate to Member
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


jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Ok, fixed typo and added maximize recognition. (or so i hope ;) )

artis

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 6
    • View Profile
    • Donate to Member
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

   

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
nice to see this worked out well  :up: :up:

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
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?)

artis

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 6
    • View Profile
    • Donate to Member
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.

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
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 ;)

mmdoogie

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 14
    • View Profile
    • My Projects
    • Donate to Member
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

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
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:

artis

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 6
    • View Profile
    • Donate to Member
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

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
cool script! i can't believe i just found this.. :up:

3of0

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 32
    • View Profile
    • Donate to Member
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

mmdoogie

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 14
    • View Profile
    • My Projects
    • Donate to Member
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.autohotke...com/docs/KeyList.htm

--matt

edit: fixed typo as pointed out by tomos
« Last Edit: April 11, 2009, 12:41 AM by mmdoogie »

tomos

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 11,964
    • View Profile
    • Donate to Member
^ stands for the windows key, ! is alt, ^ is control, + is shift.

small mistake there!
# is the Win key

see also
http://www.autohotke...com/docs/Hotkeys.htm
Tom

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member