Trystian Posted February 9, 2007 Share Posted February 9, 2007 (edited) Greetings again. I am trying to make a program that will detect if it is already running, and if so, will pass information received via a command line parameter to the first instance of the program, then exit the second instance. I have searched the forums for an hour trying to find a solution, but to no avail. I'm sure it's been discussed before. Typically, I use the console for debugging my uncompiled scripts (in SciTE), but never used it for compiled scripts before. Anyhow, here are snippets of what I have so far (Compiled script is named "VideoLan.exe").... #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) If $CmdLine[0] = 1 Then $sSourceFile = $CmdLine[1] EndIf $aProcess = ProcessList("VideoLan.exe") if $aProcess[0][0] > 1 Then ConsoleWrite("VideoLan: " & $sSourceFile) Exit 0 EndIf <gui stuff goes here> While 1 If ConsoleRead(0,true) > 0 Then $sCon = ConsoleRead() if StringLeft($sCon,8) = "VideoLan" Then GUICtrlSetData ($gSourceInput,StringMid($sCon,11)) EndIf EndIf Sleep(100) WEnd <functions go here> I think that the ConsoleRead/ConsoleWrite isn't the correct functions for what I need. I looked at StdoutRead/StdoutWrite, but from what I understood, that would only work for child processes, which this program wouldn't apply. Thank you in advance, -Trystian PS: I'm using AutoIT 3.2.2.0 Edited February 9, 2007 by TrystianSky Link to comment Share on other sites More sharing options...
evilertoaster Posted February 9, 2007 Share Posted February 9, 2007 you want some kinda of multithread/co-routine -http://www.autoitscript.com/forum/index.php?showtopic=22069http://www.autoitscript.com/forum/index.php?showtopic=23545 Link to comment Share on other sites More sharing options...
Trystian Posted February 9, 2007 Author Share Posted February 9, 2007 you want some kinda of multithread/co-routine -http://www.autoitscript.com/forum/index.php?showtopic=22069http://www.autoitscript.com/forum/index.php?showtopic=23545Thank you. I read those threads, but was hoping to use something a bit more simplistic, without having to resort to requiring TCP/UDP, File or Registry Access. Perhaps I'm being too picky. Link to comment Share on other sites More sharing options...
evilertoaster Posted February 9, 2007 Share Posted February 9, 2007 (edited) neogia's method (second link) using standard i/o steam to communcate between 'threads' which (in my mind) would be the standard method. If you elimnate std i/o, tcp, file and registry access as communcation types your really not left with much else besides direct memory modfications (you dont wanna do that). Edited February 9, 2007 by evilertoaster Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 9, 2007 Moderators Share Posted February 9, 2007 If you are speaking of your own AutoIt App.. _SingleTon() will kill the 2nd instance, and you could always write to a file for the 1st instance to check occasionally if it must know the 2nd instance was ever launched, maybe with AdlibEnable() (to check periodically). 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...
PaulIA Posted February 9, 2007 Share Posted February 9, 2007 If each application has a GUI, you can also use the RegisterWindowMessage and SendMessage API calls as well. Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
therks Posted February 9, 2007 Share Posted February 9, 2007 I've actually done something like this before with a program I created. I just wanted it to activate itself if you ran the program again. This is what I used. #region - unique run Global $s_AutoItWinTitle = 'AutoIt3.FireKey.Window' If WinExists($s_AutoItWinTitle) Then ControlSetText($s_AutoItWinTitle, '', 'Edit1', 'SHOW') Exit EndIf AutoItWinSetTitle($s_AutoItWinTitle) #endregion My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
Trystian Posted February 9, 2007 Author Share Posted February 9, 2007 (edited) Ok, I got it to work now, and here's the code.... #include <GUIConstants.au3> Opt("WinTitleMatchMode", 4) Opt("GUIOnEventMode", 1) if $CmdLine[0] = 1 Then $sSourceFile = $CmdLine[1] EndIf $aProcess = ProcessList(@ScriptName) if $aProcess[0][0] > 1 Then $handle = WinGetHandle("classname=AutoIt v3 GUI","VideoLan Stream Launcher") ControlSetText($handle,"","Edit1",$sSourceFile,0) WinActivate($handle) Exit 0 EndIf <gui stuff goes here> While 1 Sleep(100) WEnd <functions go here> Thank you all for the assistance. Edited February 9, 2007 by TrystianSky Link to comment Share on other sites More sharing options...
Trystian Posted February 9, 2007 Author Share Posted February 9, 2007 Saunders, looks like you did something very similar. You posted while I was typing my last message. I'm slow. 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