怎樣實現從VB程式向java窗口發送中文字串

aperyx 2007-06-01 05:03:17
我想實現從VB程式向發java窗口發送中文字串
不知如何實現?請不吝賜教
用sendkeys只能實現發送英文的
...全文
340 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
aperyx 2007-06-25
  • 打赏
  • 举报
回复
自己頂一下,期待解決
aperyx 2007-06-11
  • 打赏
  • 举报
回复
我用GetForegroundWindow的hwnd,但結果是將stext的內容發到窗口的標題
用GetFocus的hwnd沒反應
VBAdvisor 2007-06-08
  • 打赏
  • 举报
回复
sText就是你要发送的字符串。
sText="Who I am?”
aperyx 2007-06-08
  • 打赏
  • 举报
回复
VBAdvisor(Sunlight):
sText 要什麼類型啊?
我用string好象沒效果
aperyx 2007-06-08
  • 打赏
  • 举报
回复
我是把資料往oracle 的程式中輸入,
可以手工用剪貼板粘貼中文輸入.
我有在網上有找一些例子,試過sendmessage 和剪貼板,但都沒有實現我要的結果

VBAdvisor 2007-06-08
  • 打赏
  • 举报
回复
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 Long

StrPtr不需要特别申明,VB6支持。

rainstormmaster 2007-06-08
  • 打赏
  • 举报
回复
另外,你的测试程序可以粘贴中文吗?可以的话,建议从剪贴板入手解决
rainstormmaster 2007-06-08
  • 打赏
  • 举报
回复
//rainstormmaster:能告訴怎樣用sendkeys發送中文嗎?

和发送英文没什么区别

我估计可能是编码问题,给个你用的java程序的下载地址
aperyx 2007-06-08
  • 打赏
  • 举报
回复
VBAdvisor(Sunlight):
能給我一個比較完整的例子嗎?
我API不太會用
IsWindowUnicode/StrPtr 我找不到
aperyx 2007-06-08
  • 打赏
  • 举报
回复
Sorry,前幾天硬盤掛了,現在才好
rainstormmaster:能告訴怎樣用sendkeys發送中文嗎?
我用sendkey發送中文到java窗口會出現亂碼現象


VBAdvisor(Sunlight):
VBAdvisor 2007-06-05
  • 打赏
  • 举报
回复
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
VBAdvisor 2007-06-05
  • 打赏
  • 举报
回复
SetWindowTextW for Unicode
SetWindowTextA for English
  • 打赏
  • 举报
回复
或者发送WM_COPYDATA 消息
CathySun118 2007-06-03
  • 打赏
  • 举报
回复
根据窗口句柄,发消息
yangao 2007-06-01
  • 打赏
  • 举报
回复
可以查找到对应窗口的句柄
直接通过API函数发送
SendMessage lngHwndTemp, WM_SETTEXT, 0&, strCode
rainstormmaster 2007-06-01
  • 打赏
  • 举报
回复
//用sendkeys只能實現發送英文的

为什么?

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧