0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[ネタ]フォルダ内に入れた画像でデスクトップ壁紙をコマンドラインから次々変更する[デスクトッププレゼン]

Last updated at Posted at 2022-10-13

概要

  • 特定のフォルダに格納してある".png"の拡張子の画像を矢印キーやスペースキーで次々変えるコマンド書きました。
  • 何かの参考になるかもしれないので、こちらに書いておきます。
  • もしかして、デスクトップ壁紙でプレゼンしてみよう、と考える人が自分以外にもいるのであれば、使えるかもしれません。

コード

リポジトリ

こちらに、C#のコンソールアプリケーションのVisual Studioのソリューションファイルがあります。

https://github.com/hrkt/DesktopPresentationCLI

画像をデスクトップに貼るところ

こちらのサイト(https://www.codeproject.com/Questions/1252479/How-do-I-change-the-desktop-background-using-Cshar)にあったコードをそのまま拝借しました。

キーを受け付けるところ

こんな感じで、いくつかのキーを受け付けることにしました。

while (true)
{
    var ch = Console.ReadKey(false).Key;
    switch (ch)
    {
        case ConsoleKey.Escape:
            Environment.Exit(0);
            break;
        case ConsoleKey.RightArrow:
        case ConsoleKey.Spacebar:
        case ConsoleKey.DownArrow:
            pageIndex = getNextPage(pageIndex, files);
            DisplayPicture(Path.Combine(presentationDir, files[pageIndex]));
            break;
        case ConsoleKey.LeftArrow:
        case ConsoleKey.UpArrow:
            pageIndex = getPreviousPage(pageIndex, files);
            DisplayPicture(Path.Combine(presentationDir, files[pageIndex]));
            break;
    }
}

前提

以下の環境で書きました。

  • Windows 11 Pro 64bit
  • Visual Studio 2022 Community Edition

試してはいませんが、Windows10でも動きそうな気がします。

おわりに

書いて動かしてみて、以下のような所感を持ちました。

いいところ

  • ターミナルからデスクトップ画像をカーソルキーで変えるのは単純に面白い

微妙なところ

  • デスクトップ壁紙でプレゼンしてみようと思ったが、最前面に出ているターミナルが微妙に邪魔。いい感じでちっちゃくすることには現在は限界がある。
    • Windowsターミナルで背景色透明にするなどの工夫はできるものの
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?