Показать полную графическую версию : [решено] $CmdLine[0,1,2,3], $CmdLineRaw... как этим пользоваться.
Не понимаю как написать скрипт. Лучше я свой батник покажу, что мне надо зделать в autoit3 варианте.
..\system32\Cubase.cmd:
@if "%1"=="r" regedit.exe & goto sh
@if "%1"=="t" taskmgr.exe & goto sh
@if "%1"=="s" shutdown -r -f -t 00 & goto sh
@if "%1"=="x" shutdown -s -f -t 00 & goto sh
@if "%1"=="p" VSTPluginsPath.exe & goto sh
@start "" "C:\I\Apps\Cubase\Cubase.exe" %*
:sh
If $cmdline[0] = r Then... так что ли? Впринципе до меня только одно дошло, то что *.* это $CmdLineRaw.
Наверное после каждого Then будет свой ShellExecute... громозко как-то получится?
Вообщем, подскажите, пожалуйста?
---
Вот попытался набросок зделать, глючит немнжко :)
If $CmdLine[0]="r" Then
ShellExecute("regedit.exe")
ElseIf $CmdLine[1]="t" Then
ShellExecute("taskmgr.exe")
Else
ShellExecute(@ProgramFilesDir & "\Cubase\Cubase.exe", $CmdLineRaw)
EndIf
вариант два, ещё хуже стало ))) :(
#Include <Array.au3>
If $CmdLine[0]="r" Then
ShellExecute("regedit.exe")
ElseIf $CmdLine[1]="t" Then
ShellExecute("taskmgr.exe")
ElseIf $CmdLineRaw Then
ShellExecute(@ProgramFilesDir & "\Cubase\Cubase.exe", $CmdLineRaw)
Else
ShellExecute(@ProgramFilesDir & "\Cubase\Cubase.exe")
EndIf
Select
Case $CmdLine[0]=1 And $CmdLine[1]="r"
Run("regedit.exe", @WindowsDir)
Case $CmdLine[0]=1 And $CmdLine[1]="t"
Run("taskmgr.exe", @SystemDir)
Case $CmdLine[0]=1 And $CmdLine[1]="s"
Run("shutdown -r -f -t 0", @SystemDir)
Case $CmdLine[0]=1 And $CmdLine[1]="x"
Run("shutdown -s -f -t 0", @SystemDir)
Case $CmdLine[0]=1 And $CmdLine[1]="p"
Run("VSTPluginsPath.exe")
Case Else
Run("C:\I\Apps\Cubase\Cubase.exe "& $CmdLineRaw)
EndSelect
Или так:
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $CmdLine[0] = 0 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then) Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $CmdLine[1]
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) "r"
Run (http://www.autoitscript.com/autoit3/docs/functions/Run.htm)("regedit.exe", @WindowsDir (http://www.autoitscript.com/autoit3/docs/macros.htm#@windowsdir))
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) "t"
Run (http://www.autoitscript.com/autoit3/docs/functions/Run.htm)("taskmgr.exe", @SystemDir (http://www.autoitscript.com/autoit3/docs/macros.htm#@systemdir))
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) "s"
Run (http://www.autoitscript.com/autoit3/docs/functions/Run.htm)("shutdown -r -f -t 0", @SystemDir (http://www.autoitscript.com/autoit3/docs/macros.htm#@systemdir))
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) "x"
Run (http://www.autoitscript.com/autoit3/docs/functions/Run.htm)("shutdown -s -f -t 0", @SystemDir (http://www.autoitscript.com/autoit3/docs/macros.htm#@systemdir))
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) "p"
Run (http://www.autoitscript.com/autoit3/docs/functions/Run.htm)("VSTPluginsPath.exe")
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) Else (http://www.autoitscript.com/autoit3/docs/keywords.htm#Else)
Run (http://www.autoitscript.com/autoit3/docs/functions/Run.htm)("C:\I\Apps\Cubase\Cubase.exe "& $CmdLineRaw)
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
madmasles
20-08-2010, 18:21
semiono,
$CmdLine[0] возвращает количество параметров. Честно говоря, я сам с ними долго разбирался. Попробуйте создать 2 скрипта. 1-ый:#include <Constants.au3>
$mod = Run(@AutoItExe & ' /AutoIt3ExecuteScript Test.au3 Первый_параметр Второй_параметр Третий_параметр', @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
$sLog = ''
While 1
$sLog &= StdoutRead($mod)
If @error Then ExitLoop
Sleep(2)
WEnd
MsgBox(0, '', $sLog)2-ой (назовите его Test.au3 и положите в ту же папку, где лежит 1-ый):If Not $CmdLine[0] Then
ConsoleWrite('Нет параметров' & @LF)
Exit
EndIf
For $i = 1 To $CmdLine[0]
ConsoleWrite($CmdLine[$i] & @LF)
Sleep(100)
Next
ConsoleWrite(@LF & 'Все!' & @LF)Теперь запускайте 1-ый скрипт и меняйте параметры. Я сам с этим игрался, чтобы разобраться. Кстати, если скомпилировать первый скрипт, то он будет запускать второй и на компьютере с неустановленным AutoIt`oм. :)
PS
Кажется, Yashied приводил примерно такой пример на autoit-script.ru, лень искать.
Очень изящные красивые примеры! Их хоть прямо в справку записывай, отлично!
amel27, Creat0R, madmasles, благодарю!
Ещё по теме: _CmdLineSetEvent - Обработчик командной строки (http://autoit-script.ru/index.php/topic,984.0.html)
Всётаки эта тема безконечная. :)
Запускаю консольное приложение, ISCC.exe - кампилятор Inno Setup.
Задача просто передать ему управление.
Вот батник который работает:
\system32\ISCC.cmd
@"C:\I\Apps\Innosup\ISCC.exe" %*
Я уже все варианты перебрал наугад, в лучшм случае выдаёт справку, но на вход комманды не хочет воспринимать.
#Include <Constants.au3>
Run(@ProgramFilesDir & "\Innosup\ISCC.exe ", $CmdLineRaw, ".", $STDERR_CHILD & $STDIN_CHILD & $STDOUT_CHILD)
Кампилю как "Create CUI instead of GUI.EXE", хотя может быть не надо? :)
Смысл флагов $STDIN_CHILD не очень понятен, но где-то что-то я улавливаю приблизительно. ))
уже все варианты перебрал наугад »право, быстрей в справку глянуть:Run(@ProgramFilesDir &"\Innosup\ISCC.exe "& $CmdLineRaw, @ScriptDir, @SW_HIDE, $STDERR_CHILD + $STDIN_CHILD + $STDOUT_CHILD)
А вот так правильно?
$pid = Run(@ProgramFilesDir & "\Innosup\ISCC.exe " & $CmdLineRaw, @WorkingDir, @SW_ENABLE, $STDIO_INHERIT_PARENT)
StdioClose($pid)
У меня не до конца прокрутка в консоли срабатывет, будто бы подвисает на одну строку.
Но работа ISCC.exe кампилятора выполняется.
Понял проблему!! Надо было RunWait() теперь не подвисает! Анологично батнику чётко работает.
Но что лучше $STDIO_INHERIT_PARENT или 0x1 + 0x2 ?? И надо ли закрывать процесс StdioClose($pid) ?
semiono, в RunWait нет таких флагов, и по понятной причине - скрипт останавливается до тех пор, пока не завершит работу запущенный процесс
© OSzone.net 2001-2012
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.