Autoit: ein mit FileOpenDialog ausgewähltes Programm ausführen?

3647
user2723297

Ich muss ein Skript erstellen, mit dem ein Benutzer eine Software mit bestimmten Parametern ausführen kann (die einzugeben sind). Wählen Sie also zunächst das Exe aus. Zweitens sollte ein Texteingabefeld dem Benutzer die Eingabe der Parameter ermöglichen. Ich kann den ersten Schritt nicht machen.

Ich habe es mit dem zweiten gefundenen Beispiel versucht: [ https://www.autoitscript.com/autoit3/docs/functions/FileOpenDialog.htm

Die einzige Modifikation ist ein "Ausführen" -Befehl, den ich hinzugefügt habe. Beim Ausführen des Skripts wird der vollständige Dateipfad für die ausführbare Datei angezeigt. Es wird jedoch nichts ausgeführt. Ich sehe auch keinen Fehler:

include <FileConstants.au3> include <MsgBoxConstants.au3>  Example()  Func Example() ; Create a constant variable in Local scope of the message to display in FileOpenDialog. Local Const $sMessage = "Select a single file of any type."  ; Display an open dialog to select a file. Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "All (*.*)", $FD_FILEMUSTEXIST) If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No file was selected.")  ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) Else ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir)  ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog. $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF)  ; Display the selected file. MsgBox($MB_SYSTEMMODAL, "", "You chose the following file:" & @CRLF & $sFileOpenDialog) Run($sFileOpenDialog) EndIf EndFunc ;==>Example 
2

1 Antwort auf die Frage

0
user2723297
#include <FileConstants.au3> #include <MsgBoxConstants.au3>  Run_with_parameters()  Func Run_with_parameters() Local Const $sMessage = "Select the program to be run."  Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "All (*.*)", $FD_FILEMUSTEXIST) If @error Then MsgBox($MB_SYSTEMMODAL, "", "No file was selected.")  FileChangeDir(@ScriptDir) Else FileChangeDir(@ScriptDir)  $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF) Local $parameters = InputBox("Parameters", "Please type the parameters", "/?", "", _ - 1, -1, 0, 0) Run($sFileOpenDialog & " " & $parameters)  EndIf EndFunc ;==>Run_with_parameters