#NoTrayIcon
#Include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#cs
因为无聊,有时候看电影时,又想看下网页,影响看电影,所以写了此工具!本人QQ:76555051
此工具纯属个人使用,无任何商业用途,用于源码学习,高手莫笑!
#ce
;被置顶的窗口最小最大化使用的开关变量
$my_true_false=True
;隐藏开关变量
$yc=True
$mytitle = "test"
If WinExists($mytitle) Then Exit
AutoItWinSetTitle($mytitle)
;快捷键提示
MsgBox(262144+0,"程序快捷键信息","友情提示:"&@CRLF&@CRLF&"程序自身退出快捷键是:Shift+Alt+d"&@CRLF&@CRLF&"程序自身隐藏显示快捷键是:Alt+q"& @CRLF&@CRLF&"被置顶窗口程序的最小和还原快捷键是:Alt+w")
HotKeySet("+!d", "myexit") ;Shift-Alt-d 程序退出快捷键
HotKeySet("!q", "yc") ;Alt-q 程序隐藏显示快捷键
HotKeySet("!w", "jh") ;Alt-w 程序激活显示快捷键
#Region ### START Koda GUI section ### Form=C:\Documents and Settings\Administrator\桌面\Form1.kxf
$Form1 = GUICreate("程序置顶小工具 by 明兵", 371, 164, 344, 258)
GUISetIcon("F:\au3程序源码(201102月前)\mycom.ico", -1)
$Label1 = GUICtrlCreateLabel("请你输入要置顶的程序的进程名称", 56, 32, 244, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Input1 = GUICtrlCreateInput("qqplayer.exe", 64, 80, 137, 21)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Button1 = GUICtrlCreateButton("置顶程序", 232, 80, 65, 25,0x0001)
$Label2 = GUICtrlCreateLabel("QQ:76555051", 232, 136, 71, 17)
$Label3 = GUICtrlCreateLabel("退出", 328, 136, 28, 17)
GUICtrlSetBkColor(-1, 0x9DB9EB)
GUISetState(@SW_HIDE )
#EndRegion ### END Koda GUI section ###
Global $myjc,$ProcessID,$Process,$mb
GUISetState(@SW_SHOW )
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
jc()
Case $Label3
Exit
EndSwitch
WEnd
;通过进程的PID获取进程窗口句柄函数
Func _pid_jb($pid)
Dim $jb = ""
While $jb = ""
$win_list = WinList("[REGEXPTITLE:.+]")
For $i = 1 To $win_list[0][0]
If BitAND(WinGetState($win_list[$i][0]), 2) And WinGetProcess($win_list[$i][1], "") = $pid Then $jb = $win_list[$i][1]
Next
WEnd
Return $jb
EndFunc ;==>pid_jb
;进程检测函数
Func jc()
If GUICtrlRead($Input1)="" Then
GUISetState(@SW_HIDE )
MsgBox(262144+0,"提示","进程不能为空,请重填,谢谢合作!",5)
GUISetState(@SW_SHOW )
ElseIf Not ProcessExists(GUICtrlRead($Input1)) Then
GUISetState(@SW_HIDE )
MsgBox(262144+0,"提示","进程不存在,请打开有关程序后再运行本工具,谢谢合作!",5)
GUICtrlSetData($input1,"")
GUISetState(@SW_SHOW )
Else
$Process=GUICtrlRead($Input1)
$ProcessID = ProcessExists($Process)
$mb=_pid_jb($ProcessID)
;调用置顶函数
mb()
EndIf
EndFunc
;将指定程序的窗口置顶函数
Func mb()
While 1
$hw=_WinAPI_GetForegroundWindow()
If $hw<>$mb Then
_WinAPI_SetWindowPos($hw, -2, 0, 0, 0, 0, 3)
EndIf
_WinAPI_SetWindowPos($mb, -1, 0, 0, 0, 0, 3)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Label3
Exit
EndSwitch
WEnd
EndFunc
;退出本程序函数
Func myexit()
Exit
EndFunc
;隐藏与显示本程序函数
Func yc()
If $yc=True Then
GUISetState(@SW_HIDE)
$yc=False
Else
GUISetState(@SW_SHOW)
$yc=True
EndIf
EndFunc
;被置顶的程序最小最大化函数
Func jh()
;$mm=WinGetHandle("新建 文本文档.txt - 记事本","")
If $my_true_false=True Then
_WinAPI_ShowWindow($mb,@SW_RESTORE)
$my_true_false=False
ElseIf $my_true_false=False Then
_WinAPI_ShowWindow($mb,@SW_SHOWMINIMIZED)
$my_true_false=True
EndIf
EndFunc