예제 #1
0
 public YoutubeEmbeddedPage(IWebDriver seleniumWebDriver) : base(seleniumWebDriver)
 {
     QualityAcceleratedLink = new Link(By.CssSelector("a[class='service_second_menu-list_link js-service_second_menu-list_link'][href='#header2']"), seleniumWebDriver);
     Screen                             = Sikuli.CreateSession();
     PlayButtonPattern                  = Patterns.FromFile(ImagePath + "\\Images\\play.png");
     PauseButtonPattern                 = Patterns.FromFile(ImagePath + "\\Images\\pause.png");
     MuteButtonPattern                  = Patterns.FromFile(ImagePath + "\\Images\\mute.png");
     UnmuteButtonPattern                = Patterns.FromFile(ImagePath + "\\Images\\unmute.png");
     SettingButtonPattern               = Patterns.FromFile(ImagePath + "\\Images\\setting.png");
     QualityButtonPattern               = Patterns.FromFile(ImagePath + "\\Images\\quality.png");
     FourEightZeroButtonPattern         = Patterns.FromFile(ImagePath + "\\Images\\480p.png");
     FourEightZeroSelectedButtonPattern = Patterns.FromFile(ImagePath + "\\Images\\480pselected.png");
 }
 public void TestSikuliIntegration()
 {
     try
     {
         session  = Sikuli.CreateSession();
         patterns = Patterns.FromFile(@"C:\Data\win.PNG");
         if (session.Exists(patterns))
         {
             Console.WriteLine("Patteren Exist " + patterns.ToString());
             session.Wait(patterns, 60);
             session.Click(patterns);
         }
     }
     finally
     {
         session?.Dispose();
     }
 }
        public void MakeReplays()
        {
            if (!IsBusy && Matches.Count > 0)
            {
                IsBusy = true;

                Task T = Task.Factory.StartNew(() =>
                {
                    CurrentMatch        = Matches.Dequeue();
                    CurrentMatch.Status = "Replay In Progress";
                    string imagePath    = HttpRuntime.AppDomainAppPath + "Images\\";
                    using (ISikuliSession session = Sikuli.CreateSession())
                    {
                        //session.Click(Patterns.FromFile(imagePath + "CloseButton.PNG"));
                        WaitAndClick(session, imagePath + "WatchButton.PNG");
                        WaitAndClick(session, imagePath + "WatchButton.PNG");
                        WaitAndClick(session, imagePath + "ReplaysButton.PNG");
                        WaitAndClick(session, imagePath + "MatchIds.PNG");
                        session.Type(CurrentMatch.MatchId);
                        WaitAndClick(session, imagePath + "SearchButton.PNG");
                        WaitAndClick(session, imagePath + "DownloadReplayButton.PNG");
                        WaitAndClick(session, imagePath + "MatchIdText.PNG");
                        WaitAndClick(session, imagePath + "WatchReplayButton.PNG", .9F);
                        StartStopRecording();

                        WaitAndClick(session, imagePath + "CollapseButton.PNG", .7f, 300);
                        //Wait 2 hours at most
                        //session.Wait(Patterns.FromFile(imagePath + "WatchReplayButton.PNG"), 7200);
                        try
                        {
                            session.Wait(Patterns.FromFile(imagePath + "WatchReplayButton.PNG"), 60);
                        }
                        catch { };
                        StartStopRecording();
                        //Wait 1 second for the sake of shadowplay's save
                        Thread.Sleep(1000);
                    }
                    //Cleanup Replay File
                    File.Delete(@"D:\Program Files (x86)\Steam\steamapps\common\dota 2 beta\game\dota\replays\" + CurrentMatch.MatchId + ".DEM");
                    CurrentMatch.Done = true;
                    CurrentMatch.ProgressPercentage = 100;
                    LastCompletedMatch  = CurrentMatch;
                    CurrentMatch        = null;
                    IsBusy              = false;
                    CurrentMatch.Status = "Replay Uploading";
                    YoutubeUploader.UploadToYoutube();
                    MakeReplays();
                });
            }

            //Task to give a rough idea of replay progress
            Task progressUpdator = Task.Factory.StartNew(() =>
            {
                DateTime startTime = DateTime.Now;
                while (CurrentMatch != null && !CurrentMatch.Done)
                {
                    CurrentMatch.ProgressPercentage = DateTime.Now.Subtract(startTime).Seconds / int.Parse(CurrentMatch.Duration);
                    Thread.Sleep(2000);
                }
            });
        }
 private void WaitAndClick(ISikuliSession session, string fileName, float matchPercentage = .7f, int waitSeconds = 120)
 {
     session.Wait(Patterns.FromFile(fileName, matchPercentage), waitSeconds);
     session.Click(Patterns.FromFile(fileName, matchPercentage));
 }
예제 #5
0
 public void Setup()
 {
     session = Sikuli.CreateSession();
     notepad = Process.Start("notepad.exe");
 }
 public static void CreateSession()
 {
     session = SikuliSharp.Sikuli.CreateSession();
 }
예제 #7
0
 public static ISikuliSession CreateSession()
 {
     Session = Sikuli.CreateSession();
     return(Session);
 }
예제 #8
0
 /// <summary>
 /// Initialzie the sessions for the Runner
 /// </summary>
 public static void InitializeSession()
 {
     _session           = Sikuli.CreateSession();
     SessionInitialized = true;
 }
예제 #9
0
 public static void CreateSession()
 {
     Session = Sikuli.CreateSession();
 }