2
2

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 5 years have passed since last update.

IronRuby で クリップボードを使う

Posted at

.Net Framework では System.Windows.Clipboard に クリップボードを扱うクラスがある。しかし、IronRuby で require ‘System.Window’ としても、no such file to load – System.Windows (LoadError) となる。
msdn のWEBリファレンスを確認すると、Assembly: PresentationCore (in PresentationCore.dll) という記述がある。IronRubyのLibにもPresentationCore.rbがあるのでこれを使う。

clipbord.rb
# coding : windows-31j
require 'PresentationCore'
require 'System.Windows.Forms'

System::Windows::Clipboard.SetText("あいうえお") #=> クリップボードに"あいうえお"をセットする。

Thread.start { system("notepad.exe") } #=> 貼り付け用アプリ起動 

sleep 1 #=> notepad.exeが起動するまでスリープ ( きっと別の良い方法があるはずだが、今回は保留 )

System::Windows::Forms::SendKeys.SendWait('^V') #=> ^Vを送信することで、Ctrl + V となる。
2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?