我正在自动进行程序。不幸的是,我在以下多个条件阶段遇到问题:
这是我的完整代码:
我的代码:
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
Example()
Func Example()
; Create a GUI
Local $hGUI = GUICreate("my program", 300, 200)
; Create a combobox control.
Local $idComboBox = GUICtrlCreateCombo("", 10, 10, 185, 20)
Local $idButton = GUICtrlCreateButton("Activate", 210, 140, 85, 25)
Local $idButton_Close = GUICtrlCreateButton("Close", 210, 170, 85, 25)
; Add additional items to the combobox.
GUICtrlSetData($idComboBox, "Arabic|French|English", "Arabic")
; Display the GUI.
GUISetState(@SW_SHOW, $hGUI)
Local $sComboRead = ""
; Loop until the user exits.
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $idButton_Close
ExitLoop
Case $idButton
$sComboRead = GUICtrlRead($idComboBox)
; defining language codes
if $sComboRead = "Arabic" then $slktar = "ar-MA"
if $sComboRead = "French" then $slktfr = "fr-FR"
if $sComboRead = "English" then $slkten = "en-US"
local $slktlng = @ComSpec & " /K " & '"' & @ScriptDir & "binprog.exe enable_language " ;main operation witout the addinional language code
case $slktar
Run($slktlng & " " & $slktar, @ScriptDir & "bin", @SW_HIDE) ; starting main operation + arabic language code
case $slktfr
Run($slktlng & " " & $slktfr, @ScriptDir & "bin", @SW_HIDE) ; starting main operation + french language code
case $slkten
Run($slktlng & " " & $slkten, @ScriptDir & "bin", @SW_HIDE) ; starting main operation + english language code
EndSwitch
WEnd
GUIDelete($hGUI)
EndFunc
我不知道。任何帮助将不胜感激。
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
Example()
Func Example()
Local $sLanguage
; Create a GUI
Local $hGUI = GUICreate("my program", 300, 200)
; Create a combobox control.
Local $idComboBox = GUICtrlCreateCombo("", 10, 10, 185, 20)
Local $idButton = GUICtrlCreateButton("Activate", 210, 140, 85, 25)
Local $idButton_Close = GUICtrlCreateButton("Close", 210, 170, 85, 25)
; Add additional items to the combobox.
GUICtrlSetData($idComboBox, "Arabic|French|English", "Arabic")
; Display the GUI.
GUISetState(@SW_SHOW, $hGUI)
Local $sComboRead = ""
; Loop until the user exits.
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $idButton_Close
ExitLoop
Case $idButton
$sComboRead = GUICtrlRead($idComboBox)
local $slktlng = '"' & @ComSpec & '" /C "' & @ScriptDir & 'binprog.exe" enable_language'
; Define language code.
Switch $sComboRead
Case "Arabic"
$sLanguage = "ar-MA"
Case "French"
$sLanguage = "fr-FR"
Case "English"
$sLanguage = "en-US"
EndSwitch
Run($slktlng & " " & $sLanguage, @ScriptDir & "bin", @SW_HIDE)
EndSwitch
WEnd
GUIDelete($hGUI)
EndFunc
您可以使用另一个switch
语句来定义语言代码。不知道为什么您会使用单独的变量名称语言代码虽然我使用了一个通用名称$sLanguage
分配选定的语言代码。这有助于避免重复代码,即仅一个 Run()
函数需要调用,而不是三个。
还修复了$slktlng
中存储的命令的引号。我将/K
的参数更改为/C
,因此ComSpec
自动完成后关闭。