SetWindowTextW for Unicode SetWindowTextA for English
Dim lPtr As Long If IsWindowUnicode(m_hWnd) Then If Len(sText) = 0 Then SetWindowTextW m_hWnd, StrPtr(vbNullString) Exit Sub End If lPtr = StrPtr(sText) SetWindowTextW m_hWnd, lPtr Else If Len(sText) = 0 Then SetWindowTextA m_hWnd, vbNullString Exit Sub End If SetWindowTextA m_hWnd, sText End If
Private Declare Function IsWindowUnicode Lib "user32.dll" (ByVal hWnd As Long) As Long Private Declare Function SetWindowTextW Lib "user32.dll" (ByVal hWnd As Long, ByVal lpString As Long) As Long Private Declare Function SetWindowTextA Lib "user32.dll" (ByVal hWnd As Long, ByVal lpString As String) As LongStrPtr不需要特别申明,VB6支持。
直接通过API函数发送
SendMessage lngHwndTemp, WM_SETTEXT, 0&, strCode
SetWindowTextA for English
If Len(sText) = 0 Then
SetWindowTextW m_hWnd, StrPtr(vbNullString)
Exit Sub
End If
lPtr = StrPtr(sText)
SetWindowTextW m_hWnd, lPtr
Else
If Len(sText) = 0 Then
SetWindowTextA m_hWnd, vbNullString
Exit Sub
End If
SetWindowTextA m_hWnd, sText
End If
rainstormmaster:能告訴怎樣用sendkeys發送中文嗎?
我用sendkey發送中文到java窗口會出現亂碼現象
VBAdvisor(Sunlight):
能給我一個比較完整的例子嗎?
我API不太會用
IsWindowUnicode/StrPtr 我找不到
Private Declare Function SetWindowTextW Lib "user32.dll" (ByVal hWnd As Long, ByVal lpString As Long) As Long
Private Declare Function SetWindowTextA Lib "user32.dll" (ByVal hWnd As Long, ByVal lpString As String) As LongStrPtr不需要特别申明,VB6支持。
可以手工用剪貼板粘貼中文輸入.
我有在網上有找一些例子,試過sendmessage 和剪貼板,但都沒有實現我要的結果
sText 要什麼類型啊?
我用string好象沒效果
sText="Who I am?”
用GetFocus的hwnd沒反應