Jump to content

Recommended Posts

Posted (edited)

?

the file must already exist in order to use _FileWriteToLine

here it works if the file.txt file exists on the desktop.

p.s.
a hypothesis; if you create the file.txt manually using the context menu new -> text file, do not type the extension .txt that even if it is not visible, it is created automatically ... (just a wild guess)

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

  • 1 month later...
Posted (edited)

Using the BETA, I had this error: Variable used without being declared $tagSYSTEMTIME

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /beta /ErrorStdOut /in "D:\DOWNLOADS\CCTVBackup\CCTVBackup.au3" /UserParams    
+>21:45:28 Starting AutoIt3Wrapper (21.316.1639.1) from:SciTE.exe (4.4.6.0)  Keyboard:00000409  OS:WIN_10/2009  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\johnny\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\johnny\AppData\Local\AutoIt v3\SciTE
>Running AU3Check (3.3.15.4)  from:C:\Program Files (x86)\AutoIt3\Beta  input:D:\DOWNLOADS\CCTVBackup\CCTVBackup.au3
+>21:45:29 AU3Check ended.rc:0
>Running:(3.3.15.4):C:\Program Files (x86)\AutoIt3\Beta\autoit3_x64.exe "D:\DOWNLOADS\CCTVBackup\CCTVBackup.au3"    
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
"C:\Program Files (x86)\AutoIt3\Beta\Include\Date.au3" (1486) : ==> Variable used without being declared.:
Local $tLocalTime = DllStructCreate($tagSYSTEMTIME)
Local $tLocalTime = DllStructCreate(^ ERROR
->21:45:29 AutoIt3.exe ended.rc:1
+>21:45:29 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 1.217

Using the actual PRODUCTION version also has the same error BUT different variable:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /test /run /prod /ErrorStdOut /in "D:\DOWNLOADS\CCTVBackup\CCTVBackup.au3" /UserParams    
+>21:50:36 Starting AutoIt3Wrapper (21.316.1639.1) from:SciTE.exe (4.4.6.0)  Keyboard:00000409  OS:WIN_10/2009  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\johnny\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\johnny\AppData\Local\AutoIt v3\SciTE
- *** Compile in Test mode skipping Tidy; Au3Stripper; Resource updating and Versioning to speed up the process. ***
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:D:\DOWNLOADS\CCTVBackup\CCTVBackup.au3
+>21:50:37 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "D:\DOWNLOADS\CCTVBackup\CCTVBackup.au3"    
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
"C:\Program Files (x86)\AutoIt3\Include\Date.au3" (625) : ==> Variable used without being declared.:
$sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_SSHORTDATE)
$sTempString = _WinAPI_GetLocaleInfo(^ ERROR
->21:50:37 AutoIt3.exe ended.rc:1
+>21:50:37 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 1.192

 

Edited by Melba23
Added code tags
Posted
1 hour ago, ITMan2000 said:

"C:\Program Files (x86)\AutoIt3\Beta\Include\Date.au3" (1486) : ==> Variable used without being declared.:
Local $tLocalTime = DllStructCreate($tagSYSTEMTIME)

This file: C:\Program Files (x86)\AutoIt3\Beta\Include\Date.au3
should contain:

#include-once

#include "DateTimeConstants.au3"
#include "Memory.au3"
#include "Security.au3"
#include "StructureConstants.au3"
#include "WinAPIError.au3"
#include "WinAPIHObj.au3"
#include "WinAPILocale.au3"

....

does it contain?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Posted (edited)

Here's the brief code below. To answer mLipok question, yes, DATE.AU3 has all the necessary includes in the file. No change at all.

Global $g_hLogFile, $lShowWindow

#include <Date.au3>
#include <EventLog.au3>
#include <GuiConstants.au3>
#include <WindowsConstants.au3>

#Include <File.au3>
#Include <Array.au3>
#Include <String.au3>

#OnAutoItStartRegister  "OnAutoItStart"
OnAutoItExitRegister( "OnAutoItExit" )
Opt( "TrayIconHide", 0 )
Opt( "MustDeclareVars", 1 )

;============================================
; Is Parameters Been Passed To This EXE?
; 1st Parameter - Show Progress Window?
;                    Y - To Show.
;                    N - Do Not Show. Default
;============================================
If $CmdLine[ 0 ] > 0 Then
    $lShowWindow = StringUpper( $CmdLine[ 1 ] )
Else
    $lShowWindow = "N"
EndIf

;==========================
; Declare Variables To Use
;==========================
Local $cWindowTitle = "Backup CCTV Video Files To Alibaba Cloud"
Local $nColumn = ( @DesktopWidth - 600 ) / 2

;========================================
; Check Multiple Copy Of Program Running
;========================================
If WinExists( $cWindowTitle ) Then
    udfWriteLog( $g_hLogFile, "Error! Another Copy Of " & @ScriptName & " Is Currently Running!" )
    Exit
EndIf
AutoItWinSetTitle( $cWindowTitle )

Exit

;======================================
; Whenever The Program Is Executed/Run
; This Function Will Be Run First
;======================================
Func OnAutoItStart()
Local $cLogFile
Local $cINIFile = @ScriptDir & "\CCTVBackup.INI"
Local $cLogDir
Local $hEventLog, $aData[4]=[3, 1, 2, 3]

;=============================
; Check If The INI File Exist
;=============================
If Not FileExists( $cINIFile ) Then
    $hEventLog = _EventLog__Open( "", "CCTV File Backup" )
    _EventLog__Report( $hEventLog, 1, 999, 999, "", "AutoIt3 - INI File Not Found!", $aData )
    _EventLog__Close ( $hEventLog )
    Exit
Endif

$cLogDir = IniRead( $cINIFile, "Directories", "LogDir",                "Not Found" )

;====================
; Setup The Log File
;====================
    $cLogFile = $cLogDir & "\" & @ScriptName &  ".LOG"
    $g_hLogFile = FileOpen( $cLogFile, 9 )
    If $g_hLogFile == -1 Then
        Exit
    EndIf

    udfWriteLog( $g_hLogFile, "Starting " & @ScriptName & " Program...." )
    udfWriteLog( $g_hLogFile, " AutoIT Version: " & @AutoItVersion )
    udfWriteLog( $g_hLogFile, "     OS Version: " & @OSVersion )
    udfWriteLog( $g_hLogFile, "FixPack Version: " & @OSServicePack )
    udfWriteLog( $g_hLogFile, " " )
EndFunc    ; ==> OnAutoItStart


Func OnAutoItExit()
    udfWriteLog( $g_hLogFile, " " )
    udfWriteLog( $g_hLogFile, "Ending " & @ScriptName & " Program...." )
    udfWriteLog( $g_hLogFile, _StringRepeat( "=", 80 ), 2 )

    FileClose( $g_hLogFile )
EndFunc    ; ==> OnAutoItExit


;*----------------------------------------------------------------*
;* Function Name...: udfWriteLog                                  *
;* Description.....: To Write A Single Line Of Information To     *
;*                   The Log File                                 *
;* Syntax..........: udfWriteLog( $hLogFile, $cText, [ $nTime ] ) *
;*                   $hLogFile - Log File Handle To Write The Log *
;*                      $cText - Error Message To Write           *
;*                      $nTime - Default 1, 2                     *
;*                               1 - To Print With Time           *
;*                               2 - Do Not Print With Time       *
;*----------------------------------------------------------------*
Func udfWriteLog( $hLogFile, $cText, $nTime = 1 )
Local $cString

    If $nTime == 1 Then
        ;$cString = @HOUR & ":" & @MIN & ":" & @SEC & " - "
        $cString = _Now() & " - "
    ElseIf $nTime == 2 Then
        $cString = ""
    Else
        $cString = "           "
    EndIf
    $cString = $cString & $cText

    FileWriteLine( $hLogFile, $cString )
EndFunc   ; ==> udfWriteLog

 

Edited by Melba23
Added code tags
  • Moderators
Posted

ITMan2000,

The problem arises because you are trying to use those variables in the function run by #OnAutoItStartRegister - and if you read the Help file carefully you will see that:

Quote

As the function runs before any of the main script code is executed, the function cannot reference any variables defined in an #include nor any variables defined as Global within the script.

So as the 2 items which cause the error are both defined within the includes, you cannot reference them within the function registered to run under #OnAutoItStartRegister. If you try to run the example in the Help file for this command, you will see that it has exactly the same problem with $MB_SYSTEMMODAL! So thanks for pointing it out.

I would suggest just running the function immediately the script starts rather then registering it as you are currently doing - that way the includes will be made available and the problem will no longer exist.

M23

P.S. When you post code in future please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. Thanks in advance for your cooperation.

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted
2 minutes ago, Melba23 said:

ITMan2000,

The problem arises because you are trying to use those variables in the function run by #OnAutoItStartRegister - and if you read the Help file carefully you will see that:

So as the 2 items which cause the error are both defined within the includes, you cannot reference them within the function registered to run under #OnAutoItStartRegister. If you try to run the example in the Help file for this command, you will see that it has exactly the same problem with $MB_SYSTEMMODAL! So thanks for pointing it out.

I would suggest just running the function immediately the script starts rather then registering it as you are currently doing - that way the includes will be made available and the problem will no longer exist.

M23

P.S. When you post code in future please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. Thanks in advance for your cooperation.

Noted and Noted. Split the codes in #OnAutoItStartRegister. It works fine now. TQ

  • Moderators
Posted

ITMan2000,

One final point - when you reply in future, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily. Thanks in advance for your cooperation.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • 1 month later...
Posted
On 6/12/2021 at 11:15 AM, Shark007 said:

about - Fixed #3682: GuiCtrlCreatePic() with h=0 and w=0.

I use the following with the current release 33.14.5 which produces the right-hand  graphic below:

#AutoIt3Wrapper_Res_File_Add="icons\shark.png", RT_RCDATA, shark, 0

#include <ResourcesEx.au3>

Global $Pic = GUICtrlCreatePic('', -1, -1) ; logo
_Resource_SetToCtrlID($Pic, 'shark')
GUICtrlSetPos($Pic, 205, 70, 140, 140)

One other thing I should point out is that I use, #AutoIt3Wrapper_Res_HiDpi=Y
which means my positioning line is actually, GUICtrlSetPos($Pic, 205 * $iScale, 70 * $iScale, 140 * $iScale, 140 * $iScale)
where $iScale is relative to the screen scaling. (150% scaling = a 1.5 multiplication factor) Maybe this is where my issue lies.

No matter what I change I always get the same size (visible) pic using the beta. (to small).
I am able to confirm that 140x140 pixels are allocated to the graphic but for whatever reason,
the visible pic does not fill that space.

The png is natively 140x140 but I cannot make it display in that size. (screen positioning is no issue)

Below, the larger graphic is correct. The smaller graphic is from the Beta which does allocate the 140x140 pixels to the graphic, it just doesn't fill the allocated space.

1.jpg 2.jpg

To revisit my statements here, I'd like to add...

If I remove the Width/Height as such;  GUICtrlSetPos($Pic, 205 , 70) 
It also results in a small pic in the non beta version.

Only wanted to make this statement because I'd have thought it would use the native dimensions of the pic, 140x140

  • Jon unpinned this topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...