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

    • Jibberish
      By Jibberish
      Hi all,
      I need to read a log file into an array, but the log file is encoded as $FO_UTF16_BE_NOBOM (2048) = Use Unicode UTF16 Big Endian (without BOM) per FileGetEncoding (it returns 2048).
      I have searched how to convert these log files to UTF-8 and finally found a Powershell command. Since then I have been racking my brain trying to get the function to work. The command itself works from a Powerscript prompt:
      C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command Get-Content C:\Logs\Myplayer_10-10-17-02-31.log | Set-Content -Encoding utf8 C:\Logs\Myplayer1.log This is my sandbox;
      #include <array.au3> #include <File.au3> Local $aArrayLogFile Local $sLogDir = "C:\Logs\" Local $sLogFile = "Myplayer_10-10-17-02-31.log" Local $sConvertedLog = "ConvertedLog.log" Local $sLogDirFile = $sLogDir&$sLogFile RunWait("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command Get-Content "&$sLogDirFile&" | Set-Content -Encoding utf8 "&$sConvertedLog,$sLogDir) _FileReadToArray($sLogDirFile, $aArrayLogFile) _ArrayDisplay($aArrayLogFile) Also tried
      RunWait("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command Get-Content "&$sLogDirFile&" | Set-Content -Encoding utf8 "&$sConvertedLog,$sLogDir) and
      ShellExecuteWait("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"," -Command Get-Content "&$sLogDirFile&" | Set-Content -Encoding utf8 "&$sConvertedLog,$sLogDir) Tried without -Command and a bunch of other parameters that were sprinkled throughout the internet from people trying to get this to work.
      Thanks
      Jibs
    • 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