Keyboard Example - Soju06/Input GitHub Wiki

ํ‚ค๋ณด๋“œ ์˜ˆ์ œ

Hook

  • ํ˜„์žฌ ์ค€๋น„๋œ ์˜ˆ์ œ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.

Simulation

  • Simple Keyboard - ๋ฉ”๋ชจ์žฅ์„ ํ‚ค๊ณ  Hello, World!๋ฅผ ์ž…๋ ฅํ•˜๋Š” ์˜ˆ์ œ์ž…๋‹ˆ๋‹ค.

      using Input;
      using System.Diagnostics;
    
      Debug.WriteLine("Hello, World!");
    
      // ํ‚ค๋ณด๋“œ ์‹œ๋ฎฌ๋ ˆ์ด์…˜๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค.
      // ๋งŒ์•ฝ ์ง€์›ํ•˜์ง€ ์•Š๋Š” ํ”Œ๋žซํผ์ธ ๊ฒฝ์šฐ NotSupportedException ์˜ˆ์™ธ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
      var simulation = Inputs.Use<IKeyboardSimulation>();
    
      // ๋””๋ฒ„๊ทธ๋ฅผ ํ™œ์„ฑํ™” ํ•ฉ๋‹ˆ๋‹ค.
      // ๋„ค์ดํ‹ฐ๋ธŒ ์˜ค๋ฅ˜๋ฅผ ๋””๋ฒ„๊ทธ ์ถœ๋ ฅ ์ฐฝ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
      simulation.Debug = true;
    
      //  ๋ฉ”๋ชจ์žฅ์„ ํ‚ค๊ณ  Hello, World!๋ฅผ ์ž…๋ ฅํ•˜๋Š” ์˜ˆ์ œ์ž…๋‹ˆ๋‹ค.
      // Win + R  ์‹คํ–‰ ์ฐฝ์„ ์—ฝ๋‹ˆ๋‹ค.
      simulation.KeyClick(InputKeys.LeftApplication, InputKeys.R);
    
      await Task.Delay(1000);
    
      // notepad๋ฅผ ์ž…๋ ฅ ํ›„ Enterํ•ฉ๋‹ˆ๋‹ค.
      simulation.TextEntry("notepad");
    
      await Task.Delay(1000);
    
      simulation.KeyClick(InputKeys.Enter);
    
      await Task.Delay(2000);
    
      // Hello, World!๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.
      simulation.TextEntry("Hello, World!");
    
      await Task.Delay(500);
    
      // Enter ํ›„ WA SANS๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.
      simulation.KeyClick(InputKeys.Enter);
      simulation.KeyDown(InputKeys.LeftShift);
      simulation.KeyClick(InputKeys.W);
      simulation.KeyClick(InputKeys.A);
      simulation.KeyClick(InputKeys.Space);
      simulation.KeyClick(InputKeys.S);
      simulation.KeyClick(InputKeys.A);
      simulation.KeyClick(InputKeys.N);
      simulation.KeyClick(InputKeys.S);
      simulation.KeyUp(InputKeys.LeftShift);
    

    ์›๋ณธ ์˜ˆ์ œ๋Š” ์—ฌ๊ธฐ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.