Jump to content

Looking for a function


Recommended Posts

I've tried help and the forums but don't quite know what I'm looking for so it's hard to search.

Looking for something similar to If ProcessExists ("whatever.exe") Then $a=1

Only for a script i.e. If ScriptExists ("scriptname.au3") Then $a=1

I can't use ProcessExists because all au3 have the same process name.

Link to comment
Share on other sites

  • Developers

Not sure why different scripts have the same EXE name but you could use a unique name with _Singleton() in each script you run and then test for that sOccurenceName in your script.

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

You should compile your scripts to exe :)

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

check this out!

#include <process.au3>
#include <_WinAPI_GetCommandLine.au3> ; got this from this forum here...

#region example
ConsoleWrite(_IsScriptRunning(@ScriptName))
#endregion


Func _IsScriptRunning($ScriptName)
    Local $retVal = -1
    $AutoITProcesses = _GetAutoitScripts()
    
    If $AutoITProcesses[0][0] > 0 Then
        For $i = 0 to $AutoITProcesses[0][0]
            If StringInStr($AutoITProcesses[$i][1],$ScriptName) Then $retVal = 1
    
        Next
    Else
        $retVal = 2 
        SetExtended("Autoit Process Not Found Running?")
    EndIf
    
    
    Return $retVal
EndFunc

Func _GetAutoitScripts()
    ; Script Name only not full path please.
Local $AutoItEXE = _ProcessGetName(@AutoItPID)
Local $ProcessList = ProcessList()
Local $procAutoIT[1][3]
For $i = 0 to $ProcessList[0][0] 
    If $ProcessList[$i][0] = $AutoItEXE Then 
        ReDim $procAutoIT[Ubound($procAutoIT)+1][3]
            $procAutoIT[Ubound($procAutoIT)-1][0] = $ProcessList[$i][1]
            $procAutoIT[Ubound($procAutoIT)-1][1] = _WinAPI_GetCommandLineFromPID($ProcessList[$i][1])
;~          $procAutoIT[$i][2] = 
        EndIf
    Next
    $procAutoIT[0][0] = UBound($procAutoIT)-1
    Return $procAutoIT
EndFunc

_WinAPI_GetCommandLine.au3

_IsScriptRunning.au3

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...