memerim Posted March 25, 2019 Share Posted March 25, 2019 I have multiple process with same title and class, but i edited the executable name to differ each one, in determined actions they will run a autoit script, is possible detect the process who executed the script? Link to comment Share on other sites More sharing options...
Nine Posted March 26, 2019 Share Posted March 26, 2019 Look in the help file for those 2 functions : ProcessExist and ProcessList. You can also use Win* ("[ACTIVE]"). Hard to say with no code... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
memerim Posted March 26, 2019 Author Share Posted March 26, 2019 If i use winactivate will mess up everything, process exist and process list , how it can help to detect the process who executed the script. Link to comment Share on other sites More sharing options...
Nine Posted March 26, 2019 Share Posted March 26, 2019 3 minutes ago, memerim said: If i use winactivate will mess up everything Of course, but not WinGetProcess, WinGetHandle, WinGetText, etc. Help file is your best friend... Now that you have the basic tools, it is time for you to write some code. Enjoy ! “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Exit Posted March 26, 2019 Share Posted March 26, 2019 ConsoleWrite(@AutoItPID & @CRLF) ; Process identifier (PID) of the current script. App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Nine Posted March 26, 2019 Share Posted March 26, 2019 (edited) 8 minutes ago, Exit said: ConsoleWrite(@AutoItPID & @CRLF) ; Process identifier (PID) of the current script. I think he wants to know which process launched the autoit script... ps. another option is to pass the launcher PID as a command line parameter to the autoit script. Edited March 26, 2019 by Nine Exit 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
jchd Posted March 26, 2019 Share Posted March 26, 2019 To find the parent process PID you can use this: Exit 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
memerim Posted March 26, 2019 Author Share Posted March 26, 2019 1 hour ago, Nine said: I think he wants to know which process launched the autoit script... ps. another option is to pass the launcher PID as a command line parameter to the autoit script. Exactly, i'm trying know which process launched the autoit script, and Nine, i have searched and read in the help file, this is how i did my script below. This is my actual script, he detects the active window, get her process name, and run another script inside a determined sandboxie, im trying identify what process launched the script without needs active her window. expandcollapse popupLocal $Actwin = WinGetHandle("[ACTIVE]") Local $PidActwin = WinGetProcess($Actwin) Local $NamePidActwin = _Findpidname($PidActwin) If $NamePidActwin = "1.exe" Then Local $client= "/box:1 %USERPROFILE%\Desktop\Scripts\job.exe" RunWait(@ComSpec & ' /c "C:\Program Files\Sandboxie\Start.exe" ' & $client, "", @SW_HIDE) EndIf If $NamePidActwin = "2.exe" Then Local $client= "/box:2 %USERPROFILE%\Desktop\Scripts\job.exe" RunWait(@ComSpec & ' /c "C:\Program Files\Sandboxie\Start.exe" ' & $client, "", @SW_HIDE) EndIf If $NamePidActwin = "3.exe" Then Local $client= "/box:3 %USERPROFILE%\Desktop\Scripts\job.exe" RunWait(@ComSpec & ' /c "C:\Program Files\Sandboxie\Start.exe" ' & $client, "", @SW_HIDE) EndIf If $NamePidActwin = "4.exe" Then Local $client= "/box:4 %USERPROFILE%\Desktop\Scripts\job.exe" RunWait(@ComSpec & ' /c "C:\Program Files\Sandboxie\Start.exe" ' & $client, "", @SW_HIDE) EndIf If $NamePidActwin = "5.exe" Then Local $client= "/box:5 %USERPROFILE%\Desktop\Scripts\job.exe" RunWait(@ComSpec & ' /c "C:\Program Files\Sandboxie\Start.exe" ' & $client, "", @SW_HIDE) EndIf If $NamePidActwin = "6.exe" Then Local $client= "/box:6 %USERPROFILE%\Desktop\Scripts\job.exe" RunWait(@ComSpec & ' /c "C:\Program Files\Sandboxie\Start.exe" ' & $client, "", @SW_HIDE) EndIf If $NamePidActwin = "7.exe" Then Local $client= "/box:7 %USERPROFILE%\Desktop\Scripts\job.exe" RunWait(@ComSpec & ' /c "C:\Program Files\Sandboxie\Start.exe" ' & $client, "", @SW_HIDE) EndIf If $NamePidActwin = "8.exe" Then Local $client= "/box:8 %USERPROFILE%\Desktop\Scripts\job.exe" RunWait(@ComSpec & ' /c "C:\Program Files\Sandboxie\Start.exe" ' & $client, "", @SW_HIDE) EndIf If $NamePidActwin = "9.exe" Then Local $client= "/box:9 %USERPROFILE%\Desktop\Scripts\job.exe" RunWait(@ComSpec & ' /c "C:\Program Files\Sandboxie\Start.exe" ' & $client, "", @SW_HIDE) EndIf If $NamePidActwin = "10.exe" Then Local $client= "/box:10 %USERPROFILE%\Desktop\Scripts\job.exe" RunWait(@ComSpec & ' /c "C:\Program Files\Sandboxie\Start.exe" ' & $client, "", @SW_HIDE) EndIf If $NamePidActwin = "11.exe" Then Local $client= "/box:11 %USERPROFILE%\Desktop\Scripts\job.exe" RunWait(@ComSpec & ' /c "C:\Program Files\Sandboxie\Start.exe" ' & $client, "", @SW_HIDE) EndIf If $NamePidActwin = "12.exe" Then Local $client= "/box:12 %USERPROFILE%\Desktop\Scripts\job.exe" RunWait(@ComSpec & ' /c "C:\Program Files\Sandboxie\Start.exe" ' & $client, "", @SW_HIDE) EndIf If $NamePidActwin = "13.exe" Then Local $client= "/box:13 %USERPROFILE%\Desktop\Scripts\job.exe" RunWait(@ComSpec & ' /c "C:\Program Files\Sandboxie\Start.exe" ' & $client, "", @SW_HIDE) EndIf If $NamePidActwin = "14.exe" Then Local $client= "/box:14 %USERPROFILE%\Desktop\Scripts\job.exe" RunWait(@ComSpec & ' /c "C:\Program Files\Sandboxie\Start.exe" ' & $client, "", @SW_HIDE) EndIf If $NamePidActwin = "15.exe" Then Local $client= "/box:15 %USERPROFILE%\Desktop\Scripts\job.exe" RunWait(@ComSpec & ' /c "C:\Program Files\Sandboxie\Start.exe" ' & $client, "", @SW_HIDE) EndIf If $NamePidActwin = "16.exe" Then Local $client= "/box:16 %USERPROFILE%\Desktop\Scripts\job.exe" RunWait(@ComSpec & ' /c "C:\Program Files\Sandboxie\Start.exe" ' & $client, "", @SW_HIDE) EndIf ;MsgBox(0, '', $NamePidActwin) Func _Findpidname($Pid) Local $Processlist = ProcessList() For $i = 1 To $Processlist[0][0] If $Processlist[$i][1] = $Pid Then Return $Processlist[$i][0] Next EndFunc ;==>_Findpidname @jchd I launched your script it pop up a window with all process, im a bit lost what next step? Link to comment Share on other sites More sharing options...
Nine Posted March 26, 2019 Share Posted March 26, 2019 you could simplify your code by doing this (untested) but you get the idea : Local $box = Number(StringRegExp($NamePidActwin,"(\d+).",$STR_REGEXPARRAYMATCH)[0]) Local $client= "/box:" & $box & " %USERPROFILE%\Desktop\Scripts\job.exe" RunWait(@ComSpec & ' /c "C:\Program Files\Sandboxie\Start.exe" ' & $client, "", @SW_HIDE) “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
AdamUL Posted March 26, 2019 Share Posted March 26, 2019 (edited) Have a look at _WinAPI_GetParentProcess and _ProcessGetName. The script will need to be compiled for it to work correctly. #include <Process.au3> #include <WinAPIProc.au3> Global $iScriptParentPID = _WinAPI_GetParentProcess(@AutoItPID) Global $sParentProcessName = _ProcessGetName($iScriptParentPID) MsgBox(0, "Process Name", $sParentProcessName) ;For testing. Adam Edited March 26, 2019 by AdamUL memerim 1 Link to comment Share on other sites More sharing options...
jchd Posted March 26, 2019 Share Posted March 26, 2019 Ah, this Win API escaped my search... FrancescoDiMuro 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
memerim Posted March 26, 2019 Author Share Posted March 26, 2019 56 minutes ago, AdamUL said: Have a look at _WinAPI_GetParentProcess and _ProcessGetName. The script will need to be compiled for it to work correctly. #include <Process.au3> #include <WinAPIProc.au3> Global $iScriptParentPID = _WinAPI_GetParentProcess(@AutoItPID) Global $sParentProcessName = _ProcessGetName($iScriptParentPID) MsgBox(0, "Process Name", $sParentProcessName) ;For testing. Adam Worked perfectly, thank you, thank ya all Link to comment Share on other sites More sharing options...
AdamUL Posted March 26, 2019 Share Posted March 26, 2019 Your welcome. Glad I could help. Adam 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