Author |
Topic |
|
Rob
USA
2615 Posts |
Posted - 02/28/2012 : 19:47:31
|
Ideally, you would select a sweeping gesture, like I used X to test this script. X starts on the left and ends on the right, ensuring both the start and end window can be landed on during the gesture. Where this falls short is when you have two windows open (one maximized in front of you) and you just want to tile both, as with this script, both windows have to be in view, so the gesture start/ends on them both.
Honestly, you could even tweak this to handle the other scenario. Get the window in the foreground, then minimize it and get the window below, then restore the first and the core of this script would take care of the positioning.
NOTE: Prior to version 1.7.3, the action help for acSetWindowSize is wrong, it doesn't accept left and top. I've updated the Help on the website and will include the updated local files in the next release. (I decided to leave that up to acMoveWindow but never updated the files)
Lua Script: (everything below is fine, lines starting with "--" are comments which the Lua engine will ignore)
--Get the window below where the gesture began local hFirstWindow = acGetOwnerWindowByPoint(gsx, gsy)
--Get the window below where the gesture ended local hSecondWindow = acGetOwnerWindowByPoint(gex, gey)
--Get the screen dimensions, work area only for the monitor where the gesture began local hScreen = acGetMonitorFromPoint(gsx, gsy) local iScreenRight = acGetMonitorRight(hScreen, 1) local iScreenLeft = acGetMonitorLeft(hScreen, 1) local iScreenWidth = iScreenRight - iScreenLeft local iScreenBottom = acGetMonitorBottom(hScreen, 1) local iScreenTop = acGetMonitorTop(hScreen, 1) local iScreenHeight = iScreenBottom - iScreenTop
--Restore both windows (in case either are Maximized) acRestoreWindow(hFirstWindow, 0, 0) acRestoreWindow(hSecondWindow, 0, 0)
--Move them into position acMoveWindow(hFirstWindow, 0, 0, iScreenLeft, iScreenTop) acMoveWindow(hSecondWindow, 0, 0, iScreenLeft+(iScreenWidth/2), iScreenTop)
--Size them accordingly acSetWindowSize(hFirstWindow, 0, 0, iScreenWidth/2, iScreenHeight) acSetWindowSize(hSecondWindow, 0, 0, iScreenWidth/2, iScreenHeight) |
|
Rob
USA
2615 Posts |
Posted - 02/28/2012 : 20:00:59
|
Don't forget about global variables. You could actually make this a two-part action where you draw on the first window, to store it. Then draw on the second window and it would tile those two:
Lua Script:
--If the first window hasn't been selected, store it and wait for the gesture to fire again (which would be for the second window) if hFirstWindow == nil then
--Get the window below where the gesture began hFirstWindow = acGetOwnerWindowByPoint(gsx, gsy) else
--The first window has already been selected, so go ahead and do the tiling and clear the hFirstWindow variable
--Get the window below where the gesture began local hSecondWindow = acGetOwnerWindowByPoint(gsx, gsy)
--Get the screen dimensions, work area only for the monitor where the gesture began local hScreen = acGetMonitorFromPoint(gsx, gsy) local iScreenRight = acGetMonitorRight(hScreen, 1) local iScreenLeft = acGetMonitorLeft(hScreen, 1) local iScreenWidth = iScreenRight - iScreenLeft local iScreenBottom = acGetMonitorBottom(hScreen, 1) local iScreenTop = acGetMonitorTop(hScreen, 1) local iScreenHeight = iScreenBottom - iScreenTop
--Restore both windows (in case either are Maximized) acRestoreWindow(hFirstWindow, 0, 0) acRestoreWindow(hSecondWindow, 0, 0)
--Move them into position acMoveWindow(hFirstWindow, 0, 0, iScreenLeft, iScreenTop) acMoveWindow(hSecondWindow, 0, 0, iScreenLeft+(iScreenWidth/2), iScreenTop) --Size them accordingly acSetWindowSize(hFirstWindow, 0, 0, iScreenWidth/2, iScreenHeight) acSetWindowSize(hSecondWindow, 0, 0, iScreenWidth/2, iScreenHeight) hFirstWindow = nil end
|
|
|
Edward Dablin
17 Posts |
Posted - 11/20/2012 : 15:29:47
|
Hi this looks very useful but how do I get it to work? |
|
|
Rob
USA
2615 Posts |
Posted - 11/20/2012 : 21:26:23
|
I just confirmed it's still working, to be sure =)
So I just pasted the code below into the Lua Script and made the gesture be the X. Then, I started the gesture on Notepad, drew the gesture, and ended on the Paint window. Then both windows were tiled, side by side covering the whole screen.
--Get the window below where the gesture began
local hFirstWindow = acGetOwnerWindowByPoint(gsx, gsy)
--Get the window below where the gesture ended
local hSecondWindow = acGetOwnerWindowByPoint(gex, gey)
--Get the screen dimensions, work area only for the monitor where the gesture began
local hScreen = acGetMonitorFromPoint(gsx, gsy)
local iScreenRight = acGetMonitorRight(hScreen, 1)
local iScreenLeft = acGetMonitorLeft(hScreen, 1)
local iScreenWidth = iScreenRight - iScreenLeft
local iScreenBottom = acGetMonitorBottom(hScreen, 1)
local iScreenTop = acGetMonitorTop(hScreen, 1)
local iScreenHeight = iScreenBottom - iScreenTop
--Restore both windows (in case either are Maximized)
acRestoreWindow(hFirstWindow, 0, 0)
acRestoreWindow(hSecondWindow, 0, 0)
--Move them into position
acMoveWindow(hFirstWindow, 0, 0, iScreenLeft, iScreenTop)
acMoveWindow(hSecondWindow, 0, 0, iScreenLeft+(iScreenWidth/2), iScreenTop)
--Size them accordingly
acSetWindowSize(hFirstWindow, 0, 0, iScreenWidth/2, iScreenHeight)
acSetWindowSize(hSecondWindow, 0, 0, iScreenWidth/2, iScreenHeight) |
|
|
Edward Dablin
17 Posts |
Posted - 11/21/2012 : 18:01:13
|
Works this is amazing. Your program is one of the best productivity programs I have, if no the best. Only discovered it this week! |
|
|
Edward Dablin
17 Posts |
Posted - 11/21/2012 : 18:03:04
|
I created a Lua scripts for snapping activated window to left and right:
acSendKeys("@{Right}")
&
acSendKeys("@{Left}")
I might enhance it with your positing code above so it move the one where my mouse is rather than the active one =) |
|
|
Rob
USA
2615 Posts |
Posted - 11/21/2012 : 18:06:00
|
I'm glad to hear! |
|
|
Edward Dablin
17 Posts |
Posted - 11/21/2012 : 18:11:46
|
Would like to suggest that unactivated actions are greyed. There are so many action I don't use but dont want to delet that I cant find the ones I do use easily.
So why doesn't this work. Its moving the active window rather than the one I started at?:
--Get the window below where the gesture began hFirstWindow = acGetOwnerWindowByPoint(gsx, gsy)
acSendKeys("@{Left}") |
|
|
Rob
USA
2615 Posts |
Posted - 11/21/2012 : 18:16:54
|
The first line is only getting the window's handle into a variable, not doing anything.
You need to activate the window with acActivateWindow(acGetOwnerWindowByPoint(gsx, gsy))
I'm posting from my phone, so I can't guarantee I don't have a typo.
I'll look into the greyed out feature. |
|
|
Edward Dablin
17 Posts |
Posted - 11/21/2012 : 18:18:19
|
Works! Do you have a donation page or anything? |
|
|
Rob
USA
2615 Posts |
Posted - 11/21/2012 : 18:21:32
|
Sure, you can donate at the top of the forum or in the left column on the home page. Though if you have any kind of AdBlock or JavaScript blocker installed in your browser, you maybe aren't seeing it :-) |
|
|
Edward Dablin
17 Posts |
Posted - 11/21/2012 : 18:23:59
|
Nope just didn't look properly! |
|
|
Edward Dablin
17 Posts |
Posted - 11/22/2012 : 05:37:11
|
I'd like a message to be displayed when I register a window but not a message box. Ideally I'm thinking a bubble message in the system tray next to Stroke Plus. Else what are my options? Thanks. =) |
|
|
Rob
USA
2615 Posts |
Posted - 11/22/2012 : 07:48:29
|
Have you tried acDisplayText? Although I'm thinking an action to display a tray balloon might be a neat option too. |
|
|
Edward Dablin
17 Posts |
Posted - 11/22/2012 : 08:45:57
|
I have tried that but no message comes up.
Have used:
acDisplayText("check") |
|
|
Rob
USA
2615 Posts |
Posted - 11/22/2012 : 08:49:24
|
You'll need to specify more of the parameters, otherwise they will be set to defaults. For instance, the duration parameter defaults to 0, meaning you'll never see it, etc.
acDisplayText("Message", "Arial", 42, 1500, 0, 0, 455, 100, 100) |
|
|
Rob
USA
2615 Posts |
Posted - 11/22/2012 : 10:11:25
|
Added acDisplayBalloonTip in 2.4.2. Due to the Windows governs balloon tips, it may or may not be what you're looking for. Meaning, you can't have balloon tips show up one of another, Windows will simply ignore the attempt if enough time hasn't passed since the last tip was close. |
|
|
Edward Dablin
17 Posts |
Posted - 11/22/2012 : 15:06:21
|
Ahah acDisplayText works now thanks. |
|
|
|
Topic |
|
|
|