掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
Timerイベントからはクリップボードの取得をする方法は? (ID:89693)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
Timerイベントからはクリップボードの取得をする方法は? 環境はVB.net2003です。 http://www.microsoft.com/japan/msdn/library/default.asp?url=/japan/msdn/library/ja/cpref/html/frlrfsystemthreadingtimerclasstopic.asp ここを参考にTimerを利用して一定時間ごとに処理をしています。 これ単体ではうまくいっています。 http://dobon.net/vb/dotnet/string/clipboard.html また、ここを参考にクリップボードの中身を取得するという処理を試しました。 単純な取得は成功しています。 しかしTimerを利用して一定時間ごとにクリップボードの中身を取得し、 表示しようと思ったのですが、必ずNothingになってしまいます。 その間もコピー&ペーストは正常に行えます。 ので、あくまでもTimerとクリップボードの組み合わせの処理のときがうまくいかないのです。 ご教授よろしくお願いします。 ' ロード時メソッドの中に記述 Dim s As New TimerExampleState ' Create the delegate that invokes methods for the timer. Dim timerDelegate As New TimerCallback(AddressOf showStatus) ' Create a timer that waits one second, then invokes every second. Dim timer As New timer(timerDelegate, s, 1000, 1000) Private Sub showStatus(ByVal state As Object) Dim tmpStr As String Dim iData As IDataObject = Clipboard.GetDataObject() If iData Is Nothing Then tmpStr = "Nothing" ElseIf iData.GetDataPresent(DataFormats.Text) = False Then tmpStr = "Not Text" Else tmpStr = CType(iData.GetData(DataFormats.Text), String) End If Console.WriteLin(tmpStr) End Sub Class TimerExampleState Public counter As Integer = 0 Public tmr As Timer End Class 'TimerExampleState
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.