各位大侠,小弟菜鸟,因工作需要,临时捉刀,需要一个小软件实现这样一个功能,软件启动,在系统中注册一个全局热键,然后,每当按这个热键的时候,程序自动的在光标当前位置(网页,程序文本框,记事本程序等)输入系统时间戳。
我的全部代码如下:Public Class Main
Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As Integer, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer
Declare Function WindowFromPoint Lib "user32" (ByVal xPonit As Integer, ByVal yPonit As Integer) As IntPtr
Private Declare Function GetCursorPos Lib "user32" (ByRef lpPoint As POINTAPI) As Integer
Private Declare Function SendMessage Lib "user32" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer
Public Const MOD_ALT = &H1
Public Const WM_SETTEXT = &HC
Private Structure POINTAPI
Dim x As Integer
Dim y As Integer
End Structure
Public Sub ww()
Dim a As POINTAPI
Dim b As IntPtr
Dim bb As Long
GetCursorPos(a)
b = WindowFromPoint(a.x, a.y)
Label2.Text = b
bb = CLng(b)
SendMessage(b, WM_SETTEXT, 0, CStr(Now))
End Sub Public Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, Timer1.Tick
RegisterHotKey(Handle, 101, MOD_ALT, Keys.R)
End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = 786 Then
If m.WParam.ToInt32 = 101 Then
'MsgBox(CStr(Now))
Label1.Text = CStr(Now)
Call ww()
End If
End If
MyBase.WndProc(m)
End SubEnd Class
运行时竟然会提示“Unable to find an entry point named 'SendMessage' in DLL 'user32'.”。快崩溃了大侠们帮帮忙啊…………谢谢各位了,问题究竟出在哪里呢
我的全部代码如下:Public Class Main
Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As Integer, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer
Declare Function WindowFromPoint Lib "user32" (ByVal xPonit As Integer, ByVal yPonit As Integer) As IntPtr
Private Declare Function GetCursorPos Lib "user32" (ByRef lpPoint As POINTAPI) As Integer
Private Declare Function SendMessage Lib "user32" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer
Public Const MOD_ALT = &H1
Public Const WM_SETTEXT = &HC
Private Structure POINTAPI
Dim x As Integer
Dim y As Integer
End Structure
Public Sub ww()
Dim a As POINTAPI
Dim b As IntPtr
Dim bb As Long
GetCursorPos(a)
b = WindowFromPoint(a.x, a.y)
Label2.Text = b
bb = CLng(b)
SendMessage(b, WM_SETTEXT, 0, CStr(Now))
End Sub Public Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, Timer1.Tick
RegisterHotKey(Handle, 101, MOD_ALT, Keys.R)
End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = 786 Then
If m.WParam.ToInt32 = 101 Then
'MsgBox(CStr(Now))
Label1.Text = CStr(Now)
Call ww()
End If
End If
MyBase.WndProc(m)
End SubEnd Class
运行时竟然会提示“Unable to find an entry point named 'SendMessage' in DLL 'user32'.”。快崩溃了大侠们帮帮忙啊…………谢谢各位了,问题究竟出在哪里呢
解决方案 »
- can't use a public user define type wthin a private object module啥意思
- 我初学VB,请大家帮帮忙,谢谢了
- 分页问题,请高手指教,做了一个星期未果?
- 用什么方法同时画两条直线?
- 请问VB程序怎么安装好啊
- 我將中文附給一個string變量,通過OBDC存到Oracle,再select 回來顯示,但總是顯示亂碼。賜教
- 寻找合作者
- 大家一般用什么方法保存软件运行时需要,或者生成的数据。
- 许大哥,我在这里
- VB+数据库的问题????
- 这些简单代码什么意思啊??每行都解析下。谢谢先!
- 实时错误 3001 ,参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32