PDA

View Full Version : Win.luafunctions



father of monstermagnet
April 19th, 2005, 09:05 AM
@Mike C

I'm playing with the IEOSD script you send me. Thanks :lol:
(very cool, particularly the timers)

The following functions are not available here (and not shown in Inspector).

win.HideWindowFromTaskbar
win.RemoveWindowFrame
win.SetWindowOnTop
win.FadeWindow

Will this be implemented or i'm missing something ?

Promixis
April 19th, 2005, 09:26 AM
You need an update...

.dll into the main G dir.

.lua into the luascript dir.

Promixis
April 19th, 2005, 09:32 AM
some updated code...





ieOSD = {

New = function (self,o)
o = o or {}
setmetatable (o,self)
self.__index = self
return o
end,

Initialize = function (self)
self.Transparency = self.Transparency or 200 -- set default if needed
self.RemoveFrame = self.RemoveFrame or false -- remove frame

self.oIE = luacom.CreateObject("InternetExplorer.Application")
self.oIE:Navigate ("about:blank - Microsoft Internet Explorer")

if not self.oIE then
gir.LogMessage ("OSD","Failed to create IE.Application",1)
return
end
--[[ -- use this is you need... for some reason the .screen object is very sensitive
if not self.oIE.Document.parentWindow.screen then -- this kludge will kill iexplore when this problems occurs
win.TerminateProcess (win.FindProcess ("iexplore.exe")) -- this happens when the quit methood of ie.app is not called..
self.oIE = luacom.CreateObject("InternetExplorer.Application")
print ("killed")
self.oIE:Navigate ("about:blank - Microsoft Internet Explorer")
return
end
--]]
return true
end,

StartTimer = function (self)
if self.Timeout then
self.Timer = gir.CreateTimer (nil,function () gir.RunCodeOnMainThread (function (...) return self:Cancel (unpack (arg)) end)end,nil,0) -- this trickery used to get back on the same thread...
self.Timer:Arm (self.Timeout)
end
end,

SetupDefaultEventHandlers = function (self)

self.oDocEvents = {
parent = self,

onmouseover = function (self)
win.SetWindowLayeredAttributesOff (self.parent.oIE.HWND)
end,

onmouseout = function (self)
win.SetWindowTransparency (self.parent.oIE.HWND,self.parent.Transparency)
end,

oncontextmenu = function (self) -- note the parentwindow fails if an ie object is not released with a :Quit () method. You have to kill the iexplorer.exe task to reset it.
self.parent.oDoc.parentWindow.event.returnValue = 0
end,

onmousedown = function (self)
win.HideWindowFromTaskbar (WeatherOSD.oIE.HWND)
end,

ondblclick = function (self)
self.parent:Cancel ()
end
}
self.oDoc = self.oIE.Document
luacom.Connect (self.oDoc,self.oDocEvents)
end,

Cancel = function (self)
_ = self.Timer and self.Timer:Destroy ()
self.oIE:Quit ()
self.oDoc= nil
self.oIE = nil
collectgarbage ()
end,

}


ieTextOSD = ieOSD:New ({

New = function (self,o)
o = o or {}
setmetatable (o,self)
self.__index = self
return o
end,

Show = function (self,text,timeout)
self:Initialize ()
local frame = 4 -- size of frame.
if not self.oIE then
return
end

-- self.oIE:Navigate ("about:blank - Microsoft Internet Explorer")

self.oIE.Document&#58;WriteLn &#40;"<body scroll='no' bgcolor='black'>"&#41;
self.oIE.Document&#58;WriteLn &#40;"<font size='9' color='green'>"&#41;
self.oIE.Document&#58;WriteLn &#40;text&#41;
self.oIE.Document&#58;WriteLn &#40;"</font>"&#41;
self.oIE.Fullscreen = 1

while self.oIE.Busy == 1 do --? use READYSTATE_COMPLETE
win.Sleep &#40;50&#41;
end

self.oIE.document.body.style.margin = 1
self.tr = self.oIE.document.body&#58;createTextRange &#40;&#41;
self.oIE.Height = &#40;self.tr&#58;boundingHeight&#40;&#41;+self.tr&#58;offsetTop&#40;&#41;*2 &#41;
self.oIE.Width = &#40;self.tr&#58;boundingWidth&#40;&#41;+self.tr&#58;offsetLeft&#40;&#41;*2 &#41;
self.oIE.Left = win.GetSystemMetrics &#40;win.SM_CXSCREEN&#41; - self.oIE.Width + frame
-- self.oIE.Left = self.oIE.Document.parentWindow.screen.width - self.oIE.Width+ frame-- win.GetSystemMetrics &#40;win.SM_CXSCREEN&#41; - self.oIE.Width
self.oIE.Top = 0 - frame

local h = self.oIE.HWND
win.HideWindowFromTaskbar &#40;h&#41;
win.SetWindowTransparency &#40;h,self.Transparency&#41;

win.RemoveWindowFrame &#40;h,frame&#41;

self.oIE.Visible = 1

win.SetWindowOnTop &#40;h&#41; -- must call after window visible...

ieOSD.StartTimer &#40;self&#41;

ieOSD.SetupDefaultEventHandlers &#40;self&#41;
end,

Cancel = function &#40;self&#41;
-- win.FadeWindow &#40;self.oIE.HWND,0,1000,nil&#41;
ieOSD.Cancel &#40;self&#41;
end,
&#125;&#41;




ieOSDClock = ieTextOSD&#58;New &#40;
&#123;
New = function &#40;self,o&#41;
o = o or &#123;&#125;
setmetatable &#40;o,self&#41;
self.__index = self
return o
end,


Start = function &#40;self&#41;

self.ClockTimer = gir.CreateTimer &#40;nil,function &#40;&#41; gir.RunCodeOnMainThread &#40;function &#40;...&#41; return self&#58;Update &#40;unpack &#40;arg&#41;&#41; end&#41;end,nil,1&#41; -- this trickery used to get back on the same thread...
self.ClockTimer&#58;Arm &#40;1000&#41;

end,

Update = function &#40;self&#41;
self.tr&#58;moveStart &#40;"textedit",-1&#41;
self.tr.text = os.date &#40;"%H"&#41;.."&#58;"..os.date &#40;"%M"&#41;.."&#58;"..os.date&#40;"%S"&#41;
end,

Cancel = function &#40;self&#41;
_ = self.ClockTimer and self.ClockTimer&#58;Destroy &#40;&#41;
ieTextOSD.Cancel &#40;self&#41;
end
&#125;&#41;


ieImageOSD = ieOSD&#58;New &#40;&#123; --HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Play Animations

New = function &#40;self,o&#41;
o = o or &#123;&#125;
setmetatable &#40;o,self&#41;
self.__index = self
return o
end,

Show = function &#40;self,imagefilename&#41;
self&#58;Initialize &#40;&#41;

local frame = 4 -- size of frame.
local margin = 1

if not self.oIE then
return
end

-- self.oIE&#58;Navigate &#40;"about&#58;blank - Microsoft Internet Explorer"&#41;

self.oIE.Document&#58;WriteLn &#40;"<body scroll='no' bgcolor='black'>"&#41;
self.oIE.Document&#58;WriteLn &#40;"</font>"&#41;
self.oIE.Fullscreen = true

self.image = self.oIE.Document&#58;createElement&#40;"img"&#41;
self.image.src = imagefilename
self.oIE.Document.Body&#58;appendChild &#40;self.image&#41;

while self.oIE.Busy == 1 do --? use READYSTATE_COMPLETE
win.Sleep &#40;50&#41;
end

self.oIE.document.body.style.margin = margin
self.oIE.Height = self.image.Height + frame +margin
self.oIE.Width = self.image.Width + frame+margin
local l,t,r,b = monitor.GetMonitorWorkAreaRect &#40;1&#41;
self.oIE.Left = r - self.oIE.Width
self.oIE.Top = b - self.oIE.Height

local h = self.oIE.HWND
win.HideWindowFromTaskbar &#40;h&#41;
win.SetWindowTransparency &#40;h,230&#41;

self.oIE.Visible = 1

-- win.SetWindowOnTop &#40;h&#41; -- must call after window visible...

ieOSD.SetupDefaultEventHandlers &#40;self&#41;
end,

UpdateImage = function &#40;self,imagefilename&#41;
if self.image then
self.image&#58;removeNode &#40;true&#41;
end

self.image = self.oIE.Document&#58;createElement&#40;"img"&#41;
self.image.src = imagefilename
self.oIE.Document.Body&#58;appendChild &#40;self.image&#41;
end,

Cancel = function &#40;self&#41;
ieOSD.Cancel &#40;self&#41;
end,
&#125;&#41;


--&#91;&#91;
OSD = ieTextOSD&#58;New &#40;&#123;Timeout = 15000&#125;&#41;

OSD&#58;Show &#40;"test ie osd....."&#41;
--&#93;&#93;

-- &#91;&#91;
OSDClock = ieOSDClock&#58;New &#40;&#41;
OSDClock&#58;Show &#40;"00&#58;00&#58;00"&#41;
OSDClock&#58;Start &#40;&#41;



--&#93;&#93;

-- &#91;&#91;
WeatherOSD = ieImageOSD&#58;New &#40;&#41;

WeatherOSD&#58;Show &#40;"C&#58;\\DOCUME~1\\mike\\LOCALS~1\\Temp\\satmap Minneapolis.gif"&#41;
--&#93;&#93;

father of monstermagnet
April 19th, 2005, 10:08 AM
COOOOOOOOOOL 8)

Thanks !

quixote
April 19th, 2005, 10:19 AM
Any chance we can get some screenshots? You've always got something cool in the lab. :D