Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- using System.IO;
- /// <summary>
- /// <para>A simple program that detects the user's song, and edits a .txt file with the song name.</para>
- /// </summary>
- namespace osuBrandon
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Title = "Osu! Stream Song Reciever";
- string sDirectory = @"D:\Games\OSU";
- string sPath = @"D:\Games\OSU\actualsong.txt";
- string sOld_Song = String.Empty;
- string sNew_Song = String.Empty;
- // Create Directory if it doesn't exist...
- if (!Directory.Exists(sDirectory))
- {
- Directory.CreateDirectory(sDirectory);
- }
- // Loop to check song change...
- while (true)
- {
- Process[] p = Process.GetProcessesByName("osu!");
- try
- {
- sNew_Song = p[0].MainWindowTitle.Substring(8, (p[0].MainWindowTitle.Length - 8));
- }
- catch (Exception e)
- {
- // Selecting song...
- continue;
- }
- if ((sOld_Song != sNew_Song) || (sOld_Song == String.Empty) && (sNew_Song == String.Empty))
- {
- Console.WriteLine(sNew_Song);
- // Write song name into the text file...
- using (TextWriter tw = File.CreateText(sPath))
- {
- tw.WriteLine(sNew_Song);
- tw.Close();
- }
- }
- sOld_Song = sNew_Song;
- // 500 ms break
- System.Threading.Thread.Sleep(500);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement