Jump to content
Sign in to follow this  
Chris86

Run commandline parameters on a script that is already running

Recommended Posts

Chris86

Is this possible?

Edited by Chris86

Share this post


Link to post
Share on other sites
water

Can you please give us some more details about what you want to achive?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
orbs

no, it's not possible.

what you are talking about is called IPC (Inter Process Communication). google it or search the forum, there are plenty of means to implement IPC depending on your specific scenario.

Share this post


Link to post
Share on other sites
Chris86

I have a script that needs to be controlled with only two commandline parameters that is ran by a IP-phone software.

So i have to be able to control this script with two commandline parameters; the first command gives the script a phone number and the second tells the script that the phone call was hung up. And im going to have some other functions in this script that is controlled by traymenu.

Is this possible to have in one script or do i need to have two?

Share this post


Link to post
Share on other sites
water

Can you post the script so we can see what you already have coded.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
guinness

To add to what water said, what application are you using?

One option would be to close the running process and open again by passing the commandline parameters or search for WM_COPYDATA, if the application you're using can interact with this message. No idea!


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
orbs

considering the missing information, yap, that's IPC allright.

if both scripts are at your control, it's easy. but if one is an external program, you need 2 scripts:

program calls script A telling it to start monitoring the call

script A monitors the call, and also monitors an IPC channel (and also monitors the GUI for tray menu activity, as you say)

---

program calls script B telling it the call has ended

script B sends script A a message via IPC, that the call has ended

the IPC channel, in this case, can be as simple as a flag file: script B creates a file by a specific name, and script A looping a FileExists() check on that file, and if that file exists, then script A does what it needs to do when the call has ended.

Share this post


Link to post
Share on other sites
water

Chris86,

from the replies you got so far you can see that we need more information to help you.

Tell us the application you try to automate, post the script you've coded so far etc. etc.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Chris86

considering the missing information, yap, that's IPC allright.

if both scripts are at your control, it's easy. but if one is an external program, you need 2 scripts:

program calls script A telling it to start monitoring the call

script A monitors the call, and also monitors an IPC channel (and also monitors the GUI for tray menu activity, as you say)

---

program calls script B telling it the call has ended

script B sends script A a message via IPC, that the call has ended

the IPC channel, in this case, can be as simple as a flag file: script B creates a file by a specific name, and script A looping a FileExists() check on that file, and if that file exists, then script A does what it needs to do when the call has ended.

Since i cannot do what i planed i will try this thanks :)

Share this post


Link to post
Share on other sites
Carlo84

What i do is check if the script is already running and in that case write the parameters into a ini file and then exit.

In the main idle loop of my script i keep checking the ini for new input and execute it if anything is found.

Same effect diffrent execution :-)

hope this helps

Share this post


Link to post
Share on other sites
orbs

i was bored.

script A:

#include <Misc.au3>

Global Const $sFlagFile=@TempDir&'\FlagFile.txt'    ; this is identical in both scripts

If _Singleton('Script_A',1)=0 Then
    MsgBox(0,'Script_A','Hey! Can''t you see I''m busy?  ',5)
    Exit
EndIf

While True
    ; check for flag
    If FileExists($sFlagFile) Then
        MsgBox(0,'Script_A','ok, ok, I''m stopping...  ',5)
        FileDelete($sFlagFile)
        Exit
    EndIf

    ; chek user activity in tray menu
    ; ** add your code here

    ; do real stuff
    ; ** add your code here

WEnd

script B:

Global Const $sFlagFile=@TempDir&'\FlagFile.txt'    ; this is identical in both scripts

If ProcessExists('Script_A.exe') Then
    If FileExists($sFlagFile) Then
        MsgBox(0,'Script_B','Hey, I already asked Script A to stop. There must be something wronf with it.  ',5)
    Else
        MsgBox(0,'Script_B','I will stop Script_A now.  ',5)
        FileWriteLine($sFlagFile,'if this file exists, it means Script_B is trying to stop Script_A.  ')
    EndIf
Else
    MsgBox(0,'Script_B','Hey, I you need to start Script_A before I can stop it.  ',5)
    Exit
EndIf

compile both scripts to exe. now you behave like your IP phone application: call script A to start, then call script B to stop script A.

bonus: see what happens if you call script A twice, or if you call script B when script A is not running.

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  

  • Similar Content

    • Skysnake
      By Skysnake
      Hi
      Problem is this
      myscript -p <zumerkelen> -x something else myscript is my AutoIt compiled CUI.  
      -p <> is first param - fails, see below
      -x [text] second param, works.
      When I run this with the param enclosed in <> I get the response
      The syntax of the command is incorrect.
      Experimentation indicates that the <> tags are the problem.
      _ArrayDisplay($CmdLine, "1 Array") MsgBox(16, "1 Raw", $CmdLineRaw) The problem is with the reading of the command line.  It fails BEFORE it gets into the variables...

      I am not dealing with AutoIt, or even my own command line, this is legacy software.  It seems that AutoIt "interprets" the <> before loading the command line...  I need to be able to read that as text without it being interpreted.
      The only part I can control is my script, the myscript, which I can change at will.
      The standard command line functions appear all to interpret params on read.  I want those params read raw.   If I could just get that as a string it would be fine.
      Where to look?
      Skysnake
       
    • jsmcpn
      By jsmcpn
      Hello all!  I'm trying to make a little script that sends a message over TCP.  An example payload would be:
      MY_PAYLOAD#<ATTRS><ATTR><NAME>MAILSERVER</NAME><OPERATION>set_value(ServiceStatus)</OPERATION><VALUE><![CDATA["Not Running"]]></VALUE><TIMESTAMP>1349297031</TIMESTAMP></ATTR></ATTRS> Note how the payload contains special characters, and how the CDATA contains a SPACE (i.e.  "Not Running")
      My compiled AU3 script expects exactly two command line arguments:
      1) destination server/port expressed as 127.0.0.1:80
      2) the payload I want to send to my server application (which may have multiple ATTRs, this example only has one ATTR)
      MyApp.exe 127.0.0.1:80 "MY_PAYLOAD#<ATTRS><ATTR><NAME>MAILSERVER</NAME><OPERATION>set_value(ServiceStatus)</OPERATION><VALUE><![CDATA["Not Running"]]></VALUE><TIMESTAMP>1349297031</TIMESTAMP></ATTR></ATTRS>"  
      My problems (plural) are with parsing of the second argument:
      1)  If I don't wrap second argument in double-quotes, then Windows bails out before even launching EXE with "< was unexpected at this time"
      2)  If I DO wrap second argument in double-quotes, then two problems can arise when my EXE parses the arguments:
                   aa) The double-quotes are stripped from the CDATA value. ["Running"] is stored in the array as [Running]
                   bb) If CDATA value DOES have a space, such as ["Not Running"], then I get an extra unwanted $CmdLine[3] because the SPACE between Not and Running is treated as a separator.  My second argument is thus split into two separate arguments, [2] and [3] instead of being treated as one arg stored in [2]
                              cc) Additionally, my script exits because it has an "IF $CmdLine[0] <>2 THEN Exit (1)" to validate the command line args.
      I've tried launching the EXE with the second argument wrapped and escaped in a multitude of ways.  Double double-quotes, triple double-quotes, single-quotes on the outside with double-quotes inside (i.e.  '"ETC"'), starting the second arg with a caret (i.e. ^"ETC") and one of three things happens:
      1) "< was unexpected at this time"
      2) my CDATA value is stripped of its double-quotes
      3) my payload argument gets split at the space in the CDATA value and the script bails out due to the unexpected 3rd argument.
       
      Any ideas?  How can I preserve the second argument literally, including all special characters, quotes and spaces?
      I tried adding some string manipulation code to grab the 2nd argument from $CmdLineRaw and it works (preserves the "Not Running" with quotes), but my number of arguments is still 3 instead of 2 if there is a space in the CDATA value.
       
      Any assistance would be greatly appreciated!
    • jazzyjeff
      By jazzyjeff
      Hello,

      I am trying to understand the $CmdLine array. My goal is to run scriptA.exe have it create a variable $varA and then run scriptB.exe and have scriptB.exe output $varA to a Msgbox. It isn't working though, so I am not getting how this works.

      This is what I am trying:
      ScriptA -

      $varA = 'Test' Run('d:\(x86)\AutoIt3\AutoIt3.exe "D:\AutoIT Script\CMDLINE\scriptB.au3"') ScriptB -

      If $CmdLine[0] = 0 Then MsgBox(64, "Result", "No variable was found.") Else MsgBox(64, "Variable", $CmdLine[1] & $varA) EndIf
      If someone can help me understand why this isn't working, I'd appreciate it.
×