PDA

View Full Version : Minimize toggle quit working



molitar
September 23rd, 2006, 03:29 PM
Ok I have this minimize toggle script it worked for a short while but than stopped. I can only assume I have something being called wrong when I call the window. What is the best method to call the window handle for the minimize script?



window = gir.GetWindowMatches(MediaPlayerClassicW)

if (win.IsIconic(window)) then
win.ShowWindow(window, win.SW_RESTORE)
else
win.ShowWindow(window, win.SW_MINIMIZE)
end

Promixis
September 23rd, 2006, 09:04 PM
add a print of the windows handle to make sure you are getting it correctly.

blubberhoofd
September 25th, 2006, 01:25 PM
Hi,

:) messing around with MPC windows can be a pain in the b***

it's been a while but maybe the handles obtained by this script can be of use to you.
-- get time from MPC
local m = {}
m.ChildClass = "static"
m.Filename = "mplayerc.exe"
m.MatchHidden = true

index = 1
local test = gir.GetWindowMatches(m)
if test ~= nil then
Handle = table.tostring(gir.GetWindowMatches(m))

repeat
Start = string.find(Handle, "= ", index)
if Start ~= nil then
index = string.find(Handle, ",", Start)
handle = string.sub(Handle, Start+2, index-1)

windowtext = win.GetWindowText(handle)
if windowtext ~= nil then
if string.find(windowtext, "%d%d%s/%s%d") then
print (windowtext)

--convert to percentage
_, _, hours, minutes, seconds, thours, tminutes, tseconds = string.find(windowtext, "(%d%d)%p(%d%d)%p(%d%d)%s%p%s(%d%d)%p(%d%d)%p(%d%d)")
if hours == nil then
_, _, minutes, seconds, tminutes, tseconds = string.find(windowtext, "(%d%d)%p(%d%d)%s%p%s(%d%d)%p(%d%d)")
hours = 0
thours = 0
end

hours = 3600 * hours
minutes = minutes * 60
seconds = seconds + minutes + hours
print ("current="..seconds)

thours = 3600 * thours
tminutes = tminutes * 60
tseconds = tseconds + tminutes + thours
print ("total="..tseconds)

ratio = seconds / tseconds
percentage = ratio * 100
print (percentage.."%")

if Title == nil then Title = "test" end

--show progressbar
if not ProgOSD then
ProgOSD = osd.Classes.Progress:New(osd.GetStyle("ProgressDarkBlue",{Monitor = 2, Position = "NEARBOTTOMCENTERW", BorderSize = 0, BGColor1 = osd.MakeARGB(255, 136, 136, 136), BGColor2 = osd.MakeARGB(255, 17, 17, 17), FGColor1 = osd.MakeARGB(255, 221, 221, 221), FGColor2 = osd.MakeARGB(255, 136, 136, 136), TimeOut = 1500, AutoSizeWidth = 95, Caption = Title.."\n"..windowtext, Min = 0, Max = 100}))
end
ProgOSD.Caption = Title.."\n"..windowtext
ProgOSD:Show(true, percentage, 1)
end
end
end

until Start == nil
end


btw is there any particular reason for using scripting in this case?

molitar
September 25th, 2006, 05:30 PM
add a print of the windows handle to make sure you are getting it correctly.

Ok the print definitely was not getting any information. I finally got this to work I tried it by using the table.tostring but it wanted a number not a string. So I changed it to read table.tonumber and than it complained about being a table and not a number. It really seems their is some serious bugs with gir. What I finally got to work properly is this...



window = win.FindWindow("MediaPlayerClassicW", nil)

if (win.IsIconic(window)) then
win.ShowWindow(window, win.SW_RESTORE)
else
win.ShowWindow(window, win.SW_MINIMIZE)
end