Jump to content

Emanoel

Active Members
  • Posts

    23
  • Joined

  • Last visited

Everything posted by Emanoel

  1. @pixelsearch Nice changes! I had trouble changing the shuttle image, and @Nine used several functions and lines to solve it. But now there is no need to add them, I separated picture to 6 parts and used your line for $idShuttle, the problem is solved! Maybe he can explain what happened?
  2. I changed the code and turned the buttons to OnEvent. Now you can drop new file into gui or open it with the "..." button whenever you want, pause the whole program with the "Pause" button. Opt("GUIOnEventMode", 1) Opt("GUIResizeMode", 1) Opt("MouseCoordMode", 2) #include <Misc.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $FilePath, $Paused = False Global $FileExt[] = [".3g2", ".3gp2", ".3gp", ".3gpp", ".aac", ".adt", ".adts", ".aif", ".aifc", ".aiff", ".asf", ".asx", ".au", ".avi", ".cda", _ ".dvr-ms", ".flac", ".ivf", ".m1v", ".m2ts", ".m3u", ".m4a", ".m4v", ".mid", ".midi", ".mov", ".mp2", ".mp3", ".mp4", ".mp4v", ".mpa", ".mpe", _ ".mpeg", ".mpg", ".rmi", ".snd", ".wav", ".wax", ".wm", ".wma", ".wmd", ".wms", ".wmv", ".wmx", ".wmz", ".wpl", ".wvx"] $oPlayer = ObjCreate("WMPlayer.OCX") $iPos = 0 ; x coordinate of $ShuttleButton control in progress bar $hDLL = DllOpen("user32.dll") ; to dectect mouse down on the $ShuttleButton control $iSliderLength = 421 ; in pixels $adlibInterval = 250 ; in milliseconds $oPlayer.URL = "" $iMediaLength = 0 $mediaPos = 0 $iShuttleWidth = 25 #Region ### START Koda GUI section ### Form= $hGui = GUICreate("Music Player", 466, 170, 192, 132, Default, BitOR($WS_EX_TOPMOST, $WS_EX_ACCEPTFILES)) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") Global $PauseButton = GUICtrlCreateButton("Play", 184, 128, 99, 33) GUICtrlSetOnEvent($PauseButton, "PauseButton") Global $InputFile = GUICtrlCreateInput("", 8, 32, 417, 55) GUICtrlSetState($InputFile, $GUI_DROPACCEPTED) GUICtrlGetHandle($InputFile) GUICtrlSetBkColor(-1, 0xE3E3E3) GUICtrlSetCursor(-1, 5) GUICtrlCreateLabel("Drop your song here or browse it:", 8, 8, 199, 20) $BrowseButton = GUICtrlCreateButton("...", 432, 32, 27, 25) GUICtrlSetOnEvent($BrowseButton, "BrowseFile") Global $Sliderbar = GUICtrlCreateButton("", 8, 96, 451, 25, $BS_CENTER) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetBkColor(-1, 0xE3E3E3) Global $ShuttleButton = GUICtrlCreateButton("", 8, 96, $iShuttleWidth, 25) GUICtrlSetBkColor(-1, 0x646464) GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_Event_PrimaryDown") Global $Progress = GUICtrlCreateLabel("0:00", 8, 128, 28, 20, $SS_LEFT) ; current media position Global $Length = GUICtrlCreateLabel("0:00", 432, 128, 28, 20, $SS_RIGHT) ; media length GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_DROPPED, "DropFile") #EndRegion ### END Koda GUI section ### $oPlayer = ObjCreate("WMPlayer.OCX") If Not IsObj($oPlayer) Then MsgBox(0, "WMPlayer.OCX", "Cannot create a WMP object.", 5) GUIDelete($hGui) Exit EndIf Global $iPos = 0 ; x coordinate of $ShuttleButton control in progress bar Global $hDLL = DllOpen("user32.dll") ; to dectect mouse down on the $ShuttleButton control Global $SliderLength = 370 ; in pixels Global $adlibInterval = 250 ; in milliseconds $oPlayer.URL = "" Global $mediaLength = 0 Global $mediaPos = 0 $oPlayer.Settings.Volume = 100 While 1 Sleep(10) If $Paused Then While $Paused Sleep(100) WEnd EndIf If $oPlayer.playState = 3 Then ; when song playing ;ConsoleWrite("Playing ") do whatever you want ElseIf $oPlayer.playState = 1 Then ; when song stopped GUICtrlSetData($PauseButton, "Play Again!") EndIf WEnd Func CLOSEClicked() $oPlayer.Close Exit EndFunc ;==>CLOSEClicked Func BrowseFile() Local $Extension = Null For $temp In $FileExt $Extension &= "*" & $temp & ";" Next $Extension = (StringTrimRight($Extension, 1)) $FilePath = FileOpenDialog("Open Music File", "", "Media Files (" & $Extension & ")", 12) If CheckFile() Then GUICtrlSetData($InputFile, $FilePath) GUICtrlSetData($Sliderbar, _RemoveFileExt(StringMid($FilePath, StringInStr($FilePath, "\", 0, -1) + 1))) $oPlayer.URL = $FilePath Local $hTimer = TimerInit() While $oPlayer.playState <> 3 ; 1 - stopped, 2 - paused, 3 - playing If TimerDiff($hTimer) > 3000 Then MsgBox(0, "WMPlayer.OCX", $FilePath & @CRLF & @CRLF & "Cannot play this file.", 5) ExitLoop EndIf Sleep(5) WEnd $oPlayer.Controls.Pause $oPlayer.Controls.currentPosition = 0 $iMediaLength = Int($oPlayer.currentMedia.Duration) ; in seconds GUICtrlSetData($Length, Int($iMediaLength / 60) & ":" & StringFormat("%02i", Mod($iMediaLength, 60))) AdlibRegister("Slider", $adlibInterval) GUICtrlSetData($PauseButton, "Play") EndIf EndFunc ;==>BrowseFile Func DropFile() $oPlayer.Close Switch @GUI_DropId Case $InputFile $FilePath = GUICtrlRead($InputFile) If CheckFile() Then GUICtrlSetData($Sliderbar, _RemoveFileExt(StringMid($FilePath, StringInStr($FilePath, "\", 0, -1) + 1))) $oPlayer.URL = $FilePath Local $hTimer = TimerInit() While $oPlayer.playState <> 3 ; 1 - stopped, 2 - paused, 3 - playing If TimerDiff($hTimer) > 3000 Then MsgBox(0, "WMPlayer.OCX", $FilePath & @CRLF & @CRLF & "Cannot play this file.", 5) ExitLoop EndIf Sleep(5) WEnd $oPlayer.Controls.Pause $oPlayer.Controls.currentPosition = 0 $iMediaLength = Int($oPlayer.currentMedia.Duration) ; in seconds GUICtrlSetData($Length, Int($iMediaLength / 60) & ":" & StringFormat("%02i", Mod($iMediaLength, 60))) AdlibRegister("Slider", $adlibInterval) GUICtrlSetData($PauseButton, "Play") EndIf EndSwitch EndFunc ;==>DropFile Func PauseButton() CheckFile() If GUICtrlRead($PauseButton) = "Pause" Then $oPlayer.Controls.Pause AdlibUnRegister() $Paused = True GUICtrlSetData($PauseButton, "Resume") Else $oPlayer.Controls.Play AdlibRegister("Slider") $Paused = False GUICtrlSetData($PauseButton, "Pause") EndIf EndFunc ;==>PauseButton Func _Event_PrimaryDown() Local $n_msg = GUIGetCursorInfo()[4] Switch $n_msg Case $ShuttleButton AdlibUnRegister() $x = MouseGetPos(0) $xOffset = $x - $iPos While _IsPressed("01") $x = MouseGetPos(0) GUICtrlSetPos($ShuttleButton, $x - $iShuttleWidth / 2) Sleep(10) WEnd $oPlayer.Controls.currentPosition = ($x - $iShuttleWidth / 2) / $iSliderLength * $iMediaLength $oPlayer.Controls.Play AdlibRegister("Slider", $adlibInterval) Case $Sliderbar GUICtrlSetPos($ShuttleButton, MouseGetPos(0) - $iShuttleWidth / 2) $x = (MouseGetPos(0) - $iShuttleWidth / 2) / $iSliderLength * $iMediaLength $oPlayer.Controls.currentPosition = $x > $iMediaLength ? $iMediaLength : $x $oPlayer.Controls.Play EndSwitch EndFunc ;==>_Event_PrimaryDown Func CheckFile() Local $check = True For $temp In $FileExt If StringInStr($FilePath, $temp, Default, -1) = False Then $check = False Else $check = True ExitLoop EndIf Next If $FilePath = "" Then MsgBox(0, "File Error", "The file has not been selected yet.") Return 0 ElseIf $check = False Then MsgBox(0, "File Error", "The dropped file is not a media file, try again please.") Return 0 EndIf Return 1 EndFunc ;==>CheckFile Func _RemoveFileExt($string) Return StringLeft($string, StringInStr($string, ".", Default, -1) - 1) EndFunc ;==>_RemoveFileExt Func Slider() $mediaPos = $oPlayer.Controls.currentPosition $iPos = $mediaPos * $SliderLength / $mediaLength GUICtrlSetPos($ShuttleButton, $iPos) GUICtrlSetData($Progress, Int($mediaPos / 60) & ":" & StringFormat("%02i", Mod($mediaPos, 60))) EndFunc ;==>Slider The problem is "Sliderbar" button is located on the Shuttle button (overlapped) πŸ€”. Since it's my first time working on "GUIOnEventMode", can't fix shuttle button problem.
  3. @Nine, I've added Opt("MouseCoordMode", 2) to code and now it's working great. Can't thank you enough 🧑🌹.
  4. I rewrite my code to have the feature "change position of song by clicking on slider bar". When I add ElseIf ... (line 99-103), shuttle button goes to end of song and gui closes immediately. #include <GuiConstants.au3> #include <Misc.au3> Global $SliderButton = @ScriptDir & "\SliderButton.jpg" $hGui = GUICreate("Music Player", 400, 75, -1, -1) $idSongName = GUICtrlCreateButton("", 0, 0, 400, 20) ;music file name GUICtrlSetState(-1, $GUI_DISABLE) $iShuttleWidth = 20 $ShuttleButton = GUICtrlCreateButton("", 0, 0, $iShuttleWidth, 20) GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0x646464) $PauseButton = GUICtrlCreateButton("Pause", 208, 40, 80, 20) $PlayButton = GUICtrlCreateButton("Play", 112, 40, 80, 20) $Progress = GUICtrlCreateLabel("0:00", 4, 25, 45, 20, $SS_LEFT) ; current media position $Length = GUICtrlCreateLabel("0:00", 350, 25, 45, 20, $SS_RIGHT) ; media length GUISetState(@SW_SHOW) $FilePath = "C:\Users\Anonymous\Downloads\Music\Chelsea Wolfe - Two spirit [128].mp3" $oPlayer = ObjCreate("WMPlayer.OCX") If Not IsObj($oPlayer) Then MsgBox(0, "WMPlayer.OCX", "Cannot create a WMP object.", 5) GUIDelete($hGui) Exit EndIf $iPos = 0 ; x coordinate of $ShuttleButton control in progress bar $hDLL = DllOpen("user32.dll") ; to dectect mouse down on the $ShuttleButton control $iSliderLength = 370 ; in pixels $adlibInterval = 250 ; in milliseconds $oPlayer.URL = "" $iMediaLength = 0 $mediaPos = 0 $oPlayer.Settings.Volume = 100 $oPlayer.URL = $FilePath $hTimer = TimerInit() While $oPlayer.playState <> 3 ; 1 - stopped, 2 - paused, 3 - playing If TimerDiff($hTimer) > 3000 Then MsgBox(0, "WMPlayer.OCX", $FilePath & @CRLF & @CRLF & "Cannot play this file.", 5) ExitLoop EndIf Sleep(5) WEnd $sFile = StringMid($FilePath, StringInStr($FilePath, "\", 0, -1) + 1) GUICtrlSetData($idSongName, $sFile) $iMediaLength = Int($oPlayer.currentMedia.Duration) ; in seconds GUICtrlSetData($Length, Int($iMediaLength / 60) & ":" & StringFormat("%02i", Mod($iMediaLength, 60))) AdlibRegister("Slider", $adlibInterval) $oPlayer.Controls.Pause While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE $oPlayer.Close Exit Case $PlayButton If GUICtrlRead($PlayButton) = "Play" Then $oPlayer.Controls.Play AdlibRegister("Slider") GUICtrlSetData($PlayButton, "Stop") Else $oPlayer.Controls.currentPosition = 0 $oPlayer.Controls.Pause GUICtrlSetData($PlayButton, "Play") EndIf Case $PauseButton If GUICtrlRead($PauseButton) = "Pause" Then $oPlayer.Controls.Pause AdlibUnRegister() GUICtrlSetData($PauseButton, "Resume") ElseIf GUICtrlRead($PlayButton) <> "Play" And GUICtrlRead($PauseButton) <> "Pause" Then $oPlayer.Controls.Play AdlibRegister("Slider") GUICtrlSetData($PauseButton, "Pause") EndIf Case $GUI_EVENT_PRIMARYDOWN If GUIGetCursorInfo()[4] = $ShuttleButton Then AdlibUnRegister() $x = MouseGetPos(0) $xOffset = $x - $iPos While _IsPressed("01", $hDLL) = 1 $x = MouseGetPos(0) If $x > 380 + $xOffset Then $x = 380 + $xOffset ElseIf $x < $xOffset Then $x = $xOffset EndIf $iPos = $x - $xOffset GUICtrlSetPos($ShuttleButton, $iPos) Sleep(10) WEnd $mediaPos = $iPos / $iSliderLength * $iMediaLength $oPlayer.Controls.currentPosition = $mediaPos $oPlayer.Controls.Play AdlibRegister("Slider", $adlibInterval) ElseIf GUIGetCursorInfo()[4] = $idSongName Then GUICtrlSetPos($ShuttleButton, MouseGetPos(0) - $iShuttleWidth / 2) $x = (MouseGetPos(0) - $iShuttleWidth / 2) / $iSliderLength * $iMediaLength $oPlayer.Controls.currentPosition = $x > $iMediaLength ? $iMediaLength : $x $oPlayer.Controls.Play EndIf EndSwitch If $oPlayer.playState = 1 Then ExitLoop EndIf WEnd Func Slider() $mediaPos = $oPlayer.Controls.currentPosition $iPos = $mediaPos * $iSliderLength / $iMediaLength GUICtrlSetPos($ShuttleButton, $iPos) GUICtrlSetData($Progress, Int($mediaPos / 60) & ":" & StringFormat("%02i", Mod($mediaPos, 60))) EndFunc ;==>Slider
  5. @Nine, Thank you very much, I appreciate your efforts πŸ™πŸ»πŸ™πŸ»β™₯
  6. @NineI think it's easier to work with the button than picture, I am more familiar with the functions of the button. Now I do not know what to do if I want to put the slider in another part of the main source. You didn't even mention the path of the picture in your code and it is complicated for me. I don't want to be lazy, but i there is a way to replace the picture with a button, it will be easier for me to work with.
  7. @Nine thanks. Can't I put a button instead of a picture? I replace line $Shuttle = GUICtrlCreatePic($SliderButton, 0, 0, 20, 20) with: $Shuttle = GUICtrlCreateButton($SliderButton, 0, 0, 20, 20) button moves along with the song but since I don't know about moving button with button/picture, can't fix it.
  8. Ok @Nine, I use just GUIGetMsg() buttons in this code: #include <GuiConstants.au3> #include <Misc.au3> Global $SliderButton = @ScriptDir & "\SliderButton.jpg" $hGui = GUICreate("Music Player", 400, 75, -1, -1) $Label1 = GUICtrlCreateButton("", 0, 0, 400, 20) ;music file name GUICtrlSetState(-1, $GUI_DISABLE) $Shuttle = GUICtrlCreatePic($SliderButton, 0, 0, 20, 20) $PauseButton = GUICtrlCreateButton("Pause", 208, 40, 80, 20) $PlayButton = GUICtrlCreateButton("Play", 112, 40, 80, 20) $Progress = GUICtrlCreateLabel("0:00", 4, 25, 45, 20, $SS_LEFT) ; current media position $Length = GUICtrlCreateLabel("0:00", 350, 25, 45, 20, $SS_RIGHT) ; media length GUISetState(@SW_SHOW) $FilePath = "" ;your music path & .mp3 $oPlayer = ObjCreate("WMPlayer.OCX") If Not IsObj($oPlayer) Then MsgBox(0, "WMPlayer.OCX", "Cannot create a WMP object.", 5) GUIDelete($hGui) Exit EndIf $iPos = 0 ; x coordinate of $Shuttle control in progress bar $hDLL = DllOpen("user32.dll") ; to dectect mouse down on the $Shuttle control $sliderLength = 370 ; in pixels $adlibInterval = 250 ; in milliseconds $oPlayer.URL = "" $mediaLength = 0 $mediaPos = 0 $oPlayer.Settings.Volume = 100 $oPlayer.URL = $FilePath $hTimer = TimerInit() While $oPlayer.playState <> 3 ; 1 - stopped, 2 - paused, 3 - playing If TimerDiff($hTimer) > 3000 Then MsgBox(0, "WMPlayer.OCX", $FilePath & @CRLF & @CRLF & "Cannot play this file.", 5) ExitLoop EndIf Sleep(5) WEnd $sFile = StringMid($FilePath, StringInStr($FilePath, "\", 0, -1) + 1) GUICtrlSetData($Label1, $sFile) $mediaLength = Int($oPlayer.currentMedia.Duration) ; in seconds GUICtrlSetData($Length, Int($mediaLength / 60) & ":" & StringFormat("%02i", Mod($mediaLength, 60))) AdlibRegister("Slider", $adlibInterval) $oPlayer.Controls.Pause While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE $oPlayer.Close Exit Case $PlayButton If GUICtrlRead($PlayButton) = "Play" Then $oPlayer.Controls.Play AdlibRegister("Slider") GUICtrlSetData($PlayButton, "Stop") Else $oPlayer.Controls.currentPosition = 0 $oPlayer.Controls.Pause GUICtrlSetData($PlayButton, "Play") EndIf Case $PauseButton If GUICtrlRead($PauseButton) = "Pause" Then $oPlayer.Controls.Pause AdlibUnRegister() GUICtrlSetData($PauseButton, "Resume") Else $oPlayer.Controls.Play AdlibRegister("Slider") GUICtrlSetData($PauseButton, "Pause") EndIf Case $Shuttle AdlibUnRegister() $x = MouseGetPos(0) $xOffset = $x - $iPos While _IsPressed("01", $hDLL) = 1 $x = MouseGetPos(0) If $x > 380 + $xOffset Then $x = 380 + $xOffset ElseIf $x < $xOffset Then $x = $xOffset EndIf $iPos = $x - $xOffset GUICtrlSetPos($Shuttle, $iPos) Sleep(1) WEnd $mediaPos = $iPos / $sliderLength * $mediaLength $oPlayer.Controls.currentPosition = $mediaPos AdlibRegister("Slider", $adlibInterval) GUICtrlSetData($PauseButton, "Pause") EndSwitch If $oPlayer.playState = 1 Then ExitLoop EndIf WEnd Func Slider() $mediaPos = $oPlayer.Controls.currentPosition $iPos = $mediaPos * $sliderLength / $mediaLength GUICtrlSetPos($Shuttle, $iPos) GUICtrlSetData($Progress, Int($mediaPos / 60) & ":" & StringFormat("%02i", Mod($mediaPos, 60))) EndFunc ;==>Slider Still have the problem with "GUICtrlCreatePic".
  9. Hi, I have a problem with GUICtrlCreatePic(). In topic WMPlayer.ocx how to change the shuttle picture? I wanted to replace the shuttle picture with a custom one (which I sent below the code) but got some weird results. #include <GuiConstants.au3> #include <Misc.au3> Global $Paused = False, $SliderButton = @ScriptDir & "\SliderButton.jpg" $hGui = GUICreate("Music Player", 400, 75, -1, -1) $Label1 = GUICtrlCreateButton("", 0, 0, 400, 20) ;music name GUICtrlSetState(-1, $GUI_DISABLE) $Shuttle = GUICtrlCreatePic($SliderButton, 0, 6, 30, 13) $PauseButton = GUICtrlCreateButton("Pause", 208, 40, 80, 20) GUISetOnEvent($PauseButton, "PauseButton") $PlayButton = GUICtrlCreateButton("Play", 112, 40, 80, 20) $Progress = GUICtrlCreateLabel("0:00", 4, 25, 45, 20, $SS_LEFT) ; current media position $Length = GUICtrlCreateLabel("0:00", 350, 25, 45, 20, $SS_RIGHT) ; media length GUISetState(@SW_SHOW) $FilePath = "" ;your music path & .mp3 $oPlayer = ObjCreate("WMPlayer.OCX") If Not IsObj($oPlayer) Then MsgBox(0, "WMPlayer.OCX", "Cannot create a WMP object.", 5) GUIDelete($hGui) Exit EndIf $iPos = 0 ; x coordinate of $Shuttle control in progress bar $hDLL = DllOpen("user32.dll") ; to dectect mouse down on the $Shuttle control $sliderLength = 380 ; in pixels $adlibInterval = 250 ; in milliseconds $oPlayer.Settings.Volume = 100 While 1 $oPlayer.URL = $FilePath $hTimer = TimerInit() While $oPlayer.playState <> 3 ; 1 - stopped, 2 - paused, 3 - playing If TimerDiff($hTimer) > 3000 Then MsgBox(0, "WMPlayer.OCX", $FilePath & @CRLF & @CRLF & "Cannot play this file.", 5) ExitLoop EndIf Sleep(5) WEnd If $oPlayer.playState <> 3 Then ContinueLoop EndIf $sFile = StringMid($FilePath, StringInStr($FilePath, "\", 0, -1) + 1) GUICtrlSetData($Label1, $sFile) $mediaLength = Int($oPlayer.currentMedia.Duration) ; in seconds GUICtrlSetData($Length, Int($mediaLength / 60) & ":" & StringFormat("%02i", Mod($mediaLength, 60))) AdlibRegister("Slider", $adlibInterval) $oPlayer.Controls.Pause While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE $oPlayer.Close Exit Case $PlayButton If GUICtrlRead($PlayButton) = "Play" Then $oPlayer.Controls.Play AdlibRegister("Slider") GUICtrlSetData($PlayButton, "Stop") Else $oPlayer.Controls.currentPosition = 0 $oPlayer.Controls.Pause GUICtrlSetData($PlayButton, "Play") EndIf If $Paused Then While $Paused Sleep(100) WEnd EndIf Case $Shuttle AdlibUnRegister() $x = MouseGetPos(0) $xOffset = $x - $iPos While _IsPressed("01", $hDLL) = 1 $x = MouseGetPos(0) If $x > 380 + $xOffset Then $x = 380 + $xOffset ElseIf $x < $xOffset Then $x = $xOffset EndIf $iPos = $x - $xOffset GUICtrlSetPos($Shuttle, $iPos) Sleep(1) WEnd $mediaPos = $iPos / $sliderLength * $mediaLength $oPlayer.Controls.currentPosition = $mediaPos AdlibRegister("Slider", $adlibInterval) GUICtrlSetData($PauseButton, "Pause") EndSwitch If $oPlayer.playState = 1 Then ExitLoop EndIf WEnd WEnd Func PauseButton() If $Paused = False Then $oPlayer.Controls.Pause AdlibUnRegister() $Paused = True GUICtrlSetData($PauseButton, "Resume") Else $oPlayer.Controls.Play AdlibRegister("Slider") $Paused = False GUICtrlSetData($PauseButton, "Pause") EndIf EndFunc ;==>PauseButton Func Slider() $mediaPos = $oPlayer.Controls.currentPosition $iPos = $mediaPos * $sliderLength / $mediaLength GUICtrlSetPos($Shuttle, $iPos) GUICtrlSetData($Progress, Int($mediaPos / 60) & ":" & StringFormat("%02i", Mod($mediaPos, 60))) EndFunc ;==>Slider Also how can I set buttons to act like OnEvent button? I tried for $PauseButton but didn't make it. So I didn't do it for $PlayButton and $Shuttle. I want to add some lines from my main source to $PlayButton and since I used while loop in those lines (while the song is not over), I should control song (Pause/Resume, adjust position) anytime I want.
  10. Thanks to @Nine for posting a useful topic, @Melba23 now I can play any .mp3 file with WMPlayer.
  11. Hi guys, I hope you have a good day. _SoundOpen has a problem. I tried the _SoundOpen example script and changed the file path to open some .mp3 files. Works well on some .mp3 files but not all of them (even if the files are in the same path). When a file does not open successfully, MsgBox appears in the ElseIf section. I tried converting .mp3 files to VBR, CBR mp3 and .wav and updating sound card driver but the only solution was to convert .mp3 to .wav. Is there another way to open any .mp3 file? Note that I need the length and position of the sound and SoundPlay is not enough for me.
  12. Ofcourse I used FileOpen and FileClose before and after the loop, but I didn't write "$FO_APPEND". I don't know is it helpful to have faster file writing or not. Perhaps there is a way like using GPU to speed up file writing.
  13. I changed some lines in my code. Now I create the array as much as the intervals exist. And yes, it is related to srt file, I export time from srt and make keyframes. And by file handle, Do you mean I write FileWriteLine (@ScriptDir & "\FileName.txt", ...) instead of ($file, ...) ?
  14. @pixelsearch $i is the value of keyframes and the number in front of it indicates the value of a motion in the aftereffects. I wrote this script to make keyframes in some intervals automatically.
  15. @pixelsearch Your code worked well and did exact the same thing I want. Thank you so much πŸ™Œ
  16. I checked @Subz code, the problem is that the program continues until last index of array, but I want $i to continue longer than this value till it reaches the last value of the array. I did the same thing of all these codes in this topic, even wrote "For $i = 0 To $array [UBound ($array) - 1] [1]" but $i goes more than array index and shows the error "Array variable has incorrect number of subscripts or subscript dimension range exceeded." which is normal. I even tried another "For j = 0 To UBound ($array) - 1" in "For $i = 0 To $array [UBound ($array) - 1] [1]" but it did not work because I didn't know where to write If-Else to write. For $i = 0 To $array[UBound ($array)-1][1] For $j = 0 To UBound ($array)-1 If ($i >= $array [$j][0]) And ($i <= $array[$j][1]) Then FileWriteLine ($file, $i & @TAB & Random (0, $max)) Else FileWriteLine ($file, $i & @TAB & 0) EndIf Next Next
  17. The problem is $i is not equal to the index of array. Therefore, after a while program gives the error of being out of the array index range. sorry for my englishπŸ™ŒπŸΌ
  18. Hi, the problem I have seems simple, but I can't do it properly. There is a unstable 2D array where each row specifies an interval (like the image). I want a variable such as i to start from 0, if it's inside these intervals, a random value should be written in the file, and if it's outside the range (like using else), the value 0 should be written. Also, when the array ends, program ends too. I tried this code: $array[500][2] = [[390, 480], [809, 870], [870, 959], [959, 1139], ...] $i = 0 $max = 60 For $a In $array If ($i >= $a[0]) And ($i <= $a[1]) Then FileWriteLine ($file, $i & @TAB & Random (0, $max)) Else FileWriteLine ($file, $i & @TAB & 0) EndIf Next ;??? where to add $i += 1 I want txt file to be like: 0 0 1 0 ... 390 34.2341.. 391 55.3457.. ... 480 11.7577.. 481 0 482 0 ...
  19. Thanks, JockDundee Is this work for blank lines? and Dan_555, what if I want to know the index of last array? My text contains some blank lines thats why I used if in second while. If $a[$count2] == "" Then
  20. Hello everyone, this is my code: Func Write ($datafromuser) Local $a[0], $count = 0, $count2 = 0 While $count <= 20 _ArrayAdd ($a, $datafromuser, '', @CRLF) $a[$count] = StringStripWS ($a[$count], 2) $count += 1 WEnd While $count2 <= 20 If $a[$count2] == "" Then $count2 += 1 Else MsgBox(0, "title", "a[" & $count2 & "]=" & $a[$count2]) $count2 += 1 EndIf WEnd EndFunc $datafromuser is the text entered to editbox. I wrote msgbox to check my code and it works good, but I could not find any solution to find the number of last line. Autoit has _FileCountLines to calculate last line of a specific file. Is there an order to replace with the number 20? I placed 20 just to test my code.
  21. I found "VideoSubFinder" program for this case. Now I can extract timing srt from hardsub videos. Thank you for your answer πŸ˜‰πŸŒΉ
  22. Thanks! but is there any way to contain milliseconds?
  23. Hi, I want to create an srt file (as you know how to schedule a srt file, for example, 00: 00: 29,633 -> 00: 00: 32,133). The problem is that I do not know a way to count the time at the beginning of the film and record the time of each text. TimerInit () and TimerDiff () only specify the time difference. Please tell me a solution so that I can record the exact time of each text (hr:min:sec,ms). Indicate that I have the text and just want to know the text change through PixelSearch and save the time in a file. Tell me if you know a better way to do this πŸ₯Ί
Γ—
Γ—
  • Create New...