Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/24/2015 in all areas

  1. Melba23

    New MVPs

    Hi, Some good news today: LarsJ, mikell and mLipok have accepted the invitation to become MVPs. I am sure you will all join me in congratulating them on their new status. M23
    2 points
  2. zorphnog

    log4a - A logging UDF

    I routinely need to log information for my scripts. In the past, I've usually just created functions in each script to write to a log file. I also use ConsoleWrite in conjunction with SciTE a lot when I'm trying to debug scripts. After using some logging libraries for other languages (namely NLog (C#) and Java (log4j)) I decided to write a logging UDF for AutoIt. I decided to base it loosely upon the log4j and NLog libaries. I say loosely because this one is not nearly as feature rich as either one of those, but I think it still provides a nice logging interface. What can it do? Output types: Console, File, or Both. Additionally, you can configure the logger to output differently based on whether the script is compiled or not. This way you can output to the console (SciTE) while you're writing a script, and output to a log file when you've compile the script. Log levels: While I don't think it's really necessary to have this many log levels, these are the levels in ascending order of severity: Trace Debug Info Warn Error Fatal Log Filtering: The log can be enabled and disabled. There are also minimum and maximum log levels that can be configured to only show a range of log levels (i.e. a minimum level of warn would not log messages for trace, debug, or info). These filter levels can be overridden when logging a message if the need be. Error Stream: Logging can be configured to write to the stderr (i.e. ConsoleWriteError). When enabled, any log messages at the error level and above will be written to the error stream. Message Format Macros: The logging message format can be customized to your liking using the following macros: ${date} = Long date (i.e. MM/DD/YYYY HH:MM:SS) ${host} = Hostname of local machine ${level} = The current log level ${message} = The log message ${newline} = Insert a newline ${shortdate} = Short date (i.e. MM/DD/YYYY) Available Functions: Configuration Functions _log4a_SetCompiledOutput - Sets the logging output type for the compiled version of the script (Default: $LOG4A_OUTPUT_FILE) _log4a_SetEnable - Enables or disables logging messages (Default: Disabled) _log4a_SetErrorStream - Enables or disables logging of the standard error stream (Default: Enabled) _log4a_SetFormat - Configures the format of logging messages (Default: "${date} ${level} ${message}") _log4a_SetLogFile - Sets the path of the log file (Default: "<ScriptFullPath>.log") _log4a_SetMaxLevel - Configures the maximum log level to process messages (Default: $LOG4A_LEVEL_FATAL) _log4a_SetMinLevel - Configures the minimum log level to process messages (Default: $LOG4A_LEVEL_TRACE) _log4a_SetOutput - Sets the logging output type for the non-compiled version of the script (Default: $LOG4A_OUTPUT_CONSOLE) Logging Functions _log4a_Debug - Logs a message at the debug level _log4a_Error - Logs a message at the error level _log4a_Fatal - Logs a message at the fatal level _log4a_Info - Logs a message at the info level _log4a_Message - Logs a message to the configured outputs _log4a_Trace - Logs a message at the trace level _log4a_Warn - Logs a message at the warn level See the source file for full documentation of available functions. A quick example script: #include "log4a.au3" ; Enable logging and don't write to stderr _log4a_SetEnable() _log4a_SetErrorStream(False) log_messages() ; Write to stderr, set min level to warn, customize message format _log4a_SetErrorStream() _log4a_SetMinLevel($LOG4A_LEVEL_INFO) If @compiled Then _log4a_SetMinLevel($LOG4A_LEVEL_WARN) ; Change the min level if the script is compiled _log4a_SetFormat("${shortdate} | ${host} | ${level} | ${message}") log_messages() ; Disable logging (except for those that override) _log4a_SetEnable(False) log_messages() Func log_messages() _log4a_Trace("A TRACE message", True) ; overrides filters _log4a_Debug("A DEBUG message") _log4a_Info("A INFO message") _log4a_Warn("A WARN message") _log4a_Error("A ERROR message", True) ; overrides filters _log4a_Fatal("A FATAL message") EndFunc Without further adieu, the UDF: log4a.au3
    1 point
  3. mikell

    WinMove, GUIResize

    Maybe this Opt("GUIResizeMode", $GUI_DOCKALL)
    1 point
  4. ViciousXUSMC, Hehe "(fox|cat)[^<]*</td>" => matches a string containing fox|cat AND zero or more non-< chars up to </td> When done, the search continues after the </td> "(fox|cat)(?=[^<]*<\/td>)" => matches fox|cat followed by 0 or more non-< chars and </td> When done, the search continues after the match It's the magic of the lookahead which is a zero-length assertion BTW [^<]* is used to check that there is no html tag between fox|cat and </td> Edit : Note that you can also do it like this "(?i)(?=(fox|cat)[^<]*</td>)"
    1 point
  5. Deye, I would use: StringRegExp($sDigit, "^\d$") M23
    1 point
  6. @‌kcvinu Wow, that makes it easy! I did not know about the .GetRecords method. I did a quick performance test and that method is about 50% faster! Good find. I may have to implement it into my code done.
    1 point
  7. A UDF isn't necessarily defined by it's complexity or simplicity. It's really just a matter of defining functions that are not embedded within the AutoIt interpreter. Having said that, I will say that a well written UDFs/functions are as modular as possible. I'll admit, my UDF is a bit old and has had a few updates made since it's inception, so it's probably not as modularized as I would like...but if it ain't broke... Perhaps I'll revisit it sometime. I'll be happy to look at the _Get_Records() func in your code and provide you feedback.
    1 point
  8. I like the idea of having a raw SQL statement capability. Good stuff. My only question (having not looked at the code in your attachments), looking at your example above, is there a reason you broke out functions for _Create..., _Alter..., _Insert..., instead of having a single function to execute a SQL statement? i.e. _SQL_Execute("CREATE TABLE....), _SQL_Execute("ALTER TABLE....), etc.
    1 point
  9. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Func Drag File and Drop", 456, 53, -1, -1,-1, $WS_EX_ACCEPTFILES) $Input1 = GUICtrlCreateInput("[ ... ]", 8, 24, 441, 21) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_DROPPED Msgbox(0,"", @GUI_DragFile) ; do here whatever you want: GuiCtrlSetData($Input1, @GUI_DragFile & ".renamed") EndSwitch WEnd
    1 point
  10. Well your drag and drop works, do you want to rename or copy selected file? Here is some starting point for you: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $gui_choose Global $btn_copy = 9999 Global $btn_rename = 9999 Global $Form1 = GUICreate("Func Drag File and Drop", 256, 53, -1, -1, -1, $WS_EX_ACCEPTFILES) Global $Input1 = GUICtrlCreateInput("[ ... ]", 8, 24, 241, 21) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Input1 WhatNext() Case $btn_copy CopyFile() Case $btn_rename RenameFile() EndSwitch WEnd Func WhatNext() ;Create new GUI to select the next action $gui_choose = GUICreate("What to do?", 200, 60, -1, -1, -1, $WS_EX_TOPMOST) $btn_copy = GUICtrlCreateButton("Copy", 10, 10, 80, 40) $btn_rename = GUICtrlCreateButton("Rename", 100, 10, 80, 40) GUISetState() EndFunc ;==>WhatNext Func CopyFile() ;<<<<<<<=========== Edit this anyway you want GUIDelete($gui_choose) MsgBox(0, "", "Create function for copying the file somewhere") EndFunc ;==>CopyFile Func RenameFile() ;<<<<<<<=========== Edit this anyway you want GUIDelete($gui_choose) MsgBox(0, "", "Create function for renaming the file") EndFunc ;==>RenameFile
    1 point
  11. @nick2price You can use the AU3Info tool (Tools -> AU3Info in Full Installation of SciTE) to know the class of the window P.S You only need one of these: title/hWnd/class, Not all of them
    1 point
  12. @nick2price Use Send('^c')^v means Ctrl + V not Ctrl+ C (as you would see in command prompt) TD Edit: WinActivate won't work, You need the title/hWnd/class of the window to activate the windows, Read the documentation for more info
    1 point
  13. Try this: <?php $output = exec('C:\Program Files (x86)\AutoIt3\AutoIt3.exe test2.au3'); echo "<pre>$output</pre>"; TD
    1 point
  14. czardas, I added that after the last round of complaints. M23
    1 point
  15. JLogan3o13

    VMworld

    Caution, word-wall ahead: Conference thoughts General meandering complaints about the venue -
    1 point
  16. Jon

    AutoIt v3.3.14.2 Released

    AutoIt v3.3.14.0 has been released. Thanks to everyone involved, both visible and behind the scenes. Download it here. Complete list of changes: History Note The Map functionality was disabled in this release as it was not ready. I will release another beta version later with it re-enabled for continued dev and test.
    1 point
  17. In some ways it's not so surprising because we both base our syntax on an existing universal model - music notation. Yeah, I will do shortly. If you want to mention it straight away, by all means be my guest.
    1 point
×
×
  • Create New...