我正在研究一些AutoIt代碼來幫助我處理辦公室惡作劇和東西。第一個字符串的作用是將字符串「shutdown pc00xxx」重寫爲shutdown /r /m pc00xxx /t 0
,但我無法獲得第二個字符串。在AutoIt中重寫一個字符串一次,但不是第二次
我有以下代碼:
func RunProc($string)
Local $command = StringLower($string)
Local $subs = StringMid($command, 1, 4)
Local $computer = StringInStr($command, "pc")
if $subs == "shut" Then
Run("shutdown /r /m " & StringMid($command, $computer) & " /t 0")
ElseIf $subs == "clos" Then
Local $prleft = StringTrimLeft($command, 6)
Local $extend = StringInStr($command, "on")
Local $pright = StringTrimRight($prleft, $extend)
Local $strclose = StringMid($string, $prleft, $pright)
Run("taskkill.exe /S "& StringMid($command, $computer) & " /im " & $strclose & ".exe")
EndIf
的問題是,我試圖改寫短語「CLOSE 「東西」 ON 「pc00xxx」 是taskkill.exe/S pc00xxx/IM SOMETHING.exe ,我正在嘗試獲取「CLOSE」和「ON pc00xxx之間的子串」。
因此,舉例來說,我會鍵入關閉Outlook ON PC00xxx和有$ a的值strclose是:
$strclose = outlook