Jump to content

how to detect if an other copy from the same script if runing


Recommended Posts

Hello
How are you
I have a question, please.
I've created a window and i need
when i run the script if it detect an other copy from the same script was runing
 the script close the first copy Automatically and run a new copy
I want an example to understand it

Link to comment
Share on other sites

Danp2 exactly described what to do. What have you tried so far?

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

In fact, all my attempts were unsuccessful
I apologize for bothering you all this time because of my poor understanding of this. If there is no inconvenience I want a simple example to explain to me
I would be thankful to all of you
Greetings to you, right you are a good peoples

Link to comment
Share on other sites

Hello
I apologize very much for bothering you all
But it's very important to me
I will now try to explain in detail what I want to do and please help me with this
1. I designed an audio player called easy audio player
The executable file name is easyAudioPlayer.exe
Its task is to play audio files
I have made this player the default in opening my audio files.
2 What I want is if you press an audio file if the program finds another file that is open in the same program, it will closes it and opens the file that was pressed
This is exactly what I want
please help
By typing a simple example,
Greetings to all of you and I repeat my apologies
I apologize for my weak English

Link to comment
Share on other sites

You should stop apologizing about your English and instead apologize for your lack of effort in solving the issue for yourself.

You've been given pointers on how to do it. Now how about you show some code showing where you've actually tried to solve it yourself instead of repeatedly asking for someone else to write the code for you.

Link to comment
Share on other sites

I tried writing this function but it did not work
Please correct the error if any
Greetings
Thank you very much

 

Func check($exefile = @ScriptName, $HWND = $hGUI)
    Local $process = $exefile, $window = $HWND, $return
    Local $iPID = WinGetProcess($window)
    If @error Then Return -1
    Local $aProcessList = ProcessList($process)
    If @error Then Return -1
    For $i = 1 To $aProcessList[0][0]
        If Not $aProcessList[$i][1] = $iPID Then
            ProcessClose($aProcessList[$i][1])
        EndIf
    Next
    Return 1
EndFunc   ;==>check

 

Edited by Jos
Link to comment
Share on other sites

  • Developers

Something like this?

Func check($exefile)
    Local $OwnPID = @AutoItPID
    Local $aProcessList = ProcessList($exefile)
    If @error Then Return -1
    For $i = 1 To $aProcessList[0][0]
        If Not $aProcessList[$i][1] = $OwnPID Then
            ProcessClose($aProcessList[$i][1])
        EndIf
    Next
    Return 1
EndFunc   ;==>check

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

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

×
×
  • Create New...