AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Window (or process) handling ? (too many)

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Dave72



Joined: 27 Jan 2007
Posts: 30
Location: Canada

PostPosted: Fri Jul 24, 2009 11:52 pm    Post subject: Window (or process) handling ? (too many) Reply with quote

Hi.
I have an external app (Juice, a podcast aggregator). As it completes each download, it does a command line call to my AHK script, passing some variables.
My script uses FFMpeg to convert the files to mpegs (which I play at my tv using a MediaMVP and GB-PVR application).
Its sorta like my little IPTV system.

Problem is.. if I use #singleinstance Off , as each new download completes, it keeps spawning new instances of my script (FFMpeg takes a bit of time). Eventually, the computer bogs down. I cant use #singleinstance Ignore or Force obviously.
My current 'solution' for this, is to only allow one thread at a time for downloading in Juice. That way, once my script is done it closes its own window, then the cmd.exe window (called from the Juice) closes, and the next file downloads.
The drawback is.. it would be nice to be downloading the next file while the current one processes. I just cant figure out how.

Anyone run into a window handling situation like this ?



Code if its needed to looksee..
Code:
#singleinstance off
SetTitleMatchMode, 2
WinMinimize, cmd.exe
TimeStamp = A_Now
FormatTime, TimeStamp,,ddd`,MMMd  h:mm:ss
IniRead, Ext, %A_ScriptDir%\mpegmaker4juice.ini, General, Ext
IniRead, FFopt, %A_ScriptDir%\mpegmaker4juice.ini, General, FFopt
IniRead, DelOrig, %A_ScriptDir%\mpegmaker4juice.ini, General, DelOrig
IniRead, FFShow, %A_ScriptDir%\mpegmaker4juice.ini, General, FFShow
;
JuicePathtoFile = %1% ; full path from drive letter to .ext
JuicePodcastName = %2% ; just folder name it seems
;
Splitpath, JuicePathtoFile,,Filedir,FileExt,FilenameNoExt,
If FileExt not in %Ext%
   {
   Goto, Filetypenotinlist
   }
Runwait, ffmpeg.exe -i "%JuicePathtoFile%" %FFopt% "%FileDir%\%FilenameNoExt%.mpeg" ,,%FFShow%
If (DelOrig = "True")
   {
   FileDelete, %JuicePathtoFile%
   }
FileAppend, %TimeStamp% %JuicePathtoFile% converted and deleted (used string %FFOpt%)`n, %A_Scriptdir%\mpegmaker4juice.log
Exit
;
Filetypenotinlist:
Msgbox, 16, mpegmaker4juice, Filetype does not exist in ini file, 8
FileAppend, %JuicePathtoFile% : filetype not in .ini list`n, %A_Scriptdir%\mpegmaker4juice.log
Exit
Back to top
View user's profile Send private message
greynite



Joined: 17 May 2008
Posts: 39
Location: Dallas, TX

PostPosted: Wed May 12, 2010 5:16 pm    Post subject: Reply with quote

Use the process command to watch for existing FFmpeg & wait instead for it to close
Code:
Loop, 600
{
Process, WaitClose, FFmpeg.exe, 5
if !ErrorLevel ; The PID no longer exists.
    break
}

Hope this helps.

Cheers,
Shawn[/code]
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group