コード例 #1
0
ファイル: Screenshoter.cs プロジェクト: ajhyndman/heroesdb-be
        public void Screenshot()
        {
            Debug.WriteLine("Screenshot() {");
            Debug.Indent();
            var window = WinUser.FindWindow("Valve001", null);

            if (window == IntPtr.Zero)
            {
                Debug.WriteLine("window not found");
                return;
            }
            if (!Directory.Exists(this.config.InjectDestinationPath))
            {
                Directory.CreateDirectory(this.config.InjectDestinationPath);
            }
            if (Directory.Exists(this.config.ScreenshotSourcePath))
            {
                foreach (var file in Directory.GetFiles(this.config.ScreenshotSourcePath))
                {
                    File.Delete(file);
                }
            }
            var characters = new DataTable();

            using (var connection = new SQLiteConnection(this.config.ConnectionString)) {
                connection.Open();
                var command = connection.CreateCommand();
                command.CommandText = @"
					SELECT
						c.ID,
						c.Name
					FROM HDB_Characters AS c
					WHERE
						c.ID IN (
							SELECT es.CharacterID
							FROM HDB_EquipScreenshots AS es
							WHERE es.Ready = 0
						) OR
						c.ID IN (
							SELECT ss.CharacterID
							FROM HDB_SetScreenshots AS ss
							WHERE ss.Ready = 0
						)
					ORDER BY
						CASE WHEN c.ID IN (4, 8, 64, 256) THEN 1 WHEN c.ID IN (2, 16, 32, 128) THEN 2 WHEN c.ID IN (1, 512, 1024) THEN 3 ELSE 4 END,
						c.ID;
				"                ;
                var reader = command.ExecuteReader();
                characters.Load(reader);
            }
            foreach (DataRow character in characters.Rows)
            {
                Console.WriteLine("Initialize {0} for screenshots and press [Enter] or any other key to skip.", character["Name"]);
                Console.Beep();
                var key = Console.ReadKey();
                if (key.Key == ConsoleKey.Enter)
                {
                    WinUser.ShowWindow(window, WinUser.SW_RESTORE);
                    WinUser.SetForegroundWindow(window);
                    this.setInitialCamera();
                    this.ScreenshotSets(Convert.ToInt32(character["ID"]));
                    this.ScreenshotEquips(Convert.ToInt32(character["ID"]));
                }
            }
            Directory.Delete(this.config.InjectDestinationPath, true);
            Debug.Unindent();
            Debug.WriteLine("}");
        }
コード例 #2
0
ファイル: Screenshoter.cs プロジェクト: ajhyndman/heroesdb-be
 private void sendInput(WinUser.INPUT input, Int32 delay = 50)
 {
     System.Threading.Thread.Sleep(delay);
     WinUser.SendInput(1, new [] { input }, Marshal.SizeOf(typeof(WinUser.INPUT)));
 }