Jump to content

whitts

Active Members
  • Posts

    25
  • Joined

  • Last visited

whitts's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Is there any way to mask the input of a GUICTRLCREATEINPUT E.G. $Something = GUICtrlCreateInput("Enter something (mask ***.***.***) ", 208, 32, 185, 21) Only allowing numbers? thanks
  2. Removed
  3. On program exit how do i delete whats in memory, and/or clear out the arrays. Thanks
  4. I have posted my entire code below. Everythings working but i cant find away to integrate my radio buttons. I have two radio buttons: - $Radio1 = GUICtrlCreateRadio("Brother MFC8500", 120, 352, 113, 17) $Radio2 = GUICtrlCreateRadio("Brother MFC-8220", 8, 352, 113, 17) Basically when on of them is selected i want this part to be adjusted: - (brotherMFC-8220) so if brother 8500 is selected (by radio button) i want this to change to brother 8500 and if brother 8220 is selected (by radio button) i want it change to brother 8220. _ArrayAdd($Third,'rundll32 /s printui.dll, PrintUIEntry /if /q /b "' &GUICtrlRead($Display)& '" /f "c:\8220\Adduni.inf" /r "\\' &GUICtrlRead($IP) & '\' &GUICtrlRead($Share)& '" /m "Brother MFC-8220" w') CODE#include <GUIConstants.au3>#include <Array.au3> #include <File.au3> Global $SaveCnt = 1 Global $Saved[1] Global $Second[1] Global $Third[1] Global $fourth[1] Global $fourtha[1] Global $fourthb[1] Global $Fifth[1] $Local = GUICreate("Local Port Batch File Creator", 604, 425, 215, 182) GUISetBkColor(0xFF0000) $Label1 = GUICtrlCreateLabel("Scan Station's IP", 24, 8, 143, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) $IP = GUICtrlCreateInput("IP", 8, 32, 185, 21) $Label2 = GUICtrlCreateLabel("Share Name", 248, 8, 103, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) $Share = GUICtrlCreateInput("Share", 208, 32, 185, 21) $Label3 = GUICtrlCreateLabel("Printer's Display Name", 408, 8, 184, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) $Display = GUICtrlCreateInput("Display", 408, 32, 185, 21) $Add = GUICtrlCreateButton("Add Printer", 8, 384, 187, 33, 0) $Printers = GUICtrlCreateEdit("", 8, 72, 185, 265) GUICtrlSetData(-1, "sData") $Create = GUICtrlCreateButton("Create Batch File", 208, 384, 187, 33, 0) $Radio1 = GUICtrlCreateRadio("Brother MFC8500", 120, 352, 113, 17) $Radio2 = GUICtrlCreateRadio("Brother MFC-8220", 8, 352, 113, 17) $netuse = GUICtrlCreateButton("Create Net Use", 408, 384, 185, 33) $Edit1 = GUICtrlCreateEdit("", 208, 72, 185, 265) GUICtrlSetData(-1, "Edit1") $Edit2 = GUICtrlCreateEdit("", 408, 72, 185, 265) GUICtrlSetData(-1, "Edit2") GUISetState(@SW_SHOW) _ArrayAdd($Saved,'ECHO.^<package^>>"yes.wsf"') _ArrayAdd($Saved, 'ECHO.>>"yes.wsf"') _ArrayAdd($Saved, '') _ArrayAdd($Saved, 'ECHO.^<job id="vbs"^>>>"yes.wsf"') _ArrayAdd($Saved, 'ECHO.>>"yes.wsf"') _ArrayAdd($Saved, 'ECHO. ^<script language="VBScript"^>>>"yes.wsf"') _ArrayAdd($Saved, 'ECHO.set WshShell = WScript.CreateObject("WScript.Shell")>>"yes.wsf"') _ArrayAdd($Saved, 'ECHO.WScript.Sleep 3000>>"yes.wsf"') _ArrayAdd($Saved, 'ECHO.WshShell.SendKeys "Y">>"yes.wsf"') _ArrayAdd($Saved, 'ECHO.^</script^>>>"yes.wsf"') _ArrayAdd($Saved, 'ECHO.^</job^>>>"yes.wsf"') _ArrayAdd($Saved, 'ECHO.^</package^>>>"yes.wsf"') _ArrayAdd($Saved, '') _ArrayAdd($Saved, 'ECHO.Windows Registry Editor Version 5.00>"printer.reg"') _ArrayAdd($Saved, 'ECHO.>>"printer.reg"') _ArrayAdd($Saved, '') _ArrayAdd($Second,'regedit /S printer.reg') _ArrayAdd($Second,'') _ArrayAdd($Second,'net stop spooler') _ArrayAdd($Second,'net start spooler') While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Add _ArrayAdd($fourth,GUICtrlRead($IP)) $sData = _ArrayToString($fourth, @CRLF) GuiCtrlSetData($Printers, $sData) _ArrayAdd($fourtha,GUICtrlRead($Share)) $sData = _ArrayToString($fourtha, @CRLF) GuiCtrlSetData($Edit1, $sData) _ArrayAdd($fourthb,GUICtrlRead($Display)) $sData = _ArrayToString($fourthb, @CRLF) GuiCtrlSetData($Edit2, $sData) _ArrayAdd($Saved,'ECHO.[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports]>>"printer.reg"') _ArrayAdd($Saved,'ECHO."\\\\' &GUICtrlRead($IP) & "\\" &GUICtrlRead($Share)& '"="">"printer.reg">>"printer.reg"') _ArrayAdd($Saved, '') _ArrayAdd($Third,'start wscript yes.wsf') _ArrayAdd($Third,'') _ArrayAdd($Third,'rundll32 /s printui.dll, PrintUIEntry /if /q /b "' &GUICtrlRead($Display)& '" /f "c:\8220\Adduni.inf" /r "\\' &GUICtrlRead($IP) & '\' &GUICtrlRead($Share)& '" /m "Brother MFC-8220" w') _ArrayAdd($Third,'') _ArrayAdd($Fifth,'net use \\' &GUICtrlRead($IP) & "\" &GUICtrlRead($Share)& ' /user: GUICtrlSetData($IP,"") GUICtrlSetData($Share,"") GUICtrlSetData($Display,"") $array4 = ArrayMerge($Saved, $Second) $array4 = ArrayMerge($array4, $Third) Func ArrayMerge($amSaved, $amSecond) Local $tempArray = $amSaved Local $amElements = Ubound($tempArray) + Ubound($amSecond) Redim $tempArray[$amElements] Local $amCount = 0 For $X = Ubound($amSaved) to $amElements - 1 $tempArray[$X] = $amSecond[$amCount] $amCount += 1 Next Return $tempArray EndFunc Case $Create _ArrayAdd($array4,'del yes.wsf') _ArrayAdd($array4,'del printer.reg') _FileWriteFromArray("localport.bat",$array4) Case $netuse _FileWriteFromArray("printer.bat",$fifth) EndSwitch WEnd
  5. Works perfectly thanks
  6. How do i display an array to an edit window using _ArrayDisplay This is where i want to show it $Printers = GUICtrlCreateEdit("", 8, 144, 585, 137)
  7. Thanks weaponx, that code works a treat
  8. Ok say i have 3 arrays $array1 $array2 $array3 How could i add $array2 to the end of array $array1 and then add $array3 to the end of $array1 (which would at this point would contain $array2) Thanks
  9. How do i open it back up in append mode? Thanks
  10. Blue_Drache your solution works in the correct order for me but only allows one press of the save button. PsaltyDS works but seems to put things in the array in strange places... Thanks to you both for your input..
  11. I was wondering if we can write to a file from more than one array at the same time. e.g. I dont want to do it seperately because the second will over write the first. _FileWriteFromArray("MyFile.txt",$Saved &$Second)
  12. Below i have 3 cases in a row all are the same (when i press the save button) I want to exicute the first one until everything is added in the array and then move to the second until everyting in the array is added then to the third. At the moment the program is excuting the first thing in the array for the first case then the first thing in the array for the seocnd an dthen the third and then starts again with the second thing in the array. Anyone any ideas? Thanks CODE#include <GUIConstants.au3> #include <Array.au3> #include <File.au3> Global $Saved[1];This will be an array of 2 elements, but _ArrayAdd will take care of ;making it bigger as you add data. GUICreate("", 273, 192, 217, 152) $Input1 = GUICtrlCreateInput("Input1", 12, 14, 245, 21) $Input2 = GUICtrlCreateInput("Input2", 12, 47, 245, 21) $Input3 = GUICtrlCreateInput("Input3", 12, 80, 245, 21) $Save = GUICtrlCreateButton("Save to memory", 22, 130, 105, 45, $BS_DEFPUSHBUTTON) $Write = GUICtrlCreateButton("Write to file", 142, 130, 105, 45, 0) GUISetState(@SW_SHOW) _ArrayAdd($Saved,'ECHO.^<package^>>"yes.wsf"') _ArrayAdd($Saved, 'ECHO.>>"yes.wsf"') _ArrayAdd($Saved, '') _ArrayAdd($Saved, 'ECHO.^<job id="vbs"^>>>"yes.wsf"') _ArrayAdd($Saved, 'ECHO.>>"yes.wsf"') _ArrayAdd($Saved, 'ECHO. ^<script language="VBScript"^>>>"yes.wsf"') _ArrayAdd($Saved, 'ECHO.set WshShell = WScript.CreateObject("WScript.Shell")>>"yes.wsf"') _ArrayAdd($Saved, 'ECHO.WScript.Sleep 3000>>"yes.wsf"') _ArrayAdd($Saved, 'ECHO.WshShell.SendKeys "Y">>"yes.wsf"') _ArrayAdd($Saved, 'ECHO.^</script^>>>"yes.wsf"') _ArrayAdd($Saved, 'ECHO.^</job^>>>"yes.wsf"') _ArrayAdd($Saved, 'ECHO.^</package^>>>"yes.wsf"') _ArrayAdd($Saved, '') _ArrayAdd($Saved, 'ECHO.Windows Registry Editor Version 5.00>"printer.reg"') _ArrayAdd($Saved, 'ECHO.>>"printer.reg"') _ArrayAdd($Saved, '') While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Save _ArrayAdd($Saved,'ECHO.[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports]>>"printer.reg"') _ArrayAdd($Saved,'ECHO."\\\\' &GUICtrlRead($Input1) & "\\" &GUICtrlRead($Input2)& '"="">"printer.reg">>"printer.reg"') _ArrayAdd($Saved, '') GUICtrlSetData($Input1,"") GUICtrlSetData($Input2,"") GUICtrlSetData($Input3,"") Case $Save _ArrayAdd($Saved, 'regedit /S printer.reg') _ArrayAdd($Saved, '') _ArrayAdd($Saved, 'net stop spooler') _ArrayAdd($Saved, 'net start spooler') Case $Save _ArrayAdd($Saved,'start wscript yes.wsf') _ArrayAdd($Saved,'') _ArrayAdd($Saved, 'rundll32 /s printui.dll, PrintUIEntry /if /q /b "' &GUICtrlRead($Input2)& '" /f "c:\8220\Adduni.inf" /r "\\' &GUICtrlRead($Input1) & '\' &GUICtrlRead($Input2)& '" /m "Brother MFC-8220" w') _ArrayAdd($Saved,'') GUICtrlSetData($Input1,"") GUICtrlSetData($Input2,"") GUICtrlSetData($Input3,"") Case $Write ;~ _ArrayDisplay($Saved) _FileWriteFromArray("MyFile.txt",$Saved) EndSwitch WEnd
  13. Das Ami here is my code... CODE#include <GUIConstants.au3> #include <Array.au3> #include <File.au3> Global $Saved[1];This will be an array of 2 elements, but _ArrayAdd will take care of ;making it bigger as you add data. GUICreate("", 273, 192, 217, 152) $Input1 = GUICtrlCreateInput("Input1", 12, 14, 245, 21) $Input2 = GUICtrlCreateInput("Input2", 12, 47, 245, 21) $Input3 = GUICtrlCreateInput("Input3", 12, 80, 245, 21) $Save = GUICtrlCreateButton("Save to memory", 22, 130, 105, 45, $BS_DEFPUSHBUTTON) $Write = GUICtrlCreateButton("Write to file", 142, 130, 105, 45, 0) GUISetState(@SW_SHOW) #include <File.au3> If Not _FileCreate("myfile.txt") Then MsgBox(4096,"Error", " Error Creating/Resetting log. error:" & @error) EndIf $file = FileOpen("myfile.txt", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWriteLine($file, 'ECHO.^<package^>>"yes.wsf"') FileWriteLine($file, 'ECHO.>>"yes.wsf"') FileWriteLine($file, '') FileWriteLine($file, 'ECHO.^<job id="vbs"^>>>"yes.wsf"') FileWriteLine($file, 'ECHO.>>"yes.wsf"') FileWriteLine($file, 'ECHO. ^<script language="VBScript"^>>>"yes.wsf"') FileWriteLine($file, 'ECHO.set WshShell = WScript.CreateObject("WScript.Shell")>>"yes.wsf"') FileWriteLine($file, 'ECHO.WScript.Sleep 3000>>"yes.wsf"') FileWriteLine($file, 'ECHO.WshShell.SendKeys "Y">>"yes.wsf"') FileWriteLine($file, 'ECHO.^</script^>>>"yes.wsf"') FileWriteLine($file, 'ECHO.^</job^>>>"yes.wsf"') FileWriteLine($file, 'ECHO.^</package^>>>"yes.wsf"') FileWriteLine($file, '') FileWriteLine($file, 'ECHO.Windows Registry Editor Version 5.00>"printer.reg"') FileWriteLine($file, 'ECHO.>>"printer.reg"') FileWriteLine($file, '') FileClose($file) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Save _ArrayAdd($Saved,'ECHO.[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports]>>"printer.reg"') _ArrayAdd($Saved,'ECHO."\\\\' &GUICtrlRead($Input1) & "\\" &GUICtrlRead($Input2)& '"="">"printer.reg">>"printer.reg"') GUICtrlSetData($Input1,"") GUICtrlSetData($Input2,"") GUICtrlSetData($Input3,"") Case $Write ;~ _ArrayDisplay($Saved) _FileWriteFromArray("MyFile.txt",$Saved) EndSwitch WEnd Thanks BsaltyDS i will take a look at that
  14. I just tried it the way you told me to - whee am i going wrong... Heres my code CODEWhile 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Save _ArrayAdd($Saved,'ECHO.[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports]>>"printer.reg"') _ArrayAdd($Saved,'ECHO."\\\\' &GUICtrlRead($Input1) & "\\" &GUICtrlRead($Input2)& '"="">"printer.reg">>"printer.reg"') GUICtrlSetData($Input1,"") GUICtrlSetData($Input2,"") GUICtrlSetData($Input3,"") Case $Write For $i=1 to $Saved[0] FileWriteLine ("myfile.txt", $Saved[$i]) Next EndSwitch WEnd
  15. How do i get _FileWriteFromArray("MyFile.txt",$Saved) To append the text to the end of an already created file. The file myfile.txt already has text in it and i dont want that overwritten i just want the text in the array to be written after the original text.. Thanks
×
×
  • Create New...