gatt Posted May 26, 2017 Share Posted May 26, 2017 (edited) Its possible make a script, to detect each time it a new program x.exe is opened in my pc, and do y action? Example: I have a tool that will open 10 of same program, with a delay between each opened program. What i need is: each time this program is opened, the script load y action. At the end ill need those 10 same .exe with the action loaded in each one; The program that will opened is the same the 10x, same name, same process name; Edited May 26, 2017 by gatt Link to comment Share on other sites More sharing options...
Deye Posted May 26, 2017 Share Posted May 26, 2017 (edited) something to get you started ! this will give you the count of instances .. and check if all instances are paired before starting a new instance $count = ProcessList("same.exe") If Mod($count[0][0], 2) = 0 Then Run("same.exe") ;~ the count of instances $message = "you have " & $count[0][0] & " instances open" MsgBox(0, 'Count', $message) Edited May 26, 2017 by Deye Link to comment Share on other sites More sharing options...
gatt Posted May 26, 2017 Author Share Posted May 26, 2017 (edited) I have a tool that will open 10 firefox.exe with a delay of 1 second in each firefox opened, what i need is a script to load this code: RegWrite("HKCU\Console", "colortable00", "REG_SZ", "Intel i" & Random(6, 9, 1) & "000HQ") Each time one of those firefox is opened -It's Just example Edited May 26, 2017 by gatt Link to comment Share on other sites More sharing options...
Deye Posted May 27, 2017 Share Posted May 27, 2017 (edited) how about something like this : Local $iPid, $iSleep For $x = 0 To 10 $iPid = Run("C:\Program Files\Mozilla Firefox\firefox.exe http://www.google.com") $iSleep = 1000 Do Sleep($iSleep) If IsWindowActive($iPid) Then RegWrite("HKCU\Console", "colortable00", "REG_SZ", "Intel i" & Random(6, 9, 1) & "000HQ") ExitLoop Else $iSleep += 1000 EndIf Until $iSleep = 4000 Next Func IsWindowActive($iPID) Local $aWinList = WinList() For $i = 1 To $aWinList[0][0] If WinGetProcess($aWinList[$i][1]) = $iPID And BitAND(WinGetState($aWinList[$i][1]), 2) Then Return 1 Next Return 0 EndFunc ;==>IsWindowActive Edited May 27, 2017 by Deye Link to comment Share on other sites More sharing options...
gatt Posted May 27, 2017 Author Share Posted May 27, 2017 (edited) Bro not worked, when i open the program it dont change the registry key. I need a autoitscript opened in background running all time, and detecting each time x.exe is opened and add that regedit key Edited May 27, 2017 by gatt Link to comment Share on other sites More sharing options...
Deye Posted May 27, 2017 Share Posted May 27, 2017 try adding #RequireAdmin at the top of the script if the run command doesn't work try $iPid = Run("C:\Program Files\Mozilla Firefox\firefox -new-window http://www.google.com") Link to comment Share on other sites More sharing options...
gatt Posted May 27, 2017 Author Share Posted May 27, 2017 (edited) I dont need the script open the program, ill open it manually, i just need it add that regedit key each time i open x program. For example: each time i open firefox.exe it add RegWrite("HKCU\Console", "colortable00", "REG_SZ", "Intel i" & Random(6, 9, 1) & "000HQ") Just it, but i need the script keeps in background running and detecting each time firefox.exe is opened and add registry again Edited May 27, 2017 by gatt Link to comment Share on other sites More sharing options...
Deye Posted May 27, 2017 Share Posted May 27, 2017 (edited) then just use this #RequireAdmin RegWrite("HKCU\Console", "colortable00", "REG_SZ", "Intel i" & Random(6, 9, 1) & "000HQ") from scite's menu choose compile to exe or F5 to run .. Edited May 27, 2017 by Deye Link to comment Share on other sites More sharing options...
gatt Posted May 27, 2017 Author Share Posted May 27, 2017 (edited) But i need it run only when detect a new "firefox.exe" is opened, even if theres another firefox opened Edited May 27, 2017 by gatt Link to comment Share on other sites More sharing options...
water Posted May 27, 2017 Share Posted May 27, 2017 Can you please tell us why you need to open 10 instances of FireFox (or whatever program you need to start)? Sounds a bit strange to me My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
gatt Posted May 27, 2017 Author Share Posted May 27, 2017 (edited) I just dont explained it well, my english not good, what i need is just a script to run a regedit key each time it detects a .exe is opened, forget 10 firefox instances - I need change one regedit key each time i open a .exe, if possible the script should keep detecting until i close it Edited May 27, 2017 by gatt Link to comment Share on other sites More sharing options...
Developers Jos Posted May 27, 2017 Developers Share Posted May 27, 2017 It's always funny how some persist to remain vague about what it really is they want. My view on this is simple: When you can't be bothered to put in some effort to explain and share what you already have then I can't be bothered to assist. Jos water 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
gatt Posted May 27, 2017 Author Share Posted May 27, 2017 Funny is post in someones topic with the intention of just critic others, instead helps, im not being vague because i want, and just because i cant express it correct, like i said im using google translate to try explain what im looking for Link to comment Share on other sites More sharing options...
Developers Jos Posted May 27, 2017 Developers Share Posted May 27, 2017 At least I achieved you are willing to type a full sentence now. Going back to my cave now Jos 232showtime 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
gatt Posted May 27, 2017 Author Share Posted May 27, 2017 I found this script that detects when a new process is found: Dim $GetProcess , $CompareProcess , $LastArray, $TestThis $GetProcessTime = TimerInit() $Check = '' While 1 If TimerDiff($GetProcessTime) / 1000 >= 1 Then; checks for a change in process list ever 1 second $GetProcess = GetProccessInfo(Chr(01)) If StringInStr($LastArray, $GetProcess) = 0 Then $LastArray = $GetProcess $Check = $Check + 1 If $Check <> 1 Then MsgBox(0, 'Change', 'The Process List Changed') EndIf $GetProcessTime = TimerInit() EndIf Sleep(100) WEnd Func GetProccessInfo($d_Delimeter) Local $n_NowList = ProcessList() Local $r_ReturnArray = '' For $i = 1 To $n_NowList[0][0] $r_ReturnArray = $r_ReturnArray & $n_NowList[$i][0] & $d_Delimeter Next Return $r_ReturnArray;StringTrimRight($r_ReturnArray, 1) EndFunc But how i manage to compare the process name and run a action? For example, detected a new process is opened, then it checks if this new process name is equal "firefox.exe" then do a action. 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