; Auto-It3 Script ; Auto-Lock Song Library ; Allows you to edit MediaShout 3 (tm) Lyric cues (playorder changes, etc) without changing the Song library. ; Automatically keeps the Song Library locked - unlocks it only when ShoutSinger is open. ; Therefore all edits made to a Lyric cue (using the cue properties box) only change the cue - not the Library. ; If you wish to change the song in the Library, just use ShoutSinger & the library will automatically ; unlock until you exit ShoutSinger, then it automatically locks again. ; ; Recommended that you go to Tools->Settings->Text and set "Synchronization" to "None". ; ; Disclaimer - This code is "Freeware" and may not be sold under any circumstances. ; There are no warranties, guarantees, support or fitness for use implied. ; The user agrees to accept all responsibility for the use of this software, and indemnify and hold harmless the developer(s) ; for any claims, loss or damage resulting from it's use. ; ; To God be the Glory! ; 2-14-08 ; R. Noar ;Global Variables: $g_szVersion = "Song Library Auto Lock 1.0" ; Script Name $Wcount = 60 $Errcode = 1 ; ; ;Startup If WinExists($g_szVersion) Then Exit ; Exit if this script is already running AutoitWinSetTitle($g_szVersion) Opt("WinTitleMatchMode", 1) ; Default Match Window Titles mode ; If Not WinExists ("MediaShout") Then ;Start Mediashout if not already started Run ("C:\Program Files\MediaComplete\MediaShout 3\MediaShout 3.exe","", @SW_MAXIMIZE) ;Start MediaShout EndIf ; WinWaitActive ("MediaShout","",60) ; Wait for MediaShout to start SplashTextOn("Please Wait", "MediaShout Initializing", -1, 200, -1, 10, 32, "", 24) ; AdlibEnable ("CheckIfTerm", 250) ; Check every 250msec, If Mediashout terminates, then exit this program ; For $i = $Wcount to 1 Step -1 Sleep (2000) ; Wait for Mediashout to initialize If MouseGetCursor () = "15" Then $i=$Wcount ;Keep waiting if cursor is hourglass (15) If WinExists("Server Busy","") Then ; See if getting "Server Busy" message WinActivate ("Server Busy") Send("R") ; send retry if "Server Busy" message from MediaShout EndIf If Not WinActive("MediaShout","") Then WinActivate("MediaShout","") If Not WinExists ("Creating","") Then Send ("!T") ; Tools Sleep (300) Send ("e") ; Settings Sleep (1000) If WinExists("Settings","") Then ExitLoop ; Exit loop if Mediashout is responding EndIf Next Sleep (3000) ; While WinExists("Server Busy","") ; See if still getting "Server Busy" message WinActivate ("Server Busy") Send("R") ; send retry if "Server Busy" message from MediaShout Sleep (5000) WEnd ; While WinExists("Creating","") ; Check if still creating thumbnails Sleep (1000) ; Wait one second and check again WEnd ; ;Main Loop While WinExists("MediaShout") ; Run AutoLock whenever MediaShout is running ShoutSingerWtClosed("") ; Function call - checks to see if ShoutSinger is closed, then locks Song Library ShoutSingerWtOpened("") ; Function call - checks to see if ShoutSinger is opened, then unlocks Song Library WEnd Exit ; ;FUNCTIONS: Func ShoutSingerWtClosed($nul); Function checks/waits for ShoutSinger to close, then locks the Song Library $Errcode = 1 ; Initialize vars $stdisp = "" While ( IsMinimized("MediaShout") OR IsVisible("ShoutSinger") ); Check to see if ShoutSinger is closed Sleep (500) ; check every 500 msec WEnd ; ; ShoutSinger is closed, so do the following: For $i = 5 to 1 Step -1 ; Attempt up to 5 times to lock song database - in case system busy SplashTextOn( "Please Wait", "Locking Song Library " & $stdisp , -1, 200, -1, 10, 32, "", 24) $stdisp = ($stdisp & ".") If Not WinActive("MediaShout","") Then WinActivate("MediaShout","") If WinWaitActive ("MediaShout","",10) Then If Not WinExists("Settings","") Then Send ("!T") ; Tools Sleep (300) Send ("e") ; Settings Sleep (300) EndIf EndIf If Not WinActive("Settings","") Then WinActivate("Settings","") If WinWaitActive ("Settings","",10) Then Send ("+{TAB}") ; Click on Top Tab ;ControlClick ("Settings","",12320) ; Click on top Tab Send ("{RIGHT 4}") ; Move Right to the "Text" Tab Sleep (300) ControlFocus("Settings","",1876) ; focus is on the Lock/Unlock control Sleep (300) ControlCommand ("Settings","",1876,"Check","") ; Lock song database Sleep (300) $Locked = 0 $Locked = ControlCommand ("Settings","",1876,"IsChecked","") Sleep (300) ControlClick("Settings","",1) ; Click OK Sleep (1000) If WinExists ("Settings","") Then ; Did Settings window not close??? If Not WinActive("Settings","") Then WinActivate("Settings","") WinWaitActive ("Settings","",3) ControlClick("Settings","",1) ; In case Settings window did not close properly EndIf If $Locked = 1 Then ExitLoop EndIf Sleep (2000) ; Wait before retrying If $i = 1 Then MsgBox(0,"ERROR", "Could Not Lock Song Library") $Errcode = 0 EndIf Next SplashOff () Return $Errcode EndFunc ; ; Func ShoutSingerWtOpened($nul) ; Function checks/waits for ShoutSinger to open, then unlocks the Song Library $Errcode = 1 ; Initialize vars $stdisp = "" While Not IsVisible("ShoutSinger") ; Wait for ShoutSinger to open Sleep (500) ;check every 500 msec Wend ; ShoutSinger opened, do the following: For $i = 5 to 1 Step -1 ; Attempt up to 5 times to unlock song database, in case system busy SplashTextOn("Please Wait","Unlocking Song Library " & $stdisp , -1, 200, -1, 10, 32, "", 24) $stdisp = ($stdisp & ".") If Not WinActive("MediaShout","") Then WinActivate("MediaShout","") If WinWaitActive ("MediaShout","",10) Then If Not WinExists("Settings","") Then Send ("!T") ; Tools Sleep (300) Send ("e") ; Settings Sleep (300) EndIf EndIf If Not WinActive("Settings","") Then WinActivate("Settings","") If WinWaitActive ("Settings","",10) Then Send ("+{TAB}") ; Click on Top Tab ; ControlClick ("Settings","",12320) ; Click on Top Tab Send ("{RIGHT 4}") ; Move over right to the "Text" Tab Sleep (300) ControlFocus("Settings","",1876) ; focus is on the Lock/Unlock control Sleep (300) ControlCommand ("Settings","",1876,"UnCheck","") ; Unlock song database Sleep (300) $Locked = 1 $Locked = ControlCommand ("Settings","",1876,"IsChecked","") Sleep (300) ControlClick ("Settings","",1) ; Click OK Sleep (1000) If WinExists ("Settings","") Then ; Did Settings window not close??? If Not WinActive("Settings","") Then WinActivate("Settings","") WinWaitActive ("Settings","",3) ControlClick("Settings","",1) ; In case Settings window did not close properly EndIf If $Locked = 0 Then ExitLoop EndIf Sleep (2000) ; Wait before retrying If $i = 1 Then MsgBox(0,"ERROR", "Could Not Unlock Song Library") $Errcode = 0 EndIf Next SplashOff () If Not WinActive("ShoutSinger","") Then WinActivate("ShoutSinger","") ; return focus to ShoutSinger Return $Errcode EndFunc ; ; Func IsVisible($title) ;This Function checks to see if a Window is Visible If BitAnd( WinGetState($title), 2) Then $Errcode = 1 Else $Errcode = 0 EndIf Return $Errcode EndFunc ; Func IsMinimized($title) ;This Function checks to see if a Window is Minimized If BitAnd( WinGetState($title), 16) Then $Errcode = 1 Else $Errcode = 0 EndIf Return $Errcode EndFunc ; Func CheckIfTerm () ; Check if Mediashout has terminated If Not WinExists ("MediaShout","") Then SplashOff () Exit EndIf EndFunc