Hey folks, I have a little problem with my script.
I have no experience with these things, and I know for sure that my code is not the best, but please be lenient, thanks 😅
The User should first choose 1 of the 2 Options to actually start the script. If 1 of the 2 Option is choosen then the User should click start again and all should work.
I have already commented the problem, If the button Start is clicked before, the User will select just 1 of the 2 option and the program will start (Without clicking start).How can I set $Start to $GUI_UNCHECKED? I have already tried to use GuiCtrlSetState, but didnt worked.
$Start = GuiCtrlCreateButton("Start", 20, 200, 90, 50,bitor($BS_CENTER,0,0)) GUICtrlSetOnEvent($Start,"Startallrun") Func Startallrun() If ((GUICtrlRead($Option1) = $GUI_UNCHECKED) And (GUICtrlRead($Option2) = $GUI_UNCHECKED)) Then MsgBox($MB_OK, "Error", "You have to select 1 Option") While (GUICtrlRead($Option1) = $GUI_UNCHECKED) Sleep(10) If (GUICtrlRead($Option1) = $GUI_CHECKED) Or (GUICtrlRead($Option2) = $GUI_CHECKED) Then GUICtrlSetState($Start,$GUI_UNCHECKED) ; This doesen't work for Buttons While (GUICtrlRead($Start) = $GUI_UNCHECKED) Sleep(10) If ($Start = $GUI_CHECKED) Then ; That's the problem. The script will start if I click one of the 2 options (because start was already checked before) ExitLoop EndIf WEnd ExitLoop EndIf WEnd Else If (GUICtrlRead($Option1) = $GUI_CHECKED) Then MsgBox($MB_OK, "Starting", "Start") Start() EndIf EndIf EndFunc
I am trying to create 10 labels, which all show a history of transactions, in order.
Problem is, it get's confused when I try to use [$i] to create different variables. How can I create different labels and thus variables with this?
For $i=1 to 10 Assign("PayH_" & $i, 20) ;Creates the variables for the values Global $PayHLabel_[$i] = GUICtrlCreateLabel($PayH_[$i], 30, 30) ;Creates the labels which show the values Next I know I can do this without a For Loop, but I am trying to learn how to keep my script short.
Thanks in advance.
I'm getting an error in this script:
Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) TrayTip("clears any tray tip","",0) AutoItSetOption("TrayIconDebug", 1) ;0-off #include "OSVersion.au3" Run('C:\Dnload\9xAddons\TestThis.exe') MsgBox("","Test","$ProgramFiles - " & $ProgramFiles & @CRLF & "_OSVersion() - " & _OSVersion()) Exit This is the error I am getting:
The variables should be defined in the #include "OSVersion.au3"
Func _OSVersion() Global $OSVersion Local $sWinVer = FileGetVersion('winver.exe') $OS_Version = @OSVersion $servicepack_version = StringReplace(@OSServicePack, "Service Pack ", "SP") If @error = -1 Then $servicepack_version = "" ConsoleWrite($OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '') & @CRLF) ConsoleWrite(@OSArch & @CRLF) If $OSVersion = 'Win7' Or $OSVersion = 'Win7SP1' Or $OSVersion = 'Win7X64' Or $OSVersion = 'Win7SP1x64' Then $ProgramFiles = "C:\Programs\" Else $ProgramFiles = "C:\Program Files\" EndIf Return $OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '') EndFunc ;==>_OSVersion What do I need to do to resolve the error?
Need a help with Autoit task, I am trying to copy an XML file and edit that XML file and copy it back
The script i have attached if the script we use to copy files to client from server, so basically what it does is
Going through a Set of IP address and
Map the drive Copy the file Write copy process was success Goes on a loop through IP's to check all machines have updated files #include <File.au3> #include <iNet.au3> #include <_XMLDomWrapper.au3> func latestUpdate($address, $name) Local $result Local $hFileIndexHTML DriveMapDel ( "G:" ) ConsoleWrite('Trying: ' & $address & "/" & $name & @CRLF); $result = DriveMapAdd ( "G:", "\\" & $address & "\C$", 0, $name & "\adminname","adminpswd") ;Copying the file from Mapped drive to local if $result = 1 Then FileCopy( "G:\Program Files\test.xml", "C:\sample\test.xml", 1); ConsoleWrite('Copying Updated File: ' & $address & @CRLF); $hFileIndexHTML = FileOpen("C:\sample\test.txt", 1) FileWrite($hFileIndexHTML, $address & @CRLF) FileClose($hFileIndexHTML) EndIf EndFunc func done($file, $address) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) if ( $address = $line ) Then ConsoleWrite('Already done: ' & $file & " " & $address & @CRLF); return true EndIf Next return false EndFunc func getMachineName($ipaddress) return _TCPIpToName($ipaddress) EndFunc func process($address) local $machineName $machineName = getMachineName($address) if ($machineName = "") Then ConsoleWrite("No machine found at:" & $address & @CRLF) Else ConsoleWrite("Machine found at:" & $address & " - " & $machineName & @CRLF) if ( done( "C:\sample\test.txt", $address) = false ) then if ( $machineName <> "" ) then latestUpdate($address, $machineName) else endif endif EndIf EndFunc TCPStartup() while 1=1 PROCESS("10.10.1.1") sleep( 1000 * 60 * 10) wend The XML file i am trying to copy is unique and different in all machines (Machine name,ID's etc), But whole structure is the same (ie, the num of lines ) [That's the reason i can't copy a single file to all the machines].
I was thinking of using _FileWriteToLine to replace 3 lines with new data
_FileWriteToLine("c:\sample\test.xml", 71, "<RIA>"http://goog.html"</RIA>", True)
_FileWriteToLine("c:\sample\test.xml", 350, "<col header="Status" width="7%" dataFld="status_code" style="" preprocesser="processES" template="" hidden="0"/>", True)
_FileWriteToLine("c:\sample\test.xml", 650, "<col header="Units" width="11%" dataFld="units" style="" preprocesser="" template="fU(units)" hidden="0"/>", True)
These lines inside XML
342-360 is similar as blah blah <col header="Status" width="7%" dataFld="status_code" style="" preprocesser="processES" template="" hidden="0"/>
same goes for 650th line also
I would like to get opinion of copying this file as this is a highly critical file needed to keep machines running
Do you think using _file write to line is risky?. Do you think i have to copy the file from parent folder to another folder after replacing the lines and then copy from there back to client system. This is all what i can think now, Any comments/suggestions will be much appreciated.