Jump to content

_FileAlreadyRunning()


tttommeke
 Share

Recommended Posts

Somethimes you have programs that are only allowed to run once so when the user looks in processlist their won't be like 100X{Program}. This is a function that will look if the program isn't started yet by previous users and if it is he will close himself down (You can add easily a msgbox or so with it)

Func _AlreadyRunning()
    If ProcessExists(@Scriptname) Then
        $list = ProcessList()
            for $i = 1 to $list[0][0]
            If $list[$i][0] = @ScriptName And $list[$i][1] <> @AutoItPID Then 
                Exit
            EndIf
            Next
    EndIf
EndFunc
Link to comment
Share on other sites

Somethimes you have programs that are only allowed to run once so when the user looks in processlist their won't be like 100X{Program}. This is a function that will look if the program isn't started yet by previous users and if it is he will close himself down (You can add easily a msgbox or so with it)

Func _AlreadyRunning()
    If ProcessExists(@Scriptname) Then
        $list = ProcessList()
            for $i = 1 to $list[0][0]
            If $list[$i][0] = @ScriptName And $list[$i][1] <> @AutoItPID Then 
                Exit
            EndIf
            Next
    EndIf
EndFunc
As ashley says, but also it's too easy for someone to rename an exe and then your method would fail I think.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

As ashley says, but also it's too easy for someone to rename an exe and then your method would fail I think.

@Scriptname is dynamic, but I believe it would be inaccurate if another process had the same name other than the script.

Edited by mrRevoked
Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

  • 2 weeks later...

k well newbie's bother me, and I'm not really to nice to them all the time. Mainly ones that like to create bots or 'pranks'

On the other hand I am really cool to newbies that want to actually learn things, I'm always open to hear about their Ideas and help them write scripts..

[center][/center]

Link to comment
Share on other sites

k well newbie's bother me, and I'm not really to nice to them all the time. Mainly ones that like to create bots or 'pranks'

On the other hand I am really cool to newbies that want to actually learn things, I'm always open to hear about their Ideas and help them write scripts..

im practically a newb myself but i help when i can. Most of us work in IS or some similar industry. We can all joke around about our profession and society's image of fat guys hunching over in dark places lit by the glow of a computer screen. take care man.

Link to comment
Share on other sites

ture its dynamic but your right you could run it, rename it, then run it again...

I always used _Singleton() and it worked fine for my purpose...

That's a neat function. If you believe MS that GUIDs really are unique a nice touch is to use one of those GUID string generators and paste it in for the name param. I've been using that for Kernel Object names such as named mutexes, memory mapped files etc.. since Win9x.

_Singleton("49437747-7A33-450C-AE71-7790430CBAE8")

as example

Link to comment
Share on other sites

  • 1 year later...

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