Seminko Posted September 21, 2017 Share Posted September 21, 2017 Hey, the code worked just fine, made some adjustments and now it only runs once and exits. If I remove all the IF statements and variables I'm left with this which should obviously loop: While 1 Sleep(100) WEnd expandcollapse popup#include <File.au3> #include <Array.au3> #RequireAdmin HotKeySet("{F8}", "Terminate") Global $VLCExePath = "C:\Program Files\VideoLAN\VLC\VLC.exe" Global $ChatLogLocation = @ScriptDir & "\mumble-chat.txt" Global $PlaylistArr[1] While 1 ;~ WinActivate("Mumble") ;~ WinWaitActive("Mumble") ;~ Send("^a") ;~ SLeep(50) ;~ Send("^c") ;~ SLeep(50) $MumbleChat = ClipGet() ; checkne current Mumble Chat $MumbleChatCharCount = StringLen($MumbleChat) ; spočita chary $ChatLog = FileRead($ChatLogLocation) ; checkne uloženy mumble chat $ChatLogCharCount = StringLen($ChatLog) ; spočita chary If $MumbleChatCharCount > $ChatLogCharCount Then ; pokud je current mumble chat 'delši' splitne jen tu novou část $ChatUpdated = StringRight($MumbleChat, $MumbleChatCharCount - $ChatLogCharCount) ; splitne novou část FileWrite($ChatLogLocation, $ChatUpdated) ; zapíše novou část do chat logu $PlayCommand = StringInStr($ChatUpdated, "!Play https://www.youtube.com/watch?v=") ; checkne jestli je v nové části command a link If $PlayCommand > 0 Then $HowManyLinks = StringReplace($ChatUpdated, "!Play https://www.youtube.com/watch?v=", "!Play https://www.youtube.com/watch?v=") ; checkne kolik linku $HowManyLinksCount = @extended If $HowManyLinksCount = 1 Then ; pokud jen jeden link $LinkRaw = StringInStr($ChatUpdated, "!Play http") $Link = StringMid($ChatUpdated, $LinkRaw + 6, 43) StringReplace($Link, @CRLF, "") StringReplace($Link, @CR, "") StringReplace($Link, @LF, "") _ArrayAdd($PlaylistArr, $Link) If @error Then MsgBox(1, "", "array add failed") EndIf _ArrayDisplay($PlaylistArr) ;MsgBox(1, "", "play music once") Else ; pokud vice linku For $i = 1 to $HowManyLinksCount $LinkRaw = StringInStr($ChatUpdated, "!Play http", 0, $i) $Link = StringMid($ChatUpdated, $LinkRaw + 6, 43) StringReplace($Link, @CRLF, "") StringReplace($Link, @CR, "") StringReplace($Link, @LF, "") _ArrayAdd($PlaylistArr, $Link) Next _ArrayDisplay($PlaylistArr) ;MsgBox(1, "", "play music more times") EndIf EndIf Else MsgBox(1, "", $MumbleChatCharCount & " / " & $ChatLogCharCount) EndIf If Not $PlaylistArr[1] = "" Then PlayMusic() EndIf Sleep(100) _ArrayDisplay($PlaylistArr) WEnd Func PlayMusic() MsgBox(1, "", $PlaylistArr[1]) $LinkToPlay = $PlaylistArr[1] ShellExecuteWait($VLCExePath, "--qt-start-minimized --no-video " & $LinkToPlay & " vlc://quit") _ArrayDelete($PlaylistArr, 1) EndFunc Func Terminate() Exit EndFunc Link to comment Share on other sites More sharing options...
Developers Jos Posted September 21, 2017 Developers Share Posted September 21, 2017 15 minutes ago, Seminko said: now it only runs once and exits .. and you don't get any error? Are you running from SciTE with f5? if not, what happens when you do? Jos Seminko 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Seminko Posted September 21, 2017 Author Share Posted September 21, 2017 (edited) 6 minutes ago, Jos said: .. and you don't get any error? Are you running from SciTE with f5? if not, what happens when you do? Jos That's why I am surprised. Yes running from SciTE with F5, no error. Huh, but I've just seen this: ! Your script requires Admin rights while SciTE is running at normal level! This means no Console output from the script will be displayed and SciTE will show the script as ended right away. TIL when you use #RequireAdmin start SciTE with admin rights as well. Edited September 21, 2017 by Seminko formatting Link to comment Share on other sites More sharing options...
Seminko Posted September 21, 2017 Author Share Posted September 21, 2017 BTW, the issue was that the array did not have a second "cell". If Not $PlaylistArr[1] = "" Then PlayMusic() EndIf Replaced it with this and it works: If UBound($PlaylistArr) > 1 Then PlayMusic() EndIf Thanks Jos Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now