Shaarad Posted November 6, 2010 Share Posted November 6, 2010 Hello everyone...I am facing little difficulty with programming... I want to create a program which will avoid running itself if it is already running and will exit, but will run normally if it is not running previously.... maybe there is a command for this but i didn't find it so I posted for help... any help will be greatly appriciated ! Eagerly waiting for your response.... Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 6, 2010 Moderators Share Posted November 6, 2010 Shaarad,Look at _Singleton in the Help file. Although I tend to use WinExists with title and text parameters myself. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
somdcomputerguy Posted November 6, 2010 Share Posted November 6, 2010 ProcessExists can be used too. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
martin Posted November 6, 2010 Share Posted November 6, 2010 ProcessExists can be used too.Not ideal because you can rename an exe. 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 More sharing options...
Realm Posted November 6, 2010 Share Posted November 6, 2010 (edited) Not ideal because you can rename an exe.that would also cancel out WinExist(), because Window Titles can be renamed as well.Edit: It all depends on what the OP needs this for. If to insure he does not open the same application twice, than any of the options will work. Otherwise, If he is trying to block his users from running more than once instance, than _Singleton appears to be the best choice, due to the other ways can be deterred. Edited November 6, 2010 by Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
Shaarad Posted November 7, 2010 Author Share Posted November 7, 2010 I think WinExists won't do because my program doesn't show any window as such.... _Singleton can help. I'll see and let you guys know my status. Thanks all for your replies! Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Delta Posted November 7, 2010 Share Posted November 7, 2010 Realm WinExist() would work because the end user can't change the window title. Shaarad even though you didn't create a window AutoIt still creates a hidden window on it's on. You can set that window's title with the function AutoItWinSetTitle(). [size="1"]Please stop confusing "how to" with "how do"[/size] Link to comment Share on other sites More sharing options...
Shaarad Posted November 7, 2010 Author Share Posted November 7, 2010 hey guys _singleton worked. The example given in the help file was exactly what I needed. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
supadodger Posted November 7, 2010 Share Posted November 7, 2010 at the beginning of your script put a check for a registry key and if it exists exit if it doesnt exist write it and then continue the script... at the end of your script put a regdelete and if you got a gui put a regdelete before all exits.... you can check for process window title regwrite and even write a @tempdir appname.lock and check for that... you can make so many checks your end user cannot bypass if you wish.... i hope i helped good luck, Link to comment Share on other sites More sharing options...
Developers Jos Posted November 7, 2010 Developers Share Posted November 7, 2010 at the beginning of your script puta check for a registry key and if it exists exitif it doesnt exist write it and then continue the script...at the end of your script put a regdeleteand if you got a gui put a regdelete before all exits....you can check for process window title regwrite and even write a @tempdir appname.lock and check for that...you can make so many checks your end user cannot bypass if you wish....i hope i helped good luck,_Singleton() sounds a lot simpler and a lot less error prawn. 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 More sharing options...
Realm Posted November 7, 2010 Share Posted November 7, 2010 (edited) Realm WinExist() would work because the end user can't change the window title.Deltaforce229, You are correct, the 'common end user' would not figure out how to change the window title. Nor would the 'common end user' think about changing the title of an '.exe'. However, I still believe that _Singleton() is the best of the available options if your attempting to advert an above average end user from running multiple instances. With _Singleton() the end user, can change the title of an .exe and even the window title itself, but singleton will still be able to identify it as another instance of the said application.RealmEdit: The end user can change a window title, almost every basic syntax language that I know of offer ways to change window titles. AutoIt's very own WinSetTitle() can change another applications window title. Edited November 7, 2010 by Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now