[FUNC]获取AHK脚本自身的PID,Dbgview过滤进程

189 篇文章 4 订阅
105 篇文章 5 订阅
;PID-or-Name 参数为空, 则获取脚本自身的 PID
Process, Exist
NewPID = %ErrorLevel% 
MsgBox A matching process has appeared (Process ID is %NewPID%).

a_scriptPID := DllCall("GetCurrentProcessId")	; get script's PID
MsgBox %a_scriptPID%


应用于调试环境的设置,设置Dbgview只捕捉当前脚本PID

;启动Dbgview

if !WinExist("ahk_class dbgviewClass") 
{
		Run, E:\快盘\AHK\Dbgview.exe,, UseErrorLevel, PID
		WinWaitActive, ahk_pid %PID%, ,2
	} else 
	{
		WinRestore, ahk_class dbgviewClass
		Process, wait, dbgview.exe, 5.5
		PID = %ErrorLevel%  ; 由于 ErrorLevel 会经常发生改变, 所以要立即保存这个值.
		if PID = 0
		{
			MsgBox The specified process did not appear within 5.5 seconds.
			return
		}
	}

;清除Dbgview过历史记录,等同发送^x
WinMenuSelectItem,ahk_class dbgviewClass,,Edit, Clear Display, 

;设置Dbgview过滤进程
a_scriptPID := DllCall("GetCurrentProcessId")	; get script's PID
WinMenuSelectItem,ahk_class dbgviewClass,,Edit, Filter/Highlight..., ;	
winwait, DebugView Filter
winactivate, DebugView Filter
Winwaitactive, DebugView Filter 
MouseGetPos, x,y
mouseclick, left, 125, 85,,0
MouseMove, x,y,0
send, [%a_scriptPID%*{Enter}
send, !M{Down}{Enter}
;输出调试内容
s:="HelloWorld"
OutputDebug %s%


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值