Sign in to follow this  
Followers 0
Solomon

Controlling 1by1 with AutoIt

4 posts in this topic

I'm using AutoIt to control 1by1. I'm using it to make it start auto it, play a hypnosis mp3 and then either quit 1by1 or shutdown the computer. By using the following code, I have the functionality I want.

If ProcessExists("1by1.exe") Then ProcessClose("1by1.exe")
ProcessWaitClose("1by1.exe")
FileCopy("F:\1by1\1by1.ini", "F:\1by1\1by1.bak", 1)
$track = IniRead("G:\Standalones\Hypnosis Runner\hypnosis.ini", "autoit", "tape", "ValueNotFound")
$power = IniRead("G:\Standalones\Hypnosis Runner\hypnosis.ini", "track", "power", "ValueNotFound") 
$owners = IniRead("G:\Standalones\Hypnosis Runner\hypnosis.ini", "track", "owners", "ValueNotFound")
$self = IniRead("G:\Standalones\Hypnosis Runner\hypnosis.ini", "track", "self", "ValueNotFound")
$goal = IniRead("G:\Standalones\Hypnosis Runner\hypnosis.ini", "track", "goal", "ValueNotFound")
$genius = IniRead("G:\Standalones\Hypnosis Runner\hypnosis.ini", "track", "genius", "ValueNotFound")
$perspective = IniRead("G:\Standalones\Hypnosis Runner\hypnosis.ini", "track", "perspective", "ValueNotFound")
$wealth = IniRead("G:\Standalones\Hypnosis Runner\hypnosis.ini", "track", "wealth", "ValueNotFound")
$health = IniRead("G:\Standalones\Hypnosis Runner\hypnosis.ini", "track", "health", "ValueNotFound")
$happiness = IniRead("G:\Standalones\Hypnosis Runner\hypnosis.ini", "track", "happiness", "ValueNotFound")
$soulmate = IniRead("G:\Standalones\Hypnosis Runner\hypnosis.ini", "track", "soulmate", "ValueNotFound")
$confidence = IniRead("G:\Standalones\Hypnosis Runner\hypnosis.ini", "track", "confidence", "ValueNotFound")
$sleep = IniRead("G:\Standalones\Hypnosis Runner\hypnosis.ini", "track", "sleep", "ValueNotFound")
$fit = IniRead("G:\Standalones\Hypnosis Runner\hypnosis.ini", "track", "fit", "ValueNotFound")
If $track = "power" then IniWrite("f:\1by1\1by1.ini", "1by1", "last_file", $power)
If $track = "owners" then IniWrite("f:\1by1\1by1.ini", "1by1", "last_file", $owners)
If $track = "self" then IniWrite("f:\1by1\1by1.ini", "1by1", "last_file", $self)
If $track = "goal" then IniWrite("f:\1by1\1by1.ini", "1by1", "last_file", $goal)
If $track = "genius" then IniWrite("f:\1by1\1by1.ini", "1by1", "last_file", $genius)
If $track = "perspective" then IniWrite("f:\1by1\1by1.ini", "1by1", "last_file", $perspective)
If $track = "wealth" then IniWrite("f:\1by1\1by1.ini", "1by1", "last_file", $wealth)
If $track = "health" then IniWrite("f:\1by1\1by1.ini", "1by1", "last_file", $health)
If $track = "happiness" then IniWrite("f:\1by1\1by1.ini", "1by1", "last_file", $happiness)
If $track = "soulmate" then IniWrite("f:\1by1\1by1.ini", "1by1", "last_file", $soulmate)
If $track = "confidence" then IniWrite("f:\1by1\1by1.ini", "1by1", "last_file", $confidence)
If $track = "sleep" then IniWrite("f:\1by1\1by1.ini", "1by1", "last_file", $sleep)
If $track = "fit" then IniWrite("f:\1by1\1by1.ini", "1by1", "last_file", $fit)
Run("f:\1by1\1by1.exe")
WinWaitActive("1by1 - The Directory Player")
If Not WinActive("1by1 - The Directory Player") then WinActivate("1by1 - The Directory Player")
Send("{ENTER}")
$quit = IniRead("G:\Standalones\Hypnosis Runner\hypnosis.ini" , "autoit", "quit", "ValueNotFound")
If $quit = "1" Then Send("^q")
While ProcessExists("1by1.exe")
    Sleep(1000)
WEnd
FileDelete("f:\1by1\1by1.ini")
FileCopy("f:\1by1\1by1.bak", "f:\1by1\1by1.ini")
$shutdown = IniRead("hypnosis.ini", "autoit", "shutdown", "ValueNotFound")
If $shutdown = "1" Then Shutdown(9)
If $shutdown = "0" Then Exit

Any previous instance of 1by1 is exited. Any settings are saved, then the script reads the .ini file and plays the relevant mp3. Once the track is played, the original settings are restored, and then the computer is shut down if necessary.

The problem I have is that sometimes, I might wish to play multiple tracks. I can use Ctrl+Q to make 1by1 quit after the current track, but how do I make it wait until the second track is running before I "Send("^q")"? I've looked into 1by1's handling of playlists, but I'm still hitting the wall of making it wait until the second track is playing.

I'm really open to ideas on this one.

Share this post


Link to post
Share on other sites



is there any way to do this manually?

1by1 will natively play every file in a folder, in order. I can Send("{ENTER}") to make it play the first track, but it's making it wait until the last track is playing before telling it to quit that is the problem. There's no way to make it play a folder and then quit, or I could just FileCopy the files into a temporary folder and Send("^q") to 1by1, making it close itself. I hope I'm understanding your question correctly?

AutoIt has a SoundPlay function.

I forgot about that. Thank you. I might look into that.

you could use, WinGetTitle("[CLASS:1by1WndClass]"), to scan for any changes in the tile-bar of the 1by1 window.

Related Help -> Using AutoIt: Window Titles and Text (Advanced)

I see. So I could write the name of the 1by1 window to the .ini file once the first track is playing, and then make it check every X seconds to see if it's different?

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0