Jump to content

Run commandline parameters on a script that is already running


Recommended Posts

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

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?

Link to post
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

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

Link to post
Share on other sites

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.

Link to post
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

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

Link to post
Share on other sites

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

Link to post
Share on other sites

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.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By prizm1
      I am trying to pass multi-file selections from Windows Explorer into the $CmdLine argument parameters array. For example, and these are not the literal program/project names, I can pass three full path file names via both Window's Run dialog and Terminal into the $CmdLine array, i.e, "c:\Dir\Program.exe" "D:\Test\file1.txt" "D:\Test\file2.txt" "D:\Test\file3.txt". When checked in the running program, $CmdLine index [1] has the correct value of 3, index [1] is correct with "D:\Test\file1.txt", index [2] with "D:\Test\file2.txt" and index [3] with "D:\Test\file3.txt". I get the same correct results in $CmdLine array when I start Program.exe with the same three file parameters using the Windows Terminal.
      Also, I have added a HKEY_CLASSES_ROOT\*\shell\command key to the Window's registry. The registry entry is with a "C:\Program.exe" "%1" "$2" "%3" string value to allow for renaming file(s) from Windows Explorer via the right-click menu. With just one parameter placeholder, "%1" in the string value, a selected file will appear in $CmdLine. $CmdLine[0] is 1 and $Cmdline[1] contains the selected full path file name. Unfortunately, when I change the registry string value to include two more passing arguments, "%2" "%3", $CmdLine[0] =3 (as it should since three file path names are passed to Program.exe), $CmdLine[1] contains "D:\Test\file1.txt", but $CmdLine[2] and [3] are just empty strings.
      It appears to me that Windows is not passing the second and third ("%2" and "%3") selected file's to Autoit, but just the first parameter "%1".
      Is there some way that I can select more than one file in Window's Explorer and pass the full file paths into the $CmdLine array?
      I know that AutoIt has the _WinAPI_GetOpenFileName function, but I would like to select files directly from Windows Explorer to bring into $CmdLine.
      File Renaming Application 1.4.0.3.au3 Reg Key.reg
    • 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
       
    • By jAutomator
      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!
    • 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.
×
×
  • Create New...