StrokesPlus Forum
                       
StrokesPlus Forum
Home | Profile | Register | Active Topics
Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Lua Scripts
 General Action Scripts
 Tile Two Windows Side-by-Side Vertically
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Rob

USA
2573 Posts

Posted - 02/28/2012 :  19:47:31  Show Profile  Visit Rob's Homepage  Reply with Quote
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
2573 Posts

Posted - 02/28/2012 :  20:00:59  Show Profile  Visit Rob's Homepage  Reply with Quote
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
Go to Top of Page

Edward Dablin

17 Posts

Posted - 11/20/2012 :  15:29:47  Show Profile  Reply with Quote
Hi this looks very useful but how do I get it to work?
Go to Top of Page

Rob

USA
2573 Posts

Posted - 11/20/2012 :  21:26:23  Show Profile  Visit Rob's Homepage  Reply with Quote
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)
Go to Top of Page

Edward Dablin

17 Posts

Posted - 11/21/2012 :  18:01:13  Show Profile  Reply with Quote
Works this is amazing. Your program is one of the best productivity programs I have, if no the best. Only discovered it this week!
Go to Top of Page

Edward Dablin

17 Posts

Posted - 11/21/2012 :  18:03:04  Show Profile  Reply with Quote
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 =)
Go to Top of Page

Rob

USA
2573 Posts

Posted - 11/21/2012 :  18:06:00  Show Profile  Visit Rob's Homepage  Reply with Quote
I'm glad to hear!
Go to Top of Page

Edward Dablin

17 Posts

Posted - 11/21/2012 :  18:11:46  Show Profile  Reply with Quote
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}")
Go to Top of Page

Rob

USA
2573 Posts

Posted - 11/21/2012 :  18:16:54  Show Profile  Visit Rob's Homepage  Reply with Quote
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.
Go to Top of Page

Edward Dablin

17 Posts

Posted - 11/21/2012 :  18:18:19  Show Profile  Reply with Quote
Works! Do you have a donation page or anything?
Go to Top of Page

Rob

USA
2573 Posts

Posted - 11/21/2012 :  18:21:32  Show Profile  Visit Rob's Homepage  Reply with Quote
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 :-)
Go to Top of Page

Edward Dablin

17 Posts

Posted - 11/21/2012 :  18:23:59  Show Profile  Reply with Quote
Nope just didn't look properly!
Go to Top of Page

Edward Dablin

17 Posts

Posted - 11/22/2012 :  05:37:11  Show Profile  Reply with Quote
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. =)
Go to Top of Page

Rob

USA
2573 Posts

Posted - 11/22/2012 :  07:48:29  Show Profile  Visit Rob's Homepage  Reply with Quote
Have you tried acDisplayText? Although I'm thinking an action to display a tray balloon might be a neat option too.
Go to Top of Page

Edward Dablin

17 Posts

Posted - 11/22/2012 :  08:45:57  Show Profile  Reply with Quote
I have tried that but no message comes up.

Have used:

acDisplayText("check")
Go to Top of Page

Rob

USA
2573 Posts

Posted - 11/22/2012 :  08:49:24  Show Profile  Visit Rob's Homepage  Reply with Quote
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)
Go to Top of Page

Rob

USA
2573 Posts

Posted - 11/22/2012 :  10:11:25  Show Profile  Visit Rob's Homepage  Reply with Quote
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.
Go to Top of Page

Edward Dablin

17 Posts

Posted - 11/22/2012 :  15:06:21  Show Profile  Reply with Quote
Ahah acDisplayText works now thanks.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000