
Ambient
Active Members-
Posts
37 -
Joined
-
Last visited
Everything posted by Ambient
-
ListView Change text Colour not working for me
Ambient posted a topic in AutoIt GUI Help and Support
I have tried several way sto get this to work to no avail. Any help would be appreciated. #include <ListViewConstants.au3> #include <GuiListView.au3> #include "GuiListViewEx.au3" $idItem = GUICtrlCreateListViewItem($r & " | " & $c & $adoRs.Fields("TransactionAmount").value & " | " & $Timestamp & " | " & _StringProper($adoRs.Fields("Tillid").value) & @CRLF & @CRLF & "Card Number : " & $cardnum & " " , $idListView) ConsoleWrite( "IDITEM" & $idItem) If STRINGLEFT($adoRs.Fields("TransactionAmount").value,1)= "-" Then Consolewrite(" String is Negative" & @CRLF) ;Drops in Here as expected ;GUICtrlSetColor(-1, $COLOR_RED) ; Colour line if item is negative this didn' work $TxC= _GUICtrlListView_SetTextColor($hListView, $CLR_RED) ; I also tried $TxC= _GUICtrlListView_SetTextColor(-1, 0xFF0000) CONSOLEWRITE("TEXTCOLOUR RETURNED " & $TxC & @crlf) ; This is returning True ELSE Consolewrite(" String is NOT Negative" & @CRLF) EndIf -
Apologies Guys!
-
I am trying to build a list from a query run against a sybase db. This part works fine. My problem is this, I want to display values in a list depending on the value of certain fields i.e. See below which works for two. Unfortunately, I need it to work for 3 values. I don't know how I can do this for 3. I did try doing a select case but I was getting errors. i.e. if value =0 then "Card Check" if Value = - Then "Card Spend" Else "Money Added" The below immediate iif works brilliantly for two but as I say I need to build this with 3 different values. $idItem = GUICtrlCreateListViewItem( _iif($adoRs.Fields("TransactionAmount").value =0, "Card check","Money Added") Any help appreciated.
-
Error When running complied Script
Ambient replied to Ambient's topic in AutoIt General Help and Support
Hi Jos . I will try what you have suggested .Thank's again for you help. I'm just a little tired at this stage. -
Error When running complied Script
Ambient replied to Ambient's topic in AutoIt General Help and Support
Yes! I want to Exit if none of the three file masks exists! -
Error When running complied Script
Ambient replied to Ambient's topic in AutoIt General Help and Support
Apologies! Yes, that is meant to be a question. I want to copy files to a server and also locally. *.pdf,*.xls and *.csv from the scripts directory. When I Test this on my machine it works absolutely fine. When I test with the same exe on the machine I need it for it drops out even though the scripts directory has loads of .xls files. -
Error When running complied Script
Ambient replied to Ambient's topic in AutoIt General Help and Support
Okay! When I run this in my machine it works absolutely fine does all that I need it too. When I compile and run at remote machine it drops out at the below even though there are about 10 or 12 xls file in the script directory are there known issues with FileExists. Thanks, Jlogan3013 and Jos. If Not FileExists(@ScriptDir & "\*" & $sext) Or Not FileExists(@ScriptDir & "\*" & $sext1) Or Not FileExists(@ScriptDir & "\*" & $sext2) Then ;_FileWriteLog($logfilepath, @ScriptDir & "\*" & $sext & "Or Not FileExists(@ScriptDir & "\*" & $sext1) Or Not FileExists(@ScriptDir & "\*" & $sext2) _FileWriteLog($logfilepath, " N.B. NO " & $sext & " OR" & $sext1 & " OR" & $sext & " FILES EXIST FOR COPYING AT THIS TIME!") _FileWriteLog($logfilepath, "#######################################################################################################") Exit -
Error When running complied Script
Ambient replied to Ambient's topic in AutoIt General Help and Support
Thanks Guys how'd I miss that I will test and let you know. Thanks anway. -
Error When running complied Script
Ambient replied to Ambient's topic in AutoIt General Help and Support
Running full SciTE Version 3.6.6 -
Error When running complied Script
Ambient replied to Ambient's topic in AutoIt General Help and Support
#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=..\..\..\Users\Support6\Downloads\Hopstarter-Sleek-Xp-Basic-Document.ico #AutoIt3Wrapper_outfile=ReportsCopy.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <File.au3> #include <Misc.au3> #include <date.au3> #include <Constants.au3> Global $logfilepath = IniRead(@ScriptDir & "\Reports.ini", "LOG", "logpath", @ScriptDir & "\Reportscopy.log") ;Path to the logfile default script directory Global $FileCount, $fl Dim $FileCount = 0 $Today = @MDAY & "_" & @MON & "_" & @YEAR $datetime = @MDAY & "_" & @MON & "_" & @YEAR & "_" & "_" & @HOUR & @MIN & @SEC $g_szVersion = "Reportscopier" $ilogsize = IniRead(@ScriptDir & "\Reports.ini", "Log", "logsize", "10") ; Size to keep log in mmegabytes $Serverip = IniRead(@ScriptDir & "\Reports.ini", "SERVER", "ip", "192.168.1.10") ;Path to the server ipaddress $Drive = IniRead(@ScriptDir & "\Reports.ini", "SERVER", "Drive", "J") ; Drive letter to map $servershare = IniRead(@ScriptDir & "\Reports.ini", "SERVER", "ServerShare", "Users") ; Sharename to map to i.e $FromPath = IniRead(@ScriptDir & "\Reports.ini", "COPY", "From", "C:\temp\Reports") $serveruser = IniRead(@ScriptDir & "\Reports.ini", "Server", "user", "*****") $serverpassword = IniRead(@ScriptDir & "\Reports.ini", "Server", "password", "*****") $loc = IniRead(@ScriptDir & "\Reports.ini", "Server", "location", "0001") $sext = IniRead(@ScriptDir & "\Reports.ini", "Copy", "ext", ".xls") $sext1 = IniRead(@ScriptDir & "\Reports.ini", "Copy", "ext1", ".pdf") $sext2 = IniRead(@ScriptDir & "\Reports.ini", "Copy", "ext2", ".csv") $zip = IniRead(@ScriptDir & "\Reports.ini", "TILL", "7zip", "0") $rmlogbk = 0 $rmdbbk = 0 Dim $answer = "RM6000_DSN", $Round Dim $tblname1 = "Client" $day = _DateDayOfWeek(@WDAY) $sPID = "RepProcess.exe" Dim $Dbservice = "" Dim $i Opt("TrayMenuMode", 1) ; stops script from being paused ;################################################################ ; ; CHECK FIRST TO SEE IF THERE ARE REPORT FILES TO COPY IF NOT EXIT ; ;############################################################### $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") If Not FileExists(@ScriptDir & "\*" & $sext) Or Not FileExists(@ScriptDir & "\*" & $sext1) Or Not FileExists(@ScriptDir & "\*" & $sext2) Then _FileWriteLog($logfilepath, @ScriptDir & "\*" & $sext) Or Not FileExists(@ScriptDir & "\*" & $sext1) Or Not FileExists(@ScriptDir & "\*" & $sext2) _FileWriteLog($logfilepath, " N.B. NO " & $sext & " OR" & $sext1 & " OR" & $sext & " FILES EXIST FOR COPYING AT THIS TIME!") _FileWriteLog($logfilepath, "#######################################################################################################") Exit Else ; Lets check to see if any of the processes have hung then and write to the log. If ProcessExists("reprocessor.exe") Then ; This shouldn't exist at the time we are running or copying reports $timer = TimerInit() While ProcessExists($sPID) Sleep(1000) If TimerDiff($timer) > 10 * 60 * 1000 Then ; still there after 5 mins close it. _ProcessCloseEx($sPID) EndIf WEnd EndIf ;Exit EndIf If _Singleton($g_szVersion, 1) = 0 Then ; We know the script is already running. Let the user know. ;_FileWriteLog($logfilepath, @UserName & " tried to run another instance of the software version " & $g_szVersion) MsgBox(0, $g_szVersion, $g_szVersion & " is running. Using multiple copies of " & $g_szVersion & " at the same time breaks the [(Opus Solutions)] License!") Exit EndIf $MegaByte = ('1048576') _FileSize_In_MegaBytes($logfilepath) ;$isize_bytes = FileGetSize($logfilepath) ;$isize_megas = $isize_bytes / 1048576 If $Round >= $ilogsize Then ;MsgBox(4096, "Result", $Round) If FileDelete($logfilepath) = 1 Then ;sleep(3000) ConsoleWrite("-> Deleted file: " & $logfilepath & @LF) _FileWriteLog($logfilepath, "Deleted old log as it was " & $Round & "Mb in size.") Else _FileWriteLog($logfilepath, "Failed to delete " & $logfilepath & "file may be current") EndIf _FileWriteLog($logfilepath, "File is now current so leaving until it is " & $ilogsize & "Mb in size.") EndIf $query1 = "SELECT clientname FROM " & $tblname1 & " where clientType='L' and clientnumber=" & $loc ;~ case _GetIP() = "93.107.102.59" ; RUN THE SELECT QUERY TO GET THE CLIENT NAME $adoCon = ObjCreate("ADODB.Connection") $val = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Sybase\SQL Anywhere\11.0", "LOCATION") If FileExists($val & "\Bin32\dbeng11.exe") Then ;it's sybase 11 $adoCon.Open("Driver={SYBASE SYSTEM 11};" & "Data source= " & $answer & " ;UID=dba;PWD=sql") ;$adoCon.Open ("Provider=ASAProv.11;" & "Data source= " & $ANSWER & " ;UID=dba;PWD=sql") Else $adoCon.Open("Provider=ASAProv.90;" & "Data source= " & $answer & " ;UID=dba;PWD=sql") EndIf ;Sybase 16 "Provider=SAOLEDB;DSN=SQL Anywhere 16 Demo" $adoRs = ObjCreate("ADODB.Recordset") $adoRs.CursorType = 1 $adoRs.LockType = 3 $adoRs.Open($query1, $adoCon) If $adoRs.BOF And $adoRs.EOF Then ; Empty Record $Count = 0 Else Do $Storename = $adoRs.Fields("clientname" ).value $adoRs.MoveNext Until $adoRs.EOF $adoCon.Close EndIf ;ConsoleWrite( _GetDOSOutput("ping 192.168.0.70") & @CRLF) ;$logfilepath = @scriptdir & "reports.log" $Ip2ping = $Serverip ; ;Ping the server ip in here if the server is dead then Tooltip and run Posxpress3 For $n = 1 To 3 $Rs = Ping($Ip2ping, 1000) If @error = 0 Then ;ToolTip("Ping " & $n & " of 5",10,10, "Response","Response from " & $ip2ping & " in "& $rs & " ms" ,1) ;ToolTip("Response from " & $ip2ping & " in "& $rs & " ms" ,10,10,"Ping " & $n & " of 3", "Response",1) ;_FileWriteLog($logfilepath, "Response from " & $ip2ping & " in "& $rs & " ms") ;Sleep(1000) ;ToolTip("") ElseIf @error = 1 Then ToolTip($Ip2ping & " is offline please check patch cable" & @CRLF & "Are you sure the server is switched on?", 10, 10, "Ping " & $n & " of 3", "Response", 1) _FileWriteLog($logfilepath, $Ip2ping & " is offline please check patch cable" & @CRLF & "Ensure the server is switched on?") ; Cannot Map Drive Run posxpress with the database thats there! Sleep(500) ToolTip("") If $n = 3 Then _FileWriteLog($logfilepath, $Ip2ping & " is offline please check patch cable") _FileWriteLog($logfilepath, " N.B. NO COPY HAS TAKEN PLACE TODAY! ") ;_runposxpress(1) EndIf ;Msgbox(0,"Ping " & $n & " of 5", $ip2ping & " is offline please check cable",3) ElseIf @error = 2 Then ToolTip($Ip2ping & " is unreachable please check patch cable " & @CRLF & "Are you sure the server is switched on?", 10, 10, "Ping " & $n & " of 3", "Response", 1) _FileWriteLog($logfilepath, $Ip2ping & " is unreachable please check patch cable " & @CRLF & "Ensure sure the server is switched on?") Sleep(500) ToolTip("") If $n = 3 Then _FileWriteLog($logfilepath, $Ip2ping & " is unreachable please check patch cable ") _FileWriteLog($logfilepath, " N.B. NO REPORTS COPIED TODAY! ") ;_runposxpress(1) EndIf ;Msgbox(0,"Ping " & $n & " of 5", $ip2ping & " is unreachable check cable",3) ElseIf @error = 3 Then ToolTip($Ip2ping & " is a bad destination " & @CRLF & "Are you sure the server is switched on?", 10, 10, "Ping " & $n & " of 3", "Response", 1) _FileWriteLog($logfilepath, $Ip2ping & " address is a bad destination " & @CRLF & "Are you sure the server is switched on?") Sleep(500) ToolTip("") If $n = 3 Then ; Cannot Map Drive Run posxpress with the database that there! _FileWriteLog($logfilepath, $Ip2ping & " is a bad destination cannot map drive, running Posxpress with Current data only") _FileWriteLog($logfilepath, " N.B. NO TILL UPDATE HAS TAKEN PLACE TODAY! ") ;_runposxpress(1) EndIf ;Msgbox(0,"Ping " & $n & " of 5", $ip2ping & " is a bad destination",3) Else ToolTip($Ip2ping & "Unknown error encountered" & @CRLF & "Are you sure the server is switched on?", 10, 10, "Ping " & $n & " of 3", "Response", 1) _FileWriteLog($logfilepath, $Ip2ping & "An unknown error encountered" & @CRLF & "Are you sure the server is switched on?") Sleep(500) ToolTip("") If $n = 3 Then ; Cannot Map Drive Run posxpress with the database that there! _FileWriteLog($logfilepath, $Ip2ping & " an unknown error occurred running Posxpress with Current data only") _FileWriteLog($logfilepath, " N.B. NO COPY HAS TAKEN PLACE TODAY! ") ;_runposxpress(1) EndIf ;Msgbox(0,"Ping " & $n & " of 5", "Unknown error encountered",3) EndIf $i = $Rs + $i Next ;ToolTip("Results",10,10,"Average roundtrip time: " & $i / 5 & " ms", "Response",1) _FileWriteLog($logfilepath, _Iif($i / 5 > 0, " Server " & $Serverip & " is contactable Average roundtrip time from 3 pings :" & $i / 5 & " ms", " Server " & $Serverip & " UNREACHABLE Average roundtrip time from 3 pings:" & $i / 5 & " ms")) ; Lets make a folder locally first. ; If it does exist create it we'll call it Storename_reports and crate in root of C: $local = "C:\" & $Storename & "_Reports" If DirGetSize($local) = -1 Then _FileWriteLog($logfilepath, " Creating Folder C:\" & $Storename & "_Reports As None Exists") ;MsgBox(48, "My Message", "Directory does not exists!") Else DirCreate("C:\" & $Storename & "_Reports") EndIf ; Now lets Copy the files from the From Directory into this directory _FileWriteLog($logfilepath, "LOCAL COPY FROM : " & $FromPath) If DirGetSize($local & "\" & _DateDayOfWeek(@WDAY) & $Today) = -1 Then $Cr = DirCreate($local & "\" & _DateDayOfWeek(@WDAY) & $Today) ; Create it If $Cr = 1 Then _FileWriteLog($logfilepath, "SUCCESS CREATING LOCAL FOLDER " & $local & _DateDayOfWeek(@WDAY) & $Today) Else _FileWriteLog($logfilepath, "Could Not Create Local Folder " & @CRLF & $local & "\" & _DateDayOfWeek(@WDAY) & $Today) EndIf Else If DirGetSize($local & "\" & _DateDayOfWeek(@WDAY) & $Today) <> -1 Then _FileWriteLog($logfilepath, "Directory:" & @CRLF & $local & "\" & _DateDayOfWeek(@WDAY) & $Today & " Already Exists") EndIf ;~ EndIf ;_FileWriteLog($logfilepath, "Folder Scan Complete. There were " & $FileCount & " Files in Folder on this run." & @CRLF & "Next Run" ) $fl = ScanFolder($FromPath, "Local") ; SCAN THE REPORTS FOLDER AT LOCAL STORE CHECK FOR FILES THAT ARE ELIGIBLE FOR COPYING _FileWriteLog($logfilepath, "Folder Scan Complete. There were " & _Iif($FileCount = 0, "There Were No files to copy today.", " There were " & $FileCount & " Files copied Locally on this run.")) EndIf ; This is used for mapping the drive ;Server Copy Stuff below here. $cmd = "net use " & $Drive & " \\" & $Serverip & "\" & $servershare & " " & $serverpassword & " /user:" & $serveruser & " /PERSISTENT:NO" ;Check First to see if there is a drive Mapped, if so delete it DriveMapDel($Drive) $Dr = DriveMapGet($Drive) If $Dr = "" Then $String = $Drive & "\\" & $Serverip & "\" & $servershare & " 0" & $serveruser & $serverpassword _FileWriteLog($logfilepath, " NO " & $Drive & " DRIVE EXISTS. START MAPPING DRIVE : " & $Drive & "\\" & $Serverip & "\" & $servershare) ;_FileWriteLog($logfilepath, "net use " & $Drive & " \\" & $Serverip & "\" & $servershare & " " & $serverpassword & " /user:" & $serveruser & " /PERSISTENT:NO") ;ConsoleWrite("net use " & $Drive & " \\" & $Serverip & "\" & $servershare & " " & $serverpassword & " /user:" & $serveruser & " /PERSISTENT:NO" & @CRLF) Do ;Local $iRc= _Rundos("net use " & $Drive & " \\" & $Serverip & "\" & $servershare & " " & $serverpassword & " /user:" & $serveruser & " /PERSISTENT:NO") Local $iRc = _FileWriteLog($logfilepath, _GetDosoutput($cmd)) ;_FileWriteLog($logfilepath, "$IRC = " & $iRc ) Until $iRc > 0 Sleep(500) ;Msgbox(0,"Ping " & $n & " of 5","Response from " & "net use " & $Drive & " \\" & $Serverip & "\" & $servershare & " " & $serverpassword & " /user:" & $serveruser & " /PERSISTENT:NO " & " in "& $rs & " ms") ; $RT=DriveMapAdd($Drive, "\\" & $Serverip & "\"& $servershare, 0, $serveruser, $serverpassword) _FileWriteLog($logfilepath, "CHECKING DRIVE: " & $Drive) If DriveStatus($Drive) = "READY" Then _FileWriteLog($logfilepath, ";-)" & "DRIVE MAPPED SUCCESSFULLY! " & $Drive & "\ DRIVE MAPPED OKAY.....") Sleep(1000) ;ToolTip("Drive Mapped Successful!",10,10, $Drive &"\ drive mapped....." ,"Drive Mapping",1) ToolTip("DRIVE MAPPED SUCCESSFULLY!", 10, 10, $Drive & "\ DRIVE MAPPED.....", "Drive Mapping", 1) _FileWriteLog($logfilepath, ";-) HAPPY DAYS DRIVE MAPPED OK...HUSTON GOOD TO GO") ; ConsoleWrite("Drive Mapped Whoop.") Sleep(1000) ToolTip("") Else ToolTip("DRIVE MAPPING FAILED.", 10, 10, $Drive & "WASN'T MAPPED MAPPED IT MAY ALREADY EXIST OR NO SHARE EXISTS.....", 1) Sleep(1000) ToolTip("") EndIf ;_FileWriteLog($logfilepath, ";-) HAPPY DAYS DRIVE MAPPED OK...HUSTON GOOD TO GO") ;ConsoleWrite("before from path " & $FromPath) If DriveStatus($Drive) = "READY" Then _FileWriteLog($logfilepath, "DRIVE STILL EXISTS. " & $Drive) Else _FileWriteLog($logfilepath, "MAPPING APPEARS TO HAVE DROPPED TO : " & $Drive) EndIf If FileExists($FromPath) Then ;If there is a rpt Folder. _FileWriteLog($logfilepath, "COPYING FROM : " & $FromPath) ;~ If Not FileExists($Drive & "\" & $Storename & "\" & _DateDayOfWeek( @WDAY ) & $today) Then ; IF THERE IS NO REPORT FOLDER WITH DAY DATE NAME ON SERVER CREATE ONE ;~ _FileWriteLog($logfilepath, "NO FOLDER FOR TODAYS DATE " & $Storename & _DateDayOfWeek( @WDAY ) & $today & " SO CREATING ONE.") If DirGetSize($Drive & "\" & $Storename & "\" & _DateDayOfWeek(@WDAY) & $Today) = -1 Then $Cr = DirCreate($Drive & "\" & $Storename & "\" & _DateDayOfWeek(@WDAY) & $Today) ; Create it If $Cr = 1 Then _FileWriteLog($logfilepath, "SUCCESS CREATING FOLDER " & _DateDayOfWeek(@WDAY) & $Today) Else _FileWriteLog($logfilepath, "Creating Server Folder failed. Could Not Create Folder 1:" & @CRLF & $Drive & "\" & $Storename & "\" & _DateDayOfWeek(@WDAY) & $Today) EndIf Else If DirGetSize($Drive & "\" & $Storename & "\" & _DateDayOfWeek(@WDAY) & $Today) <> -1 Then _FileWriteLog($logfilepath, "Directory:" & @CRLF & $Drive & "\" & $Storename & "\" & _DateDayOfWeek(@WDAY) & $Today & " Already Exists") EndIf ;~ EndIf ;_FileWriteLog($logfilepath, "Folder Scan Complete. There were " & $FileCount & " Files in Folder on this run." & @CRLF & "Next Run" ) $fl = ScanFolder($FromPath, "Server") ; SCAN THE REPORTS FOLDER AT LOCAL CHECK FOR FILES THAT ARE ELIGIBLE FOR COPYING LOCALLY _FileWriteLog($logfilepath, "Folder Scan Complete. There were " & _Iif($FileCount = 0, "There Were No files to copy today.", " There were " & $FileCount & " Files copied from Folder on this run." & @CRLF & "NEXT COPY RUN BELOW.")) _FileWriteLog($logfilepath, "#######################################################################################################") ;DriveMapDel($Drive) ; exit EndIf Else ;DriveMapDel($Drive) ;"Deleteing Mapped drive OK Already Exists " _FileWriteLog($logfilepath, "RE-MAPPING DRIVE : " & $Drive) ; MAY BE WORTH DOING A NETUSE HERE AS DRIVEMAPADD DOESN'T SEEM TO WORK IN WINDOWS 7 Do Local $iRc = _FileWriteLog($logfilepath, _GetDosoutput($cmd)) ;_FileWriteLog($logfilepath, "$IRC = " & $iRc ) Until $iRc > 0 Sleep(500) ;~ Local $iRc= _Rundos("net use " & $Drive & " \\" & $Serverip & "\" & $servershare & " " & $serverpassword & " /user:" & $serveruser & " /PERSISTENT:NO") ;~ _FileWriteLog($logfilepath, "Second $IRC value = " & $iRc ) ;~ Until $iRc > 0 ; ConsoleWrite($Drive & "\\" & $Serverip & "\" & $servershare & $serveruser & $serverpassword & @CRLF) If DriveStatus($Drive) = "READY" Then ; ToolTip("Drive Mapped Successful!", 10, 10, $Drive & "\ drive mapped.....", "Drive Mapping", 1) _FileWriteLog($logfilepath, ";-) HAPPY DAYS DRIVE MAPPED OK...HUSTON GOOD TO GO") Sleep(500) ToolTip("") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Drive mapped to share create a location folder for reports then copyin DAy numbers and delete temp files at store ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; If Not FileExists($Drive & $Storename) Then If Not DirCreate($Drive & $Storename) Then _FileWriteLog($logfilepath, ";-(" & "FAILED TO CREATE FOLDER " & $Drive & "\ " & $Storename & "On Server.") ;MsgBox(8240, 'Directory Creation Failed', 'Could Not Create Folder:' & @CRLF & $Drive & $Storename) EndIf Sleep(500) Else _FileWriteLog($logfilepath, "Directory " & $Storename & " created.") ;ConsoleWrite("Directory " & $Storename & " created or exists." & @CRLF & @CRLF) EndIf ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copy Reports to the appropriate folder then delete from local drive ;msgbox(0,"Mapped drive","Huston we don't have a problem") ;ConsoleWrite("before from path " & $FromPath) If FileExists($FromPath) Then ;If there is a rpt Folder. _FileWriteLog($logfilepath, "Copying from path " & $FromPath) If Not FileExists($Drive & "\" & $Storename & "\" & _DateDayOfWeek(@WDAY) & $Today) Then ; IF THERE IS NO REPORT FOLDER CREATE ONE ON SERVER _FileWriteLog($logfilepath, "NO FOLDER ON SERVER: " & $Drive & "\" & $Storename & "\" & _DateDayOfWeek(@WDAY) & $Today) If Not DirCreate($Drive & "\" & $Storename & "\" & _DateDayOfWeek(@WDAY) & $Today) Then _FileWriteLog($logfilepath, "DIRECTORY CREATION FAILED ON SERVER 2. COULD NOT CREATE FOLDER :" & @CRLF & $Drive & "\" & $Storename & "\" & _DateDayOfWeek(@WDAY) & $Today) EndIf Sleep(500) Else EndIf $fl = ScanFolder($FromPath, "Server") ; SCAN THE REPORTS FOLDER AT STORE CHECK FOR FILES THAT ARE ELIGIBLE FOR COPYING _FileWriteLog($logfilepath, "Folder Scan Complete. There were " & _Iif($FileCount = 0, "There Were No files to copy today.", $fl & " Files copied from Folder on this run." & @CRLF & "NEXT COPY RUN BELOW.")) _FileWriteLog($logfilepath, "#######################################################################################################") ; exit EndIf EndIf EndIf EndIf ;DriveMapDel($Drive) Exit ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;FUNCTIONS BELOW HERE FUNCTIONS BELOW HERE FUNCTIONS BELOW HERE FUNCTIONS BELOW HERE ;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func LogFile($FileName, $LocalORServer) ;Msgbox(0,"Logfile", $LocalORServer) _FileWriteLog($logfilepath, "Copying to " & $LocalORServer) Local $m Local $n = 0 If $LocalORServer = "Server" Then If StringRight($FileName, 4) = ".pdf" Or StringRight($FileName, 4) = ".xls" Or StringRight($FileName, 4) = ".csv" Then Do $n = FileCopy($FileName, $Drive & "\" & $Storename & "\" & _DateDayOfWeek(@WDAY) & $Today & "\" & $datetime & "_" & GetFileName($FileName), 1) _FileWriteLog($logfilepath, _Iif($n = 1, ";-)" & " Success copying " & $FileName, ";-(" & " Failure copying " & $FileName)) Until $n = 1 If $n = 1 Then If $FileName <> "reportscopy.log" Or $FileName <> "reports.ini" Then FileRecycle($FileName) EndIf Else _FileWriteLog($logfilepath, "Failed to Copy " & @CRLF & $FromPath & $FileName) EndIf ;ToolTip($FileName,0,0) $FileCount += 1 ToolTip($FileName & " " & $FileCount, 0, 0) EndIf Else ;It's local so copy to local C:\ Storename drive If StringRight($FileName, 4) = ".pdf" Or StringRight($FileName, 4) = ".xls" Or StringRight($FileName, 4) = ".csv" Then Do $n = FileCopy($FileName, "C:\" & $Storename & "_Reports" & "\" & _DateDayOfWeek(@WDAY) & $Today & "\" & $datetime & "_" & GetFileName($FileName), 1) _FileWriteLog($logfilepath, _Iif($n = 1, ";-)" & " Success copying " & $FileName, ";-(" & " Failure copying " & $FileName)) Until $n = 1 EndIf EndIf EndFunc ;==>LogFile Func ScanFolder($SourceFolder, $LocalORServer) _FileWriteLog($logfilepath, "Scanning Folder " & $SourceFolder & " With " & $LocalORServer) Local $Search Local $File Local $FileAttributes Local $FullFilePath ;MsgBox(0, "Scanfolder func", $LocalORServer) For $i = 1 To 3 If $i = 1 Then _FileWriteLog($logfilepath, "Searching Folder for: " & $SourceFolder & "\*" & $sext) $Search = FileFindFirstFile($SourceFolder & "\*" & $sext) ElseIf $i = 2 Then _FileWriteLog($logfilepath, "Searching Folder for: " & $SourceFolder & "\*" & $sext1) $Search = FileFindFirstFile($SourceFolder & "\*" & $sext1) Else $i = 3 _FileWriteLog($logfilepath, "Searching Folder for: " & $SourceFolder & "\*" & $sext2) $Search = FileFindFirstFile($SourceFolder & "\*" & $sext2) EndIf While 1 If $Search = -1 Then ExitLoop EndIf $File = FileFindNextFile($Search) If @error Then ExitLoop $FullFilePath = $SourceFolder & "\" & $File ;~ "R" = READONLY ;~ "A" = ARCHIVE ;~ "S" = SYSTEM ;~ "H" = HIDDEN ;~ "N" = NORMAL ;~ "D" = DIRECTORY ;~ "O" = OFFLINE ;~ "C" = COMPRESSED (NTFS compression, not ZIP compression) ;~ "T" = TEMPORARY ;~ "X" = EFS ENCRYPTION $FileAttributes = FileGetAttrib($FullFilePath) If StringInStr($FileAttributes, "D") Then ; IF ITS A DIRECTORY RESCAN ScanFolder($FullFilePath, $LocalORServer) Else ;Msgbox(0, "Calling Logfile with",$LocalORServer) LogFile($FullFilePath, $LocalORServer) EndIf ;ConsoleWrite(" Fullpatf " & $FullFilePath & @crlf) WEnd Next FileClose($Search) Return $FileCount EndFunc ;==>ScanFolder ; #FUNCTION# ====================================================================================================== ; Name...........: GetFileName ; Description ...: Returns the file name of the given file path ; Syntax.........: GetFileName($sFilePath) ; Parameters ....: $sFilePath - File path ; Return values .: Success - The file name ; Failure - -1, sets @error to: ; |1 - $sFilePath is not a string ; Author ........: Renan Maronni <renanmaronni@hotmail.com> ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =================================================================================================================== Func GetFileName($sFilePath) Local $aFolders = "" Local $FileName = "" Local $iArrayFoldersSize = 0 If (Not IsString($sFilePath)) Then Return SetError(1, 0, -1) EndIf $aFolders = StringSplit($sFilePath, "\") $iArrayFoldersSize = UBound($aFolders) $FileName = $aFolders[($iArrayFoldersSize - 1)] Return $FileName EndFunc ;==>GetFileName Func _FileSize_In_MegaBytes($File) $FileSizeInBytes = FileGetSize($File) $Equal = $FileSizeInBytes / $MegaByte $Round = Round($Equal, '2') Return $Round EndFunc ;==>_FileSize_In_MegaBytes Func _File_GetDate($File) $File = FileGetShortName($File) $Ft = "" $fTime = FileGetTime($File, 1) For $i = 0 To 2 $Ft &= $fTime[$i] & "/" Next Return StringTrimRight($Ft, 1) EndFunc ;==>_File_GetDate ;Kill Process's and Child Process's Func _ProcessCloseEx($sPID) If IsString($sPID) Then $sPID = ProcessExists($sPID) If Not $sPID Then Return SetError(1, 0, 0) Return Run(@ComSpec & " /c taskkill /F /PID " & $sPID & " /T", @SystemDir, @SW_HIDE) EndFunc ;==>_ProcessCloseEx ; Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) ConsoleWrite("We intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "Windescription is: " & $oMyError.windescription) SetError(1); something to check for when this function returns EndFunc ;==>MyErrFunc Func _GetDOSOutput($sCommand) Local $iPID, $sOutput = "" $iPID = Run('"' & @ComSpec & '" /c ' & $sCommand, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $sOutput &= StdoutRead($iPID, False, False) If @error Then ExitLoop EndIf Sleep(10) WEnd Return $sOutput EndFunc ;==>_GetDOSOutput -
Error When running complied Script
Ambient replied to Ambient's topic in AutoIt General Help and Support
b -
Error When running complied Script
Ambient replied to Ambient's topic in AutoIt General Help and Support
Nice one! -
Okay guys, I have written a script which essentially runs once a week to copy files to a server. It also copies the files to a local directory. When I run in Autoit it works perfectly. When I compile and run I get the attached error. Any help would be appreciated. How should I debug this? I am not a programmer by the way but love Autoit as it has done so much for me.
-
I am having the same issue. It's doing my head in. lol When I run the below it deletes the 64 bit entry but not the 32 bit entry. I am running Windows 7 64 bit Dim $root = "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC" Dim $root64 = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC" ;Local $aArrayOfData = _Security__LookupAccountName(@UserName) If @OSArch="X86" Then RegDelete ("HKLM\SOFTWARE\ODBC\ODBC.INI") ElseIf @OSArch="X64" Then RegDelete ("HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI") RegDelete ("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBC.INI") EndIf
-
Enumerate Removable Drives :::::: Another Contribution I hope its helpful! Sorry about the format got fed up trying to format when pasting it in. Perhaps someone can enlighten me on what I'm doing wrong. My code is ok in scite when I paste here the format goes even though I'm posting as autoit code. ;~ AutoIt Version: V3.3.6.1 [X32] ;~ Windows Version: WIN_XP [X86] ;~ Language: English (0409) #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 local $free,$label,$Drive,$status,$usb ToolTip("Enumerating Drives please wait...", 10, 10, "Loading drives...", 1) Sleep(2000) ToolTip("") Local $aDrives = DriveGetDrive("REMOVABLE") If Not IsArray($aDrives) Then ;lets check first if there is a USB Stick attached to machine. $usb = 0 ToolTip("No removable drives found; NO USB Stick in port!", 10, 10, "NO USB Sticks...", 1) Sleep(1000) ToolTip("") MsgBox(16, "No Removeable Drives", "No Removeable Drives Found Please Insert And Try Again") ConsoleWrite("No removable drives found; NO USB Stick in port!") Exit Else $usb = 1 For $i = 1 To $aDrives[0] If $aDrives[$i] = "A:" Then ContinueLoop $drive = StringUpper($aDrives[$i]) $status = DriveStatus($drive) $free = Round(DriveSpaceFree($drive), 2) $label = DriveGetLabel($aDrives[$i]) ConsoleWrite("**** Drive Number " & $i & " ****" & @CRLF & _ "Letter: " & StringUpper($aDrives[$i]) & @CRLF & _ "Label: " & DriveGetLabel($aDrives[$i]) & @CRLF & _ "Status: " & DriveStatus($aDrives[$i]) & @CRLF) If $status = "UNKNOWN" Then MsgBox(16, "USB Format", "Please format USB and run backup again", 4) ;Stick code in here to check return value and call format drive if required. Exit EndIf If $i > 1 Then MsgBox(16, "Only One USB drive Allowed", "Please remove one of the removeable drives and run again", 4) Exit Else MsgBox(16, "USB Drive : - " & $label, Round(DriveSpaceTotal($drive) / 1012, 2) & "Gb" & " Drive has been allocated letter " & $drive & @CRLF & @CRLF & " Drive has " & $free & "Mb Free Space!") EndIf Next ConsoleWrite($aDrives[0] & " Drives Loaded." & @CRLF & @CRLF) EndIf Exit
-
This is my first ever post and I am not really a programmer so go easy on me if I have done anything wrong. To be honest I'm rahter nervous about doing it but I have heard a few people looking for something like this . Anyway here is my attempt at a DLL checker. Hope that its useful, I have used it after copying in a file and then registering using Regsvr32 to check if the DLL registered ok I have also used when creating an RFT logger which i hope to post soon. #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #include Local $res, $line, $sRegCmd, $sRegString Global $dll = "OLE32.dll" , $var,$var1,$var2,$path If _CheckDLLregistered($dll) Then ; The dll is registered ConsoleWrite("DLL Registered HKEY_CLASSES_ROOT\CLSID\" & $var & "\" & $var1 & @CRLF) ; ( Returns Registry paths ) Exit Else ; The dll is not registered so we need to register it in here other wise won't work ConsoleWrite("DLL NOT Registered " & $sRegCmd & @CRLF) ; ( Returns Registry paths ) Exit EndIf ;~ ----------------------------------------------------------------------------------------------------------------------------------------- ;~ AutoIt Version: v3.3.0.0 ;~ Language......: English ;~ Platform......: Windows XP ;~ Developer.....: Ambientguitar ;~ Last Modified.: 07/08/2012 ;~ version.......: 1.0.0.0 ;~ Copyright.....: (C) Ambientguitar ;~ File Name.....: Function _CheckDLLregistered ;~ Description...: Allows users to Check if a DLL is registered in their system ;~ Purpose.......: Check a DLL is registered if not register it using Regserv32. ;~ Returns.......: 1 if registered ;~ Parameters....: DLL Name to check ;~ Example.......: _CheckDLLregistered($dll) Or try _CheckDLLregistered(msado15.dll) ;~ ----------------------------------------------------------------------------------------------------------------------------------------- Func _CheckDLLregistered($dllname) For $i = 1 To 3000 $var = RegEnumKey("HKEY_CLASSES_ROOT\CLSID", $i) If @error <> 0 Then ExitLoop For $j = 1 To 3000 $var1 = RegEnumKey("HKEY_CLASSES_ROOT\CLSID\" & $var, $j) If @error <> 0 Then ExitLoop If $var1 = "InprocServer32" Then $path = "HKEY_CLASSES_ROOT\CLSID\" & $var & "\" & $var1 ToolTip($path, 10, 20, "Enumerating Registry") $var2 = RegRead($path, "") If StringInStr($var2, $dllname) Then Return 1 EndIf EndIf Next Next EndFunc ;==>_CheckDLLregisteredDLL_CHECKER1.au3
-
I like this it's great, very nice indeed ! Just one question and I hope that you can help I have checked the links to the other skins and there are some nice ones that I would like to use but I noticed that each skin has a seperate .au3 file for the msstyles . So therefore, my question is this can you post some guidance on how to go about creating the au3 file needed for the msstyles file? Muito obrigado
-
Thanks Hannes I'll check it out and if I had my way I'd rewrite the lot loL! All in good ole autoit!
-
Hi Guys, I have been messing about with a little script that accepts a parameter which is the name of a batch file (any batch file in C:\batch) which the script will then run showing a progress bar until cmd.exe closes. I haven't quite finished it but I was using a batch file which pings google for testing and I noticed the when my script finishes cmd.exe gets closed but ping.exe remains open in processes. My problem is how can i determine what processs get opened by the batch file? I was thinking of perhaps getting all running processes at the start of the script into an array the when I run the batch file doing the same then compareing to get the differnces. When I have the differences closing them when the script finishes. Just my thoughts but there is probably an easier way to do this. The reasn I want to do this is we use quite a few batch files historically and it would be nice notto have to re-write then but run them hidden rather then have them showing CMd windows all over the place.
-
Hi got this one sorted now working as I would like except the part where I do the editing saving etc.Mini you are forgiven its the season of "goodwill to all men" (oh and women of course) after all lol!Thanks a bunch Melba23 your suggestion worked it was that function. I was initializing a variable outside the function to clear the editbox mived this into the function to clear before updating and now working a treat. All I have to do now is work out how to do the rest of this lol! Have a great Christmas and Thanks again.
-
I suspect you may be right did a quick consolewrite and it looks like it is returning duplicate key names? However only showing one in Editbox. Anyway haven't time today to look at it further . Thank you very much for your suggestion. I'll keep you posted.
-
Hi folks, I am trying to create an ini editor for work purposes. I have a GUI which has a context menu built on the fly from ini sections. When I click on the menu it it then passes the section name to a function that uses $text=IniReadSection ( $g_IniFile, $section ). This then puts the section keys into the editbox $edit1 using $Edit1 = GUICtrlCreateEdit("",30,70,600,300,BitOR($ES_NOHIDESEL,$ES_AUTOVSCROLL, $WS_HSCROLL,$WS_VSCROLL, $ES_MULTILINE)) GUICtrlSetData ($Edit1 ,_readsection($sText)) The problem is this, before running GUICtrlSetData ($Edit1 ,_readsection($sText)) I run a clear function which essentially does this GUICtrlSetData ($Edit1 ,"") which clears the text OK from $edit1 If I then rightclick and bring up my selecting another section it puts it into the editbox but it is appended to the section text that was there previously. AHs anayone got any ideas where I'mgoing wrong. I have searched for 2 days in forum but can't see any thing releavant. I a have also tried in clear the following: $rs=GUICtrlSetData($Edit1 , "","") sleep(2000) If $rs=1 Then msgbox(0,$rs, "Success") Else msgbox(0,$rs, "Failure") Endif this returns 1 Also tried _GUICtrlEdit_SetText($edit1,"") and GUICtrlSendMsg($Edit1 , $WM_SETTEXT, 0, "") No joy either , thanks in advance for your suggestions.Also , any ideas how I can save edited text to the file.
-
try this it works treat for me , it can be tweaked if necessary. ; Save below to an options.ini file in your script directorythis assumes that you have Wzzip commandline ;installed in your winzip directory [ZIPFILES] --- The fles that are to be zipped please note they will be deleted after being zipped FilesToZip= C:\batch\*.txt -- you need the .zip extension WhereToZip= C:\numpty.zip [LOGPATH] logfilePath= C:\zip.log ;********************************************************************************* ; Script to zip files #include <Process.au3> $logfilepath=IniRead(@ScriptDir & "\Options.ini", "LOGPATH", "Logfilepath", @ScriptDir &'\zip.log') $filestozip=IniRead(@ScriptDir & "\Options.ini", "ZIPFILES", "FilesToZip", 0) _Zipfiles($filestozip) ; run function Func _Zipfiles($pathtozip) $a = FileGetShortName($pathtozip) $Zipto=IniRead(@ScriptDir & "\options.ini", "ZIPFILES", "WhereToZip","''") ;MsgBox(0,$a,$Pathtozip & ' in _zip func') $zipPath='"C:\Program files\WinZip\WZzip"' & ' -m ' & $Zipto & " " & $pathtozip & ' -ybc' MsgBox(0,"Test ZIPPING",$zipPath) _FileWriteLog($logfilepath,$zipPath) $rc = _RunDos($zipPath) Sleep(3000) If $rc >=1 Then _FileWriteLog($logfilepath, "Failed to zip " & " returned an error code of " & $rc) Else _FileWriteLog($logfilepath, "Success zipping " & ".zip returned an error code of " & $rc) Endif Endfunc
-
Need help with Regional, timezone settings
Ambient replied to Ambient's topic in AutoIt General Help and Support
great idea thanks I'll try that -
Need help with Regional, timezone settings
Ambient replied to Ambient's topic in AutoIt General Help and Support
yes United Kingdom GMT in time prperties I want to show as (GMT) Greenwich Mean Time:Dublin,Edinburgh,Lisbon,London