2013-08-29 36 views
-1

順便用VB。將sendkeys用於符號

當我點擊一個按鈕時,我輸入一個符號%^()。當我勾選它(CheckedListBox1)並按開始(按鈕1),它會在記事本上發送垃圾信息,但它不會這樣做。我猜它需要被轉換,或者需要聲明代碼來識別該符號被按下。基本上,我想要的是我放入的任何東西,與OUT相同。

私人小組Timer1_Tick(BYVAL發件人爲System.Object的,BYVALË作爲System.EventArgs)把手Timer1.Tick 上的錯誤繼續下一步

If CheckBox1.Checked = True Then 'Only Checked Items of the CheckedListbox 

     If IntCount > CheckedListBox1.CheckedItems.Count - 1 Then 'If the index is higher then the max. index of the checkedlistbox 
      IntCount = 0 ' The index will reset to 0 
     End If 
     SendKeys.SendWait(CheckedListBox1.CheckedItems(IntCount).ToString & "{ENTER}") 'Send keys to the active windows 
     IntCount += 1 'Goto the next line 

    Else 'All items 

     If IntCount > CheckedListBox1.Items.Count - 1 Then 'If the index is higher then the max. index of the checkedlistbox 
      IntCount = 0 ' The index will reset to 0 
     End If 
     SendKeys.SendWait(CheckedListBox1.Items(IntCount).ToString & "{ENTER}") 'Send keys to the active windows 
     IntCount += 1 'Goto the next line 

    End If 
+1

特殊字符,如%^需要圍繞他們'SendKeys.Send'大括號字面上給他們,因爲他們另有其他含義(%ALT鍵,^ CTRL鍵),所以{%}應該可以工作 –

+0

裏面沒有代碼.. –

回答

-1

我假設你只想發送鍵到記事本,如果會爲SendKeys語法是正確的,下面的提示應該使用的SendKeys發送你的鑰匙..

第一激活記事本窗口。通過添加以下代碼到Button:

AppActivate("Untitled - Notepad") 

後,送你的鑰匙..

則代碼應該將它們發送到記事本..

+0

對不起,但那不是我要找的。我試圖找到一種方法讓程序認識到在文本框中我已經放了一個符號「%」,而當我點擊「開始」播放它時,它會顯示「%」,而不是隻是略過它。這和其他一些符號是這樣的,但是當涉及到數字和字母時,它很好。例如,如果我想說「增加100%」,請輸入它並點擊「開始」,它會顯示「增加100」。明白了嗎? – Serendipitepic

0

加號(+),插入符號(^),百分號(%),代字符(〜)和 括號()對SendKeys有特殊的含義。要指定這些字符的其中之一,請將其括入大括號({})中。例如,要指定 指定加號,請使用「{+}」。

來源MSDN SendKeys.Send Method

+0

您可以在http://www.aformfiller.com/helpv310.html#change上看到需要{}的完整列表。除了{!}之外,所有應該工作的時間爲1/4秒,這是一個特殊的命令爲在網站鏈接描述的節目 – Rob