• 按键公众号 :
按键精灵电脑版
立即下载

软件版本:2014.06
软件大小:22.9M
更新时间:2021-12-03

按键精灵安卓版
立即下载

软件版本:3.7.2
软件大小:46.2M
更新时间:2023-05-10

按键精灵iOS版
立即下载

软件版本:1.8.0
软件大小:29.2M
更新时间:2023-03-21

按键手机助手
立即下载

软件版本:3.8.0
软件大小:262M
更新时间:2023-05-30

快捷导航

登录 后使用快捷导航
没有帐号? 注册

发新话题 回复该主题

[昨夜星辰] 【源码】API设置窗口状态 [复制链接]

1#
函数名称:
设置窗口关闭
参数定义:
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)

源码:

  1. Declare Function SendMessage Lib "user32" Alias "SendMessageW" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
  2. Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long
  3. 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)
  4. Declare Function ShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
  5. 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
  6. Declare Function EnableWindow Lib "user32" Alias "EnableWindow" (ByVal hwnd As Long, ByVal fEnable As Long) As Long
  7. Declare Function LocalAlloc Lib "kernel32" Alias "LocalAlloc" (ByVal wOemChar As Long,ByVal wOmChar As Long) As Long
  8. Declare Function LocalFree Lib "kernel32" Alias "LocalFree" (ByVal hMem As Long) As Long
  9. Declare Function RtlMoveMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal h As Any, ByRef f As Any, ByVal Length As Long)
  10. Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwprocessid As Long) As Long
  11. Declare Function OpenProcess Lib "kernel32" Alias "OpenProcess" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
  12. Declare Function TerminateProcess Lib "kernel32" Alias "TerminateProcess" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
  13. Declare Function CloseHandle Lib "kernel32" Alias "CloseHandle" (ByVal hObject As Long) As Long
  14. Dim Hwnd
  15. Hwnd = 0 '自行设置一个窗口句柄
  16. 'TracePrint "设置窗口关闭:" & 设置窗口关闭(Hwnd)
  17. TracePrint "设置窗口激活:" & 设置窗口激活(Hwnd)
  18. TracePrint "设置窗口最小化:" & 设置窗口最小化(Hwnd)
  19. TracePrint "设置窗口最大化:" & 设置窗口最大化(Hwnd)
  20. TracePrint "设置窗口恢复:" & 设置窗口恢复(Hwnd)
  21. TracePrint "设置窗口隐藏:" & 设置窗口隐藏(Hwnd)
  22. TracePrint "设置窗口显示:" & 设置窗口显示(Hwnd)
  23. TracePrint "设置窗口置顶:" & 设置窗口是否置顶(Hwnd, 1)
  24. TracePrint "设置窗口取消置顶:" & 设置窗口是否置顶(Hwnd, 0)
  25. TracePrint "设置窗口不可用:" & 设置窗口是否可用(Hwnd, 0)
  26. TracePrint "设置窗口可用:" & 设置窗口是否可用(Hwnd, 1)
  27. TracePrint "设置窗口所在进程强制关闭:" & 设置窗口所在进程强制关闭(Hwnd)
  28. Function 设置窗口关闭(Hwnd)
  29. Dim WM_CLOSE
  30. WM_CLOSE = 16
  31. Call SendMessage(Hwnd, WM_CLOSE, 0, 0)
  32. End Function
  33. Function 设置窗口激活(Hwnd)
  34. keybd_event 18, 0, 0, 0
  35. keybd_event 18, 0, 2, 0
  36. If SetForegroundWindow(Hwnd) <> 0 Then
  37. 设置窗口激活 = 1
  38. Else
  39. 设置窗口激活 = 0
  40. End If
  41. End Function
  42. Function 设置窗口最小化(Hwnd)
  43. Dim SW_MINIMIZE
  44. SW_MINIMIZE = 6
  45. Call ShowWindow(Hwnd, SW_MINIMIZE)
  46. End Function
  47. Function 设置窗口最大化(Hwnd)
  48. Dim SW_MAXIMIZE
  49. SW_MAXIMIZE = 3
  50. Call ShowWindow(Hwnd, SW_MAXIMIZE)
  51. End Function
  52. Function 设置窗口恢复(Hwnd)
  53. Dim SW_RESTORE
  54. SW_RESTORE = 9
  55. Call ShowWindow(Hwnd, SW_RESTORE)
  56. End Function
  57. Function 设置窗口显示(Hwnd)
  58. Dim SW_SHOW
  59. SW_SHOW = 5
  60. Call ShowWindow(Hwnd, SW_SHOW)
  61. End Function
  62. Function 设置窗口隐藏(Hwnd)
  63. Dim SW_HIDE
  64. SW_HIDE = 0
  65. Call ShowWindow(Hwnd, SW_HIDE)
  66. End Function
  67. Function 设置窗口是否置顶(Hwnd,Mode)
  68. Dim HWND_NOTOPMOST, HWND_TOPMOST, HWND_TOP, SWP_NOSIZE, SWP_NOMOVE
  69. HWND_NOTOPMOST = - 2
  70. HWND_TOPMOST = - 1
  71. HWND_TOP = 0
  72. SWP_NOSIZE = 1
  73. SWP_NOMOVE = 2
  74. 设置窗口是否置顶 = 0
  75. If Mode = 0 Then
  76. If SetWindowPos(Hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE) <> 0 Then
  77. 设置窗口是否置顶 = 1
  78. End If
  79. Else
  80. If SetWindowPos(Hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE) <> 0 Then
  81. If SetWindowPos(Hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE) <> 0 Then
  82. 设置窗口是否置顶 = 1
  83. End If
  84. End If
  85. End If
  86. End Function
  87. Function 设置窗口是否可用(Hwnd, Mode)
  88. Call EnableWindow(Hwnd, Mode)
  89. End Function
  90. Function 设置窗口所在进程强制关闭(Hwnd)
  91. 设置窗口所在进程强制关闭 = 0
  92. Dim PID, hProcess
  93. Dim PROCESS_TERMINATE
  94. PROCESS_TERMINATE = 1
  95. PID = GetWindowProcessId(Hwnd)
  96. hProcess = OpenProcess(PROCESS_TERMINATE, False, PID)
  97. If hProcess <> 0 Then
  98. If TerminateProcess(hProcess, 0) <> 0 Then
  99. 设置窗口所在进程强制关闭 = 1
  100. End If
  101. Call CloseHandle(hProcess)
  102. End If
  103. End Function
  104. Function GetWindowProcessId(Hwnd)
  105. GetWindowProcessId = 0
  106. Dim LPid
  107. LPid = LocalAlloc(0, 4)
  108. If LPid = 0 Then
  109. Exit Function
  110. End If
  111. If GetWindowThreadProcessId(Hwnd, LPid) <> 0 Then
  112. GetWindowProcessId = CLng(ReadMemoryValue(LPid, 4))
  113. End If
  114. LocalFree LPid
  115. End Function
  116. Function ReadMemoryValue(addr, length)
  117. Dim i
  118. temp_char = space(2)
  119. length = length - 1
  120. For i = 0 To length
  121. RtlMoveMemory temp_char, addr + i, 1
  122. ReadMemoryValue = ReadMemoryValue + AscB(temp_char) * 256 ^ i
  123. Next
  124. End Function
复制代码

近期制作:
传奇私服各种反外挂插件版本挂机软件,可教可售
原神加速、连发辅助工具
天下3自动钓大鱼辅助工具

承接脚本定制,点击下方联系
QQ:250039815

交流群:101296478

2#


3#

666666

4#

学习一下

5#

4444444444

6#

66666666

7#

学习学习!~~~~~~~~~~~~~~~~~~~~~~

8#

321312312

9#

看一下,学习学习

10#

物流信息

11#

看看

12#

6666666666

13#

学习中

14#


15#

11111

16#


17#

学习一下API

18#

谢谢大佬分享

发新话题 回复该主题