- 按键认证大神
- 728264
- 3502
- 18
- 1899 朵
- 27454 个
- 1718 个
- 82980
- 2011-08-04
|
1#
t
T
发表于 2022-10-30 04:22
|
|只看楼主
函数名称: 设置窗口关闭 参数定义: Hwnd 整数型:窗口句柄 返回值: 无 调用例子: TracePrint 设置窗口关闭(Hwnd) //与按键精灵自带插件不同,该函数可关闭子窗口。
函数名称: 设置窗口激活 参数定义: Hwnd 整数型:窗口句柄 返回值: 整数型:窗口激活成功返回1,否则返回0。 调用例子: TracePrint 设置窗口激活(Hwnd) //与按键精灵自带插件不同,该函数可激活自身窗口。
函数名称: 设置窗口最小化 参数定义: Hwnd 整数型:窗口句柄 返回值: 无 调用例子: TracePrint 设置窗口最小化(Hwnd)
函数名称: 设置窗口最大化 参数定义: Hwnd 整数型:窗口句柄 返回值: 无 调用例子: TracePrint 设置窗口最大化(Hwnd)
函数名称: 设置窗口恢复 参数定义: Hwnd 整数型:窗口句柄 返回值: 无 调用例子: TracePrint 设置窗口恢复(Hwnd) //可将窗口隐藏、最小化、最大化状态恢复为正常。
函数名称: 设置窗口显示 参数定义: Hwnd 整数型:窗口句柄 返回值: 无 调用例子: TracePrint 设置窗口显示(Hwnd)
函数名称: 设置窗口隐藏 参数定义: Hwnd 整数型:窗口句柄 返回值: 无 调用例子: TracePrint 设置窗口隐藏(Hwnd)
函数名称: 设置窗口是否置顶 参数定义: Hwnd 整数型:窗口句柄 Mode 整数型:1为置顶窗口,0为取消窗口置顶。 返回值: 整数型:设置成功返回1,否则返回0。 调用例子: TracePrint 设置窗口是否置顶(Hwnd, 1) TracePrint 设置窗口是否置顶(Hwnd, 0) //与按键精灵自带插件不同,即便自身窗口不处于激活状态,该函数也可将自身窗口置顶。
函数名称: 设置窗口是否可用 参数定义: Hwnd 整数型:窗口句柄 Mode 整数型:1为设置窗口可用,0为设置窗口不可用。 返回值: 整数型:设置成功返回1,否则返回0。 调用例子: TracePrint 设置窗口是否可用(Hwnd, 0) TracePrint 设置窗口是否可用(Hwnd, 1)
函数名称: 设置窗口所在进程强制关闭 参数定义: Hwnd 整数型:窗口句柄 返回值: 整数型:设置成功返回1,否则返回0。 调用例子: TracePrint 设置窗口所在进程强制关闭(Hwnd)
源码:- Declare Function SendMessage Lib "user32" Alias "SendMessageW" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
- Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long
- Declare Function keybd_event Lib "user32" Alias "keybd_event" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
- Declare Function ShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
- Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
- Declare Function EnableWindow Lib "user32" Alias "EnableWindow" (ByVal hwnd As Long, ByVal fEnable As Long) As Long
- Declare Function LocalAlloc Lib "kernel32" Alias "LocalAlloc" (ByVal wOemChar As Long,ByVal wOmChar As Long) As Long
- Declare Function LocalFree Lib "kernel32" Alias "LocalFree" (ByVal hMem As Long) As Long
- Declare Function RtlMoveMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal h As Any, ByRef f As Any, ByVal Length As Long)
- Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwprocessid As Long) As Long
- Declare Function OpenProcess Lib "kernel32" Alias "OpenProcess" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
- Declare Function TerminateProcess Lib "kernel32" Alias "TerminateProcess" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
- Declare Function CloseHandle Lib "kernel32" Alias "CloseHandle" (ByVal hObject As Long) As Long
- Dim Hwnd
- Hwnd = 0 '自行设置一个窗口句柄
- 'TracePrint "设置窗口关闭:" & 设置窗口关闭(Hwnd)
- TracePrint "设置窗口激活:" & 设置窗口激活(Hwnd)
- TracePrint "设置窗口最小化:" & 设置窗口最小化(Hwnd)
- TracePrint "设置窗口最大化:" & 设置窗口最大化(Hwnd)
- TracePrint "设置窗口恢复:" & 设置窗口恢复(Hwnd)
- TracePrint "设置窗口隐藏:" & 设置窗口隐藏(Hwnd)
- TracePrint "设置窗口显示:" & 设置窗口显示(Hwnd)
- TracePrint "设置窗口置顶:" & 设置窗口是否置顶(Hwnd, 1)
- TracePrint "设置窗口取消置顶:" & 设置窗口是否置顶(Hwnd, 0)
- TracePrint "设置窗口不可用:" & 设置窗口是否可用(Hwnd, 0)
- TracePrint "设置窗口可用:" & 设置窗口是否可用(Hwnd, 1)
- TracePrint "设置窗口所在进程强制关闭:" & 设置窗口所在进程强制关闭(Hwnd)
- Function 设置窗口关闭(Hwnd)
- Dim WM_CLOSE
- WM_CLOSE = 16
- Call SendMessage(Hwnd, WM_CLOSE, 0, 0)
- End Function
- Function 设置窗口激活(Hwnd)
- keybd_event 18, 0, 0, 0
- keybd_event 18, 0, 2, 0
- If SetForegroundWindow(Hwnd) <> 0 Then
- 设置窗口激活 = 1
- Else
- 设置窗口激活 = 0
- End If
- End Function
- Function 设置窗口最小化(Hwnd)
- Dim SW_MINIMIZE
- SW_MINIMIZE = 6
- Call ShowWindow(Hwnd, SW_MINIMIZE)
- End Function
- Function 设置窗口最大化(Hwnd)
- Dim SW_MAXIMIZE
- SW_MAXIMIZE = 3
- Call ShowWindow(Hwnd, SW_MAXIMIZE)
- End Function
- Function 设置窗口恢复(Hwnd)
- Dim SW_RESTORE
- SW_RESTORE = 9
- Call ShowWindow(Hwnd, SW_RESTORE)
- End Function
- Function 设置窗口显示(Hwnd)
- Dim SW_SHOW
- SW_SHOW = 5
- Call ShowWindow(Hwnd, SW_SHOW)
- End Function
- Function 设置窗口隐藏(Hwnd)
- Dim SW_HIDE
- SW_HIDE = 0
- Call ShowWindow(Hwnd, SW_HIDE)
- End Function
- Function 设置窗口是否置顶(Hwnd,Mode)
- Dim HWND_NOTOPMOST, HWND_TOPMOST, HWND_TOP, SWP_NOSIZE, SWP_NOMOVE
- HWND_NOTOPMOST = - 2
- HWND_TOPMOST = - 1
- HWND_TOP = 0
- SWP_NOSIZE = 1
- SWP_NOMOVE = 2
- 设置窗口是否置顶 = 0
- If Mode = 0 Then
- If SetWindowPos(Hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE) <> 0 Then
- 设置窗口是否置顶 = 1
- End If
- Else
- If SetWindowPos(Hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE) <> 0 Then
- If SetWindowPos(Hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE) <> 0 Then
- 设置窗口是否置顶 = 1
- End If
- End If
- End If
- End Function
- Function 设置窗口是否可用(Hwnd, Mode)
- Call EnableWindow(Hwnd, Mode)
- End Function
- Function 设置窗口所在进程强制关闭(Hwnd)
- 设置窗口所在进程强制关闭 = 0
- Dim PID, hProcess
- Dim PROCESS_TERMINATE
- PROCESS_TERMINATE = 1
- PID = GetWindowProcessId(Hwnd)
- hProcess = OpenProcess(PROCESS_TERMINATE, False, PID)
- If hProcess <> 0 Then
- If TerminateProcess(hProcess, 0) <> 0 Then
- 设置窗口所在进程强制关闭 = 1
- End If
- Call CloseHandle(hProcess)
- End If
- End Function
- Function GetWindowProcessId(Hwnd)
- GetWindowProcessId = 0
- Dim LPid
- LPid = LocalAlloc(0, 4)
- If LPid = 0 Then
- Exit Function
- End If
- If GetWindowThreadProcessId(Hwnd, LPid) <> 0 Then
- GetWindowProcessId = CLng(ReadMemoryValue(LPid, 4))
- End If
- LocalFree LPid
- End Function
- Function ReadMemoryValue(addr, length)
- Dim i
- temp_char = space(2)
- length = length - 1
- For i = 0 To length
- RtlMoveMemory temp_char, addr + i, 1
- ReadMemoryValue = ReadMemoryValue + AscB(temp_char) * 256 ^ i
- Next
- End Function
复制代码
|