Innovative Posted December 10, 2007 Share Posted December 10, 2007 I have some problems with my scripts, if i remove those tray scripts my script will work but when the tray scripts are there, the script will not working, meaning even there is a new process nothing will happen expandcollapse popup#include <process.au3> #include <misc.au3> #Include <Constants.au3> Opt("GUIOnEventMode", 1) Opt("TrayMenuMode",1) ; Default tray menu items (Script Paused/Exit) will not be shown. AutoItSetOption ( "trayautopause", 0 ) $settingsitem = TrayCreateMenu("Settings") $protectsettingsitem = TrayCreateItem("Protection Settings", $settingsitem) TrayCreateItem("") $aboutitem = TrayCreateItem("About") TrayCreateItem("") $exititem = TrayCreateItem("Exit") While 1 $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $aboutitem Msgbox(64,"about:","AutoIt3-Tray-sample") Case $msg = $exititem $comfirmexit = MsgBox(4 + 16, "ATTENTION", "Exiting this will deactivate ALL protections and functions"& @CRLF &""& @CRLF &"Are you sure you want to exit?") If $comfirmexit = 6 Then Exit Else MsgBox(0, "Advices..", "Next time, make sure before pressing =)") EndIf EndSelect WEnd While 1 ;Store current processlist "state" ;[x][0]: Contains process name ;[x][1]: Contains process id Global $ListOne = ProcessList() While 1 ;[x][0]: Contains process name ;[x][1]: Contains process id Global $ListTwo = ProcessList() ;Verify each process exists in original state For $X = 1 To $ListTwo[0][0] $found = False ;Comparing by PID For $Y = 1 To $ListOne[0][0] If $ListOne[$Y][1] = $ListTwo[$X][1] Then $found = True ExitLoop EndIf Next ;If no match is found in ListOne for current process in ListTwo If $found = False Then WinSetState(_WinGetByPid($ListTwo[$X][1]), "", @SW_DISABLE) $processString = "ProcessName: " & $ListTwo[$X][0] & @CRLF $processString &= "ProcessID: " & $ListTwo[$X][1] & @CRLF ;Retrieve process path $processString &= "ProcessPath: " & _GetProcessPath($ListTwo[$X][1]) & @CRLF $processString &= @CRLF & "Allow detected process to remain active?" TrayTip("A new process is detected!", "If this is expected, you should allow it to remain active but if you are unsure about it deny it from executing", 5, 1) Sleep(1000) $result = MsgBox(4 + 48,"ProcessDefender has detected a new process", $processString) If $result = 6 Then ;This will reset the first comparison state WinSetState(_WinGetByPid($ListTwo[$X][1]), "", @sw_enable) ExitLoop 2 Else ProcessClose($ListTwo[$X][1]) ExitLoop EndIf EndIf Next ;Check every second Sleep(1000) WEnd WEnd Func _WinGetByPID($iPID, $nArray = 1);0 will return 1 base array; leaving it 1 will return the first visible window it finds If IsString($iPID) Then $iPID = ProcessExists($iPID) Local $aWList = WinList(), $sHold For $iCC = 1 To $aWList[0][0] If WinGetProcess($aWList[$iCC][1]) = $iPID And _ BitAND(WinGetState($aWList[$iCC][1]), 2) Then If $nArray Then Return $aWList[$iCC][0] $sHold &= $aWList[$iCC][0] & Chr(1) EndIf Next If $sHold Then Return StringSplit(StringTrimRight($sHold, 1), Chr(1)) Return SetError(1, 0, 0) EndFunc ;==>_WinGetByPID Func _GetProcessPath($GPPpid) $colItems = "" $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2") $colItems = $objWMIService.ExecQuery('SELECT * FROM Win32_Process WHERE processid = ' & $GPPpid, "WQL", 0x10 + 0x20) If IsObj($colItems) then For $objItem In $colItems Return $objItem.ExecutablePath Next Else Return "" Endif EndFunc Link to comment Share on other sites More sharing options...
Jango Posted December 10, 2007 Share Posted December 10, 2007 I have some problems with my scripts, if i remove those tray scripts my script will work but when the tray scripts are there, the script will not working, meaning even there is a new process nothing will happenWhile 1 $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $aboutitem Msgbox(64,"about:","AutoIt3-Tray-sample") Case $msg = $exititem $comfirmexit = MsgBox(4 + 16, "ATTENTION", "Exiting this will deactivate ALL protections and functions"& @CRLF &""& @CRLF &"Are you sure you want to exit?") If $comfirmexit = 6 Then Exit Else MsgBox(0, "Advices..", "Next time, make sure before pressing =)") EndIf EndSelectWEndSure, your script do the first loop until you quit the tray loop.You need to integrate tray loop and your loop in one loop. Link to comment Share on other sites More sharing options...
Innovative Posted December 10, 2007 Author Share Posted December 10, 2007 Problem solve =) thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now