Sign in to follow this  
Followers 0
tttommeke

_FileAlreadyRunning()

15 posts in this topic

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Sweet!! I like the smaller one.. LOL

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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()

Share this post


Link to post
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...


[center][/center]

Share this post


Link to post
Share on other sites

ack!!! nerds bickering run for the hills!

Share this post


Link to post
Share on other sites

ack!!! nerds bickering run for the hills!

Dude shut the hell up...


[center][/center]

Share this post


Link to post
Share on other sites

Dude shut the hell up...

Whoa, just messing around man. Don't take offense.

Share this post


Link to post
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..


[center][/center]

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Hah ok thought you were another of the newbies that I would grow to hate.


[center][/center]

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Sweet works great to solve an issue I had with multiple runs

Share this post


Link to post
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
Sign in to follow this  
Followers 0