1.sendmessage怎么在易语言中让它找到指定窗口然后发送按键消息而且支持后台的哦谢谢大家帮忙解决解决吧!
2.vb问题:希望可以给代码
3.为什么用::SendMessage(m_hWnd, BM_GETSTATE, 0, 0)这个函数将如何完成它的功能的?
4.androidçHandlerä¸sendEmptyMessageä¸sendMessageçåºå«ï¼
5.VB Instr
sendmessage怎么在易语言中让它找到指定窗口然后发送按键消息而且支持后台的哦谢谢大家帮忙解决解决吧!
发送按键消息用这个命令:ndmessage(你要接收消息的展示网站 源码窗口句柄,自定义消息,0,0)
而支持后台的话,你用了时钟去循环执行,就已经可以后台了。遥控风扇 源码
关键在于找到指定的金线源码窗口,一般窗口所属进程的名称是不变的,那就可以从进程名取出窗口句柄,然后就sendmessage就行了。
值得一提的是这个方法用来对付网络游戏不一定管用,网络游戏开发者有一定的防范措施的!
你可以用来对付系统记事本测试一下程序是否有效
vb问题:希望可以给代码
先新建一个模块,里面添加API声明
Option Explicit
Declare Function MoveWindow Lib "user" (ByVal hwnd As Long,导航源码html ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Declare Function SendMessage Lib "user" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const LB_INITSTORAGE = &H1A8
Public Const LB_ADDSTRING = &H
Public Const WM_SETREDRAW = &HB
Public Const WM_VSCROLL = &H
Public Const SB_BOTTOM = 7
Declare Function GetLogicalDrives Lib "kernel" () As Long
Declare Function FindFirstFile Lib "kernel" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN_FIND_DATA) As Long
Public Const INVALID_HANDLE_VALUE = -1
Declare Function FindNextFile Lib "kernel" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN_FIND_DATA) As Long
Declare Function FindClose Lib "kernel" (ByVal hFindFile As Long) As Long
Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Public Const MaxLFNPath =
Type WIN_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MaxLFNPath
cShortFileName As String *
End Type
然后在窗体上制作2个菜单,放置一个ListBox和一个PictureBox
完整代码如下:
Option Explicit
Dim PicHeight%, hLB&, FileSpec$, UseFileSpec%
Dim TotalDirs%, TotalFiles%, Running%
Dim WFD As WIN_FIND_DATA, hItem&, hFile&
Const vbBackslash = "\"
Const vbAllFiles = "*.*"
Const vbKeyDot =
Private Sub Form_Load()
ScaleMode = vbPixels
PicHeight% = Picture1.Height
hLB& = List1.hwnd
SendMessage hLB&, LB_INITSTORAGE, &, ByVal & *
Move (Screen.Width - Width) * 0.5, (Screen.Height - Height) * 0.5
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyEscape And Running% Then Running% = False
End Sub
Private Sub Form_Resize()
MoveWindow hLB&, 0, 0, ScaleWidth, ScaleHeight - PicHeight%, True
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set Form1 = Nothing
End
End Sub
Private Sub mnuFindFiles_Click()
If Running% Then: Running% = False: Exit Sub
Dim drvbitmask&, maxpwr%, pwr%
On Error Resume Next
FileSpec$ = InputBox("Enter a file spec:" & vbCrLf & vbCrLf & "Searching will begin at drive A and continue " & "until no more drives are found. " & "Click Stop! at any time." & vbCrLf & "The * and ? wildcards can be used.", "Find File(s)", "*.exe")
If Len(FileSpec$) = 0 Then Exit Sub
MousePointer =
Running% = True
UseFileSpec% = True
mnuFindFiles.Caption = "&Stop!"
mnuFolderInfo.Enabled = False
List1.Clear
drvbitmask& = GetLogicalDrives()
If drvbitmask& Then
maxpwr% = Int(Log(drvbitmask&) / Log(2))
For pwr% = 0 To maxpwr%
If Running% And (2 ^ pwr% And drvbitmask&) Then _
Call SearchDirs(Chr$(vbKeyA + pwr%) & ":\")
Next
End If
Running% = False
UseFileSpec% = False
mnuFindFiles.Caption = "&Find File(s)..."
mnuFolderInfo.Enabled = True
MousePointer = 0
Picture1.Cls
Picture1.Print "Find File(s): " & List1.ListCount & " items found matching " & """" & FileSpec$ & """"
Beep
End Sub
Private Sub mnuFolderInfo_Click()
If Running% Then: Running% = False: Exit Sub
Dim searchpath$
On Error Resume Next
searchpath$ = InputBox("输入要查找的目标路径", "文件夹信息", "C:\")
If Len(searchpath$) < 2 Then Exit Sub
If Mid$(searchpath$, 2, 1) <> ":" Then Exit Sub
If Right$(searchpath$, 1) <> vbBackslash Then searchpath$ = searchpath$ & vbBackslash
If FindClose(FindFirstFile(searchpath$ & vbAllFiles, WFD)) = False Then
End If
MousePointer =
Running% = True
mnuFolderInfo.Caption = "停止(&S)"
mnuFindFiles.Enabled = False
List1.Clear
TotalDirs% = 0
TotalFiles% = 0
Call SearchDirs(searchpath$)
Running% = False
mnuFolderInfo.Caption = "文件夹信息(&F)"
mnuFindFiles.Enabled = True
Picture1.Cls
MousePointer = 0
MsgBox "Total folders: " & vbTab & TotalDirs% & vbCrLf & "Total files: " & vbTab & TotalFiles%, , "Folder Info for: " & searchpath$
End Sub
Private Sub SearchDirs(curpath$)
Dim dirs%, dirbuf$(), i%
Picture1.Cls
Picture1.Print "Searching " & curpath$
DoEvents
If Not Running% Then Exit Sub
hItem& = FindFirstFile(curpath$ & vbAllFiles, WFD)
If hItem& <> INVALID_HANDLE_VALUE Then
Do
If (WFD.dwFileAttributes And vbDirectory) Then
If Asc(WFD.cFileName) <> vbKeyDot Then
TotalDirs% = TotalDirs% + 1
If (dirs% Mod ) = 0 Then ReDim Preserve dirbuf$(dirs% + )
dirs% = dirs% + 1
dirbuf$(dirs%) = Left$(WFD.cFileName, InStr(WFD.cFileName, vbNullChar) - 1)
End If
ElseIf Not UseFileSpec% Then
TotalFiles% = TotalFiles% + 1
End If
Loop While FindNextFile(hItem&, WFD)
Call FindClose(hItem&)
End If
If UseFileSpec% Then
SendMessage hLB&, WM_SETREDRAW, 0, 0
Call SearchFileSpec(curpath$)
SendMessage hLB&, WM_VSCROLL, SB_BOTTOM, 0
SendMessage hLB&, WM_SETREDRAW, 1, 0
End If
For i% = 1 To dirs%: SearchDirs curpath$ & dirbuf$(i%) & vbBackslash: Next i%
End Sub
Private Sub SearchFileSpec(curpath$)
hFile& = FindFirstFile(curpath$ & FileSpec$, WFD)
If hFile& <> INVALID_HANDLE_VALUE Then
Do
DoEvents
If Not Running% Then Exit Sub
SendMessage hLB&, LB_ADDSTRING, 0, ByVal curpath$ & Left$(WFD.cFileName, InStr(WFD.cFileName, vbNullChar) - 1)
Loop While FindNextFile(hFile&, WFD)
Call FindClose(hFile&)
End If
End Sub
程序运行时就能够通过输入文件名而进行模糊查找了
如果还不明白,就加我QQ,主机搭建源码我把我做好的程序发给你看
QQ号:
为什么用::SendMessage(m_hWnd, BM_GETSTATE, 0, 0)这个函数将如何完成它的功能的?
sendmessage,是发一个消息到MFC的消息循环里.然后就会被执行了.
OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)重载这个就可以自己响应你发的消息了.
MFC 里面都是用消息实现的.
sendmessage也是有返回值的..你可以自己处理这些返回.
--------------------
BM_GETSTATE
这些都是被封装了的...没公开..
就算OnCmdMsg..也只是在半路给我们踩一脚而已,底层不会公开的.
androidçHandlerä¸sendEmptyMessageä¸sendMessageçåºå«ï¼
çæºç æ ¹æ®åæ°çä¸åäºç¸è°ç¨ public final boolean sendMessage(Message msg) { return sendMessageDelayed(msg, 0); } /** * Sends a Message containing only the what value. * * @return Returns true if the message was successfully placed in to the * message queue. Returns false on failure, usually because the * looper processing the message queue is exiting. */ public final boolean sendEmptyMessage(int what) { return sendEmptyMessageDelayed(what, 0); }
VB Instr
çäºä½ çé®é¢ï¼æç §ä½ çæ路使ç¨sendmessageå½æ°è¿è¡ç²è´´ï¼æåäºä»¥ä¸åæã
ä¸ãé¦å å®ç°å°ç±»ä¼¼â/Fâçæåæ¿æ¢ä¸ºå ¶å®æåï¼å¦æ¿æ¢æâ(æå ¥å¾ç)âï¼ä»¥ä¸ç代ç å°±å¯ä»¥å®ç°
Private Declare Function sendmessage Lib "user" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_PASTE = &H
Private Sub Command1_Click()
Dim Pos As Integer
Pos = InStr(1, RichTextBox1.Text, "/F", vbTextCompare)
Do Until Pos = 0
Me.RichTextBox1.SelStart = Pos - 1
Me.RichTextBox1.SelLength = 4
Clipboard.Clear
Clipboard.SetText "(æå ¥å¾ç)"
sendmessage Me.RichTextBox1.hwnd, WM_PASTE, ByVal 0&, ByVal 0&
Pos = InStr(1, RichTextBox1.Text, "/F", vbTextCompare)
Loop
End Sub
äºã使ç¨åä¸çæ¹æ³æ¿æ¢å¾çï¼åç°å¯ä»¥æ¾ç¤ºå¾çï¼ä½å¾çä½ç½®ä¸å¯¹ï¼ä»£ç å¦ä¸
Private Declare Function sendmessage Lib "user" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_PASTE = &H
Private Sub Command1_Click()
Dim Pos As Integer
Pos = InStr(1, RichTextBox1.Text, "/F", vbTextCompare)
Do Until Pos = 0
Me.RichTextBox1.SelStart = Pos - 1
Me.RichTextBox1.SelLength = 4
Clipboard.Clear
Clipboard.SetData LoadPicture(App.Path & "\help.gif")
sendmessage Me.RichTextBox1.hwnd, WM_PASTE, ByVal 0&, ByVal 0&
Pos = InStr(1, RichTextBox1.Text, "/F", vbTextCompare)
Loop
End Sub
ä¸ãå¦æå°RichTextBox1ä¸çæåå ¨é¨åæåè§è±æï¼å¦ï¼
AAAAAAAA/FBBBBBBBBBB/FCCCCCCCC/FDDDDDD/FEEEE
åç°å¾ççä½ç½®å ¨é¨é½å¯¹äºï¼ä½å¦æåæå ¨è§çè±æï¼åç°å¾ççä½ç½®åä¸å¯¹äº
综å以ä¸ä¸ç¹ï¼å¯ä»¥çåºsendmessageå½æ°å¯è½åå¨bugï¼å½å®ç²è´´æåæ¶ï¼å®å ¨æ²¡é®é¢ï¼èç²è´´å¾çæ¶ï¼å´åå ¶å®æåçåèæ°æè æ¯asciiç æå ³ï¼ææµè¯äºå¤ç§æ¹æ³ï¼åæ æ³æ¶é¤sendmessageçbug