Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Slight Script Issue

$
0
0

Hello all

 

I wrote this a little while back and iv just noticed it has a problem:

AutoIt Code         
If Not FileExists("C:\Program Files (x86)\AutoIt3\AutoIt3.exe") Then MsgBox(0, "", "You Must have AutoIt Software Installed to run this Program") Exit EndIf #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #region ### START Koda GUI section ### Form= $Form1_1 = GUICreate("AutoIt Command Prompt", 617, 306, 257, 129) GUISetBkColor(0xC0C0C0) $Label1 = GUICtrlCreateLabel("AutoIt Command Prompt", 8, 8, 598, 33, BitOR($SS_CENTER, $SS_CENTERIMAGE, $SS_SUNKEN)) GUICtrlSetFont(-1, 18, 800, 4, "MS Sans Serif") GUICtrlSetBkColor(-1, 0x99B4D1) $Input1 = GUICtrlCreateInput("", 8, 144, 601, 28) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("Enter Commands below:", 8, 56, 212, 28, BitOR($SS_CENTER, $SS_CENTERIMAGE, $SS_SUNKEN)) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0x99B4D1) $Button1 = GUICtrlCreateButton("Execute", 8, 192, 601, 57) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Button2 = GUICtrlCreateButton("Help", 8, 264, 601, 33) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Button3 = GUICtrlCreateButton("Include", 48, 96, 209, 33) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Label3 = GUICtrlCreateLabel("", 272, 97, 332, 30, BitOR($SS_CENTER, $SS_CENTERIMAGE, $SS_SUNKEN)) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xF0F0F0) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### $file = @AppDataDir & "\command.au3" While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE FileDelete($file) Exit Case $Button3 While 1 $dialg = FileOpenDialog("Choose include file", "C:\Program Files (x86)\AutoIt3\Include", "AutoIt Files (*.au3)") If @error = 1 Then ExitLoop EndIf $dialge = StringSplit($dialg, "\") $dialg1 = $dialge[5] FileOpen(@AppDataDir & "\command.au3", 2) FileWriteLine(@AppDataDir & "\command.au3", "#include <" & $dialg1 & ">") FileClose(@AppDataDir & "\command.au3") GUICtrlSetData($Label3, $dialg1) ExitLoop WEnd Case $Button1 $command = GUICtrlRead($Input1) $file = @AppDataDir & "\command.au3" FileOpen(@AppDataDir & "\command.au3", 1) FileWriteLine($file, $command) FileClose($file) GUICtrlSetData($Input1, "") GUICtrlSetData($Label3, "") ShellExecute($file) Sleep(1000) FileDelete(@AppDataDir & "\command.au3") Case $Button2 If FileExists("C:\Program Files (x86)\AutoIt3\AutoIt3.chm") Then ShellExecute("C:\Program Files (x86)\AutoIt3\AutoIt3.chm") Else ShellExecute("http://www.autoitscript.com/wiki/Function_list") EndIf EndSwitch WEnd

running a command upon opening the script is fine, but when a second command is entered a message pops up saying Error opening file.

 

How do I resolve this??

Thanks in advance


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>