Jump to content

Recommended Posts

Posted

Hello, I started autoit few days ago, and I'm trying to do something, but I need to explain first what my script do.

So I have this:

ShellExecute ($path & "\" & $array[Random (1,114,1)])

It executes a random file from the 114 files in the folder's path. So what I'm trying to do, is to save each file it has open in a ini file (just the file array number), so that it will not open it again the next time it will execute. And then when it has opened all files, it deletes all file's number from the ini.

I already searched on google, but even the ShellExecute it was hard to find how, so I'm requesting your help for this.

Thank you in advance for your help ! :D

  • Moderators
Posted

@Elliotest rather than doing Random, if you are just cycling through the array of files, why not just use _ArrayShuffle? You can then cycle through the shuffled array at your leisure.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted

If u are trying to prevent running the same file consecutively use an array to store the file numbers that have been run no need for an ini file unless you need to save these across instances of your script.

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Posted

Sorry for the double post, but how to make my script save the value from the Random $array from the ShellExecute ? This way I could easily save it no ?

Posted

So when I launch the script it doesn't work, in fact it reads only the file that are already opened in the ini. And the problem is that is must do the opposite, if a file is already in the ini, it must not open and open another file. My brain is exploding right now...

Posted (edited)

Can you try something like this:

#include <Array.au3>
#include <File.au3>
#include <FileConstants.au3>

Local $iMusic
Local $sMusic = "C:\Users\Elliotest\Music"
Local $aMusic = _FileListToArrayRec($sMusic,"*.mp3",1, 1, 0, 2)
Local $sShuffle = @ScriptDir & '\Music.ini'

_PlayShuffle(114)

Func _PlayShuffle($iPlayList)
    Local $i = 0
    Do
        $iMusic = Random(1, $aMusic[0], 1)
        If IniRead($sShuffle, "Shuffle", $iMusic, "Unplayed") = "Unplayed" Then
            ShellExecute ($aMusic[$iMusic])
            IniWrite($sShuffle, "Shuffle", $iMusic, $aMusic[$iMusic])
            Sleep (30000)
            WinClose ("[CLASS:QWidget]","")
            $i+=1
        EndIf
    Until $i = $iPlayList
EndFunc

 

Edited by Subz
Changed Random Flag to $aMusic[0]

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...