Move and resize window
The script would stop in 10s or idle in 1s.
Move and resize could snap to other window.
You could choose to move outside the monitor or could not move by br.
You could not resize outside the monitor.
There are 3 method to resize, 1 and 2 are resize by moving right and bottom window boundary, 3 is by moving all window boundary.1 would continue increase size after reach the monitor boundary, whereas, 2 would stop.
move window
acGetAllWindows(1)
local wbt,wbl,wbb,wbr = {},{},{},{}
for i,v in pairs(sp_all_windows) do
wbt[i] = acGetWindowTop(v, nil, nil)
wbl[i] = acGetWindowLeft(v, nil, nil)
wbb[i] = acGetWindowBottom(v, nil, nil)
wbr[i] = acGetWindowRight(v, nil, nil)
end
local iHandle = acGetParentWindowByPoint(gsx, gsy)
local br = true -- boundary restriant. counld move outside monitor?
local tp = acGetWindowTransparency(iHandle, nil, nil)
acSetWindowTransparency(iHandle, nil, nil, 230) -- Transparency when move
local tt = 10--total run time
local it = 1-- idle time to stop
local fq = 10-- refresh rate
local ss = 10-- snap sensitive
local wl = acGetWindowLeft(iHandle, nil, nil)
local wt = acGetWindowTop(iHandle, nil, nil)
local wr = acGetWindowRight(iHandle, nil, nil)
local wb = acGetWindowBottom(iHandle, nil, nil)
local nwl,nwt,nwr,nwb -- new window boundary
local hm,vm,tm,stm-- horizontal movement, vertical movement, total movement, saved total total movement
local ml = acGetMonitorLeft(acGetMonitorFromPoint(gsx, gsy), 1)
local mt = acGetMonitorTop(acGetMonitorFromPoint(gsx, gsy), 1)
local mr = acGetMonitorRight(acGetMonitorFromPoint(gsx, gsy), 1)
local mb = acGetMonitorBottom(acGetMonitorFromPoint(gsx, gsy), 1)
stm = 0
for i=1,tt*fq,1 do
hm = acGetMouseLocationX()-gex
vm = acGetMouseLocationY()-gey
nwl = wl + hm
nwt = wt + vm
nwr = wr + hm
nwb = wb + vm
if math.fmod (i,it*fq) == 0 then--compare every 10 cycle
tm = math.abs (hm) + math.abs (vm) --total movement
if math.abs(tm - stm) < 10 then break end
stm = tm--save the total movement
end
if nwl - ml < 0 and br then --outside the monitor left
nwl = ml
elseif math.abs(nwl - ml) < ss then
nwl = ml
else
for i,v in pairs(wbr) do
if math.abs(nwl - v) < ss then
nwl = v
break
end
end
end
if nwt - mt < 0 and br then --outside the monitor top
nwt = mt
elseif math.abs(nwt - mt) < ss then
nwt = mt
else
for i,v in pairs(wbb) do
if math.abs(nwt - v) < ss then
nwt = v
break
end
end
end
if nwr - mr > 0 and br then --outside the monitor right
nwl = mr - wr + wl
elseif math.abs(nwr - mr) < ss then
nwl = mr - wr + wl
else
for i,v in pairs(wbl) do
if math.abs(nwr - v) < ss then
nwl = v - wr + wl
break
end
end
end
if nwb - mb > 0 and br then --outside the monitor right
nwt = mb - wb + wt
elseif math.abs(nwr - mr) < ss then
nwt = mb - wb + wt
else
for i,v in pairs(wbt) do
if math.abs(nwb - v) < ss then
nwt = v - wb + wt
break
end
end
end
acMoveWindow(iHandle, nil, nil, nwl, nwt )
acDelay(1000/fq)
end
acSetWindowTransparency(iHandle, nil, nil, tp)
acDisplayText("End in " .. nwt .. "x" .. nwl, "Arial", 16, 255-acGetPixelRByPoint(gex, gey), 255-acGetPixelGByPoint(gex, gey), 255-acGetPixelBByPoint(gex, gey), 1000, acGetMouseLocationX()+20, acGetMouseLocationY())
resize window
acGetAllWindows(1)
local wbt,wbl,wbb,wbr = {},{},{},{}
for i,v in pairs(sp_all_windows) do
wbt[i] = acGetWindowTop(v, nil, nil)
wbl[i] = acGetWindowLeft(v, nil, nil)
wbb[i] = acGetWindowBottom(v, nil, nil)
wbr[i] = acGetWindowRight(v, nil, nil)
end
local iHandle = acGetParentWindowByPoint(gsx, gsy)
local tp = acGetWindowTransparency(iHandle, nil, nil)
acSetWindowTransparency(iHandle, nil, nil, 230) -- Transparency when move
local tt = 10--total run time
local it = 1-- idle time to stop
local fq = 10-- refresh rate(Hz)
local br = false -- boundary restriant.
local me = 3--resize method(1,2,3)
local ss = 10-- snap sensitive
local wl = acGetWindowLeft(iHandle, nil, nil)
local wt = acGetWindowTop(iHandle, nil, nil)
local wr = acGetWindowRight(iHandle, nil, nil)
local wb = acGetWindowBottom(iHandle, nil, nil)
local nwl,nwt,nwr,nwb -- new window boundary
local hm,vm,tm,stm-- horizontal movement, vertical movement, total movement, saved total movement
local ml = acGetMonitorLeft(acGetMonitorFromPoint(gsx, gsy), 1)
local mt = acGetMonitorTop(acGetMonitorFromPoint(gsx, gsy), 1)
local mr = acGetMonitorRight(acGetMonitorFromPoint(gsx, gsy), 1)
local mb = acGetMonitorBottom(acGetMonitorFromPoint(gsx, gsy), 1)
stm = 0
for i=1,tt*fq,1 do
hm = acGetMouseLocationX()-gex
vm = acGetMouseLocationY()-gey
if math.fmod (i, it*fq) == 0 then--compare every some cycle
tm = math.abs (hm) + math.abs (vm) --total movement
if math.abs(tm - stm) < 10 then break end
stm = tm--save the total movement
end
if me == 1 or me == 2 then
nwl = wl
nwt = wt
nwr = wr + hm
nwb = wb + vm
else
nwl = wl - (hm/2)
nwt = wt - (vm/2)
nwr = wr + (hm/2)
nwb = wb + (vm/2)
end
if nwr - mr > 0 then --outside the monitor right
nwr = mr
if me == 1 then
nwl = wl - hm +mr - wr
end
else
for i,v in pairs(wbl) do --snap to other window
if math.abs(nwr - v) < ss then
nwr = v
break
end
end
end
if nwb - mb > 0 then --outside the monitor bottom
nwb = mb
if me == 1 then
nwt = wt - vm +mb - wb
end
else
for i,v in pairs(wbt) do
if math.abs(nwb - v) < ss then
nwb = v
break
end
end
end
if nwl - ml < 0 then --outside the monitor left
nwl = ml
else
for i,v in pairs(wbr) do
if math.abs(nwl - v) < ss then
nwl = v
break
end
end
end
if nwt - mt < 0 then --outside the monitor top
nwt = mt
else
for i,v in pairs(wbb) do
if math.abs(nwt - v) < ss then
nwt = v
break
end
end
end
acSetWindowSize(iHandle, nil, nil,nwr-nwl, nwb-nwt)
acMoveWindow(iHandle, nil, nil, nwl, nwt )
acDelay(1000/fq)
end
acSetWindowTransparency(iHandle, nil, nil, tp)
acDisplayText("End in " .. nwr-nwl .. "x" .. nwb-nwt, "Arial", 16, 255-acGetPixelRByPoint(gex, gey), 255-acGetPixelGByPoint(gex, gey), 255-acGetPixelBByPoint(gex, gey), 1000, acGetMouseLocationX()+20, acGetMouseLocationY())