Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Tile Windows Horizontally/ Vertically With Only Left Click


  • Please log in to reply
9 replies to this topic
Info10020
  • Guests
  • Last active:
  • Joined: --
The code:

Menu, Tray, Add, Tile&Horizontally, TileHorizontally
Menu, Tray, Default, Tile&Horizontally

Menu, Tray, Add, Tile&Vertically, TileVertically
Menu, Tray, Add, E&xit, MenuExit

etc...

The default command set the tile horizontally as default action whenever I click it with left mouse, now how to do this: after clicking once, the default will change to tile vertically by the same left click and after clicking again, it will change to tile horizontally? In other words, I only want to use the left mouse to click to change the tiles in stead of right clicking the tray button, which will show the options of tilehorizontally, tilevertically and exit.

Thanks.

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
I'm not sure if this is the best way to do it but assigning a Hotkeycould do the trick:
LButton::Send, {RButton}
(Win 2k/XP/+ required)

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

after clicking once

If you want one click instead of two clicks to activate the default menu item, use:
Menu, Tray, Click 1

the default will change to tile vertically by the same left click and after clicking again, it will change to tile horizontally?

You could just have the script remember what it did last:
TileHorizVert:  ; Called by the default menu item.
if LastActionWasVertical
{
   ; ... do commands to tile horiz.
}
else
{
   ; ... do commands to tile vert.
}
LastActionWasVertical := not LastActionWasVertical  ; Invert
return
You can also change the default item in the menu if you want to have two menu items instead of one:

TileHorizontally:
Menu, Tray, Default, Tile&Vertically
...
return

TileVertically:
Menu, Tray, Default, Tile&Horizontally
....
return

Info10020
  • Guests
  • Last active:
  • Joined: --
Thanks for the help. I post herewith the solution:-

Objective:
To tile the open windows into horizontally or vertically alternately by only left clicking the icon in tray. It's useful if you always hide your taskbar.

First Step:
Create scripts for Tile Windows Horizontally. Copy the bold (new ActiveXObject("Shell.Application")).TileHorizontally() to notepad and save as "TileHorizontally.js" (yes, Include the quotation mark).

Create scripts for Tile Windows Vertically. Copy the bold (new ActiveXObject("Shell.Application")).TileVertically() to notepad and save as "TileVertically.js" (yes, Include the quotation mark).

These are JScript Script File type. Test the script by double-click it. Visit this link http://www.pcworld.c...861,pg,2,00.asp for further details if you need to. Perhaps someone can write them by using AutoHotkey code in stead of JScript.

Second Step:
The AutoHotKey code:-
#Persistent

Menu, Tray, NoStandard  
Menu, Tray, Click, 1 

Menu, Tray, Add, Tile&Horizontally, TileHorizontally
Menu, Tray, Add, Tile&Vertically, TileVertically 
Menu, Tray, Add, E&xit, MenuExit

TileHorizontally:
Menu, Tray, Icon, C:\My Documents\My Icons\Horiz.ico ;Path to your icon.
Menu, Tray, Default, Tile&Vertically 
Run, C:\My Documents\MyAutoHotKey\TileHorizontally.js ;Path to your JScript that created above.
return 

TileVertically:
Menu, Tray, Icon, C:\My Documents\My Icons\Vert.ico ;Path to your icon.
Menu, Tray, Default, Tile&Horizontally
Run C:\My Documents\My AutoHotKey\TileVertically.js ;Path to your JScript that created above.
return 

MenuExit: 
ExitApp

Well, it's just a small program that suits my style. I welcome all comments.

axm85
  • Guests
  • Last active:
  • Joined: --
It worked for me. Thanks for the script. I'm new to AutoHotkey; i've used Linux before and have used various tiling window managers on there, such as Ion and my favorite WMI. I wish a script or program like this could emulate a tiling window manager, such as being able to resize windows tiled beside eachother and have both horizontal and vertical tiling. Is that just impossible on Windows shell?

Shawn

jonny
  • Members
  • 2951 posts
  • Last active: Feb 24 2008 04:22 AM
  • Joined: 13 Nov 2004
You could search for alternative shells, but I doubt there's anything quite like Ion. Also, it's probably possible with AutoHotkey but there may be some overhead involved. Still, it sounds interesting, and I'll look into it later.

RemiK
  • Guests
  • Last active:
  • Joined: --
Hi all,

thanks to the javascripts described above and the code in my autohotkey script:
;tile vertically/horizontally
#v::Run, D:\usr\bin\TileHorizontally.js ;Path to your JScript that created above.
#h::Run D:\usr\bin\TileVertically.js ;Path to your JScript that created above.

I was able to create exactly what I wanted ('cause I don't like to reach for my mouse, and navigate to the menu, open it, click the desired item... [anyways, I don't think it is the purpose of autohotKEY to use the mouse {not that I want to upset anyone}]);
two hotkeys that tile the currenly not-minimized windows.

Thanks!

Regards,

Remi

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
no need for JScript

#v::DllCall( "TileWindows", uInt,0, Int,0, Int,0, Int,0, Int,0 ) ; Tile Vertically
#h::DllCall( "TileWindows", uInt,0, Int,1, Int,0, Int,0, Int,0 ) ; Tile Horizontally

For advanced methods: How to programmatically Tile / Cascade windows?
kWo4Lk1.png

RemiK
  • Guests
  • Last active:
  • Joined: --
That's nice.. and it works :D

I like this autohotkey program xD

Regards,

Remi

marco262
  • Guests
  • Last active:
  • Joined: --
I've managed to put together a script that binds Ctrl+F10 to Tiling Vertically, and Alt+F10 to Tiling Horizontally. If the windows were recently tiled, hitting either of those key combos will Undo the tiling.

LastActionWasTile := false

^F10::
if LastActionWasTile
   PostMessage, 0x111, 416, 0,, ahk_class Shell_TrayWnd ; "Undo Tile"
else
   PostMessage, 0x111, 405, 0,, ahk_class Shell_TrayWnd ; "Tile Vertically"
LastActionWasTile := not LastActionWasTile  ; Invert
return

!F10::
if LastActionWasTile
   PostMessage, 0x111, 416, 0,, ahk_class Shell_TrayWnd ; "Undo Tile"
else
   PostMessage, 0x111, 404, 0,, ahk_class Shell_TrayWnd ; "Tile Horizontally"
LastActionWasTile := not LastActionWasTile  ; Invert
return

Many thanks to Chris for the conditional code, and to SKAN for the code to tile and untile. See more "Magic Numbers" you can use at http://www.autohotke...topic41722.html

Any suggestions for how to possibly call another function from within the key combos, so that I'm not repeating my code, would be helpful, as I'm still an AHK noob.