Jump to content

Run script each time a same program is opened!


Recommended Posts

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 by gatt
Link to comment
Share on other sites

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 by Deye
Link to comment
Share on other sites

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 by gatt
Link to comment
Share on other sites

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 by Deye
Link to comment
Share on other sites

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 by gatt
Link to comment
Share on other sites

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 by gatt
Link to comment
Share on other sites

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 :huh:

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

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 by gatt
Link to comment
Share on other sites

  • Developers

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

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

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

  • Developers

At least I achieved you are willing to type a full sentence now.

Going back to my cave now ;)

Jos

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...