我試了一下 ImmSimulateHotKey 如下:
可是不能作用, 是不是它只能針對程式本身,而不能控制其它程式呢?
'// 開/關 輸入法
Public Sub IMESwitch(isOpen As Boolean)
Dim pid As Long, hkb5 As Long
 Dim hwnd5 As Long
 Dim hthr As Long

'// 取得前景視窗hwnd, 及作用中的threadID
 hwnd5 = GetForegroundWindow()
 hthr = GetWindowThreadProcessId(hwnd5, pid)
 
 '// 取得該threadId的keyboardLayout
 hkb5 = GetKeyboardLayout(hthr)

'// 希望打開
 If isOpen Then
  '// 目前為關閉
  If ImmIsIME(hkb5) <> 1 Then
   ImmSimulateHotKey hthr, IME_THOTKEY_IME_NONIME_TOGGLE
  End If
 
 '// 希望關閉
 Else
  '// 目前為打開
  If ImmIsIME(hkb5) = 1 Then
   ImmSimulateHotKey hthr, IME_THOTKEY_IME_NONIME_TOGGLE
  End If
 End If

End Sub
arrow
arrow
    全站熱搜

    vbqa 發表在 痞客邦 留言(0) 人氣()