首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

PostMessage小弟我这个什么地方错了

2012-01-23 
PostMessage我这个什么地方错了?PrivateDeclareFunctionPostMessageLibuser32 AliasPostMessageA (ByV

PostMessage我这个什么地方错了?
Private   Declare   Function   PostMessage   Lib   "user32 "   Alias   "PostMessageA "   (ByVal   hwnd   As   Long,   ByVal   wMsg   As   Long,   ByVal   wParam   As   Long,   ByVal   lParam   As   Long)   As   Long
Private   Const   VK_RETURN   =   &HD

Private   Sub   Command2_Click()
Dim   hdl   As   Long
hdl   =   GetForegroundWindow   '   hdl   is   the   handle   to   the   foreground   window
'AppActivate   ( "1.txt   -   记事本 ")
PostMessage   hdl,   VK_RETURN,   0,   0
End   Sub

我这个什么地方错了?

[解决办法]
你在PostMessage之前要先连接到目标队列的输入线程
AttachThreadInput API
[解决办法]



Private Declare Function PostMessage Lib "user32 " Alias "PostMessageA " (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const WM_CHAR = &H102


'Text3.Text 的数字是目标文本框的HWND

Call PostMessage(CLng(Text3.Text), WM_KEYDOWN, 13, 0)


绝对可以的。


热点排行