jloyzaga

run notepad++ and receive parameter from command line

2 posts in this topic

I can run this and notepad++ opens the file Run("C:\Program Files (x86)\Notepad++\notepad++.exe E:\icare\icare\NI-WI-NBSE-ERR.xml")

But what I want is to run the .au3 or exe from command line and send it the file as parameter -am I being to simplistic in hoping its this easy?

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <File.au3>
;E:\icare\icare\NI-WI-NBSE-ERR.xml
;Run("C:\Program Files (x86)\Notepad++\notepad++.exe E:\icare\icare\NI-WI-NBSE-ERR.xml")

Run("C:\Program Files (x86)\Notepad++\notepad++.exe " & $CmdLine[0] )
sleep (200)
Send("{CTRLDOWN}a{CTRLUP}")
sleep (500)
Send("{CTRLDOWN}a{CTRLUP}{CTRLDOWN}s{CTRLUP}{CTRLDOWN}{SHIFTDOWN}b{CTRLUP}{SHIFTUP}")
sleep (500)
Send("{CTRLDOWN}{ALTDOWN}s{ALTUP}{CTRLUP}")
sleep (500)
Send("E:\icare\icare\NI_WI_MONTHLY_INSTALMENTS_c2base64-7.txt")
sleep (500)
Send("{ENTER}")

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

CmdLine[0] is the count, you need to use CmdLine[1]

Also you can use ^ in place of Control + in place of Shift so something like this:

If $CmdLine[0] > 0 Then
    If FileExists($CmdLine[1]) Then
        Run(@ProgramFilesDir & '\Notepad++\notepad++.exe "' & $CmdLine[1] & '"')
        Send("^a")
        Send("^a^s^+b")
        sleep (500)
        Send("^!s")
        sleep (500)
        Send("E:\icare\icare\NI_WI_MONTHLY_INSTALMENTS_c2base64-7.txt")
        sleep (500)
        Send("{ENTER}")
    EndIf
EndIf

 

Edited by Subz

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

  • Similar Content

    • Tigerweld
      By Tigerweld
      How do I make this variable work?
      $MY_SESSION_ID = for /f "tokens=3-4" %%a in ('query session %username%') do @if "%%b"=="Active" set MY_SESSION_ID=%%a MsgBox(1, "My Session ID", "Session ID is: " & $MY_SESSION_ID)  
    • theak
      By theak
      ShellExecute("\\servername\cofs\Organization\ITS\_Software & Hardware\AS400\DVD\Windows\cwblaunch.exe", '"/v/qn ADDLOCAL=ALL"')  I had to dig to find the right setup.exe according to the documentation but I got it to run. However, it pops up with this dialog box (attached) showing me the command line parameters, as if I'm incorrect.
       
       
      It continues to run the install however, but seemingly without any of the command line parameters.
      Here's the command I entered into the CMD prompt exactly:
      "\\servername\cofs\Organization\ITS\_Software & Hardware\AS400\DVD\Windows\image64a\setup.exe",'"/v/qn ADDLOCAL=ALL"'
    • Tdurrant
      By Tdurrant
      I feel like i have been going in circles and getting no where
      I am trying to do a git pull
       
      LOCAL $sTemp = '"C:\Program Files (x86)\Git\bin\git.exe" pull'
      LOCAL $sLine = ''
      local $sToWrite = ''
      local $PID = Run($sTemp,$GitDir,@SW_MAXIMIZE, $STDIN_CHILD + $STDOUT_CHILD)
      StdinWrite($PID,$sToWrite)
      IF( $PID <> 0) THEN
          While 1
              $sLine &= StdoutRead($PID)
              MsgBox(0,'returned',$sLine)
              If @error Then ExitLoop
              Sleep(25)
          Wend
          Exit
      EndIf
      i have also tried
      LOCAL $sTemp = '"C:\Program Files (x86)\Git\bin\git.exe" pull'
      LOCAL $sLine = ''
      local $PID = Run($sTemp,$GitDir,@SW_MAXIMIZE, $STDIN_CHILD + $STDOUT_CHILD)
      StdinWrite($PID)
      IF( $PID <> 0) THEN
          While 1
              $sLine &= StdoutRead($PID)
              MsgBox(0,'returned',$sLine)
              If @error Then ExitLoop
              Sleep(25)
          Wend
          Exit
      EndIf
       
      This triggers the command prompt which gives me this info eventually
      Username for 'SomeNonGitHubRepositiory':
      Problem is that My message box always returns a blank without erroring out
      If it did return somethign then i would do
      $sToWrite = 'Username'
      StdinWrite($PID,$sToWrite)
      What did i miss?
    • Skysnake
      By Skysnake
      Hi Everyone
      I want to have a GUI, but which will accept command line options on launch.
      So, the commanline would look something like
      myAPP.EXE -bigfont -bigicon
      where myAPP.EXE would be the name of the AutoIt EXE, and the -bigfont & -bigicon items represent optional command line parameters with which the EXE starts.
      I am not looking at creating a CUI.  This is GUI, but with startup command line parameters.  These command line parameters would only be read once, during start up of the EXE.
      I have searched the forum, no luck.  What I did find was this commented by Water: https://www.autoitscript.com/forum/topic/138754-adding-command-line-parameter/
      Should I start the GUI EXE as normal, and then first possible opportunity read the command line? Is that the way to go?
      Thanks in advance
    • edthedestroyer
      By edthedestroyer
      I am trying to create a script that allows me to run and use it with CMD as the interface.

      For example:



      This is the code I have so far...

      #AutoIt3Wrapper_Change2CUI=y ConsoleWrite("Enter PIN" & @CRLF & ":") Local $input While 1 $input &= ConsoleRead() if StringInStr($input,@CRLF) <> 0 then ExitLoop Wend if $input = "1111" & @CRLF Then ConsoleWrite("Success") Else ConsoleWrite("Failure") ConsoleWrite($input) EndIf
      The problem is that after it writes Enter PIN: it will not accept input and gets stuck. After I close the script, all the input I typed shows up in cmd.


      I want be able to run this script without opening another cmd window but I haven't been able to find relevant examples for creating a "console" application used through cmd.
      Can anyone help me out?