Leaderboard
Popular Content
Showing content with the highest reputation on 08/01/2013 in all areas
-
JohnOne, Open SciTEConfig, select the <Other Tools> tab and then press <Run User CallTip manager>. There is a Help file under <SciTE Help - Extra Utilities - User CallTip Manager>. M232 points
-
mesale0077 asked me whether I could code some CSS loading animations from different web sites. These are the results using GDI+ (AutoIt v3.3.12.0+ required!): _GDIPlus_MonochromaticBlinker.au3 / _GDIPlus_RotatingBokeh.au3 _GDIPlus_SpinningCandy.au3 / _GDIPlus_SteamPunkLoading.au3 _GDIPlus_IncreasingBalls.au3 / _GDIPlus_PacmanProgressbar.au3 _GDIPlus_StripProgressbar.au3 / _GDIPlus_RingProgressbar.au3 _GDIPlus_LineProgressbar.au3 / _GDIPlus_SimpleLoadingAnim.au3 _GDIPlus_TextFillingWithWater.au3 / _GDIPlus_MultiColorLoader.au3 _GDIPlus_LoadingSpinner.au3 / _GDIPlus_SpinningAndPulsing.au3 _GDIPlus_TogglingSphere.au3 / _GDIPlus_CloudySpiral.au3 _GDIPlus_GlowingText.au3 (thanks to Eukalyptus) / _GDIPlus_HypnoticLoader.au3 _GDIPlus_RotatingRectangles.au3 / _GDIPlus_TRONSpinner.au3 _GDIPlus_RotatingBars.au3 / _GDIPlus_AnotherText.au3 (thanks to Eukalyptus) _GDIPlus_CogWheels.au3 (thanks to Eukalyptus) / _GDIPlus_DrawingText.au3 (thanks to Eukalyptus) _GDIPlus_GearsAnim.au3 / _GDIPlus_LEDAnim.au3 _GDIPlus_LoadingTextAnim.au3 / _GDIPlus_MovingRectangles.au3 _GDIPlus_SpinningAndGlowing.au3 (thanks to Eukalyptus) / _GDIPlus_YetAnotherLoadingAnim.au3 _GDIPlus_AnimatedTypeLoader.au3 / _GDIPlus_Carousel.au3 Each animation function has a built-in example how it can be used. AiO download: GDI+ Animated Wait Loading Screens.7z (previous downloads: 1757) Big thanks to Eukalyptus for providing several examples. Maybe useful for some of you Br, UEZ PS: I don't understand CSS - everything is made out of my mind, so it might be different from original CSS examples1 point
-
This is a question which gets asked quite a bit >> How to add my program to the Startup Folder? Or How can I make my program run when the PC starts? So for those who want to call a simple Function e.g. _StartupFolder_Install() this UDF is for you. UDF: #include-once ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 ; #INDEX# ======================================================================================================================= ; Title .........: _Startup ; AutoIt Version : v3.3.10.0 or higher ; Language ......: English ; Description ...: Create startup entries in the startup folder or registry. The registry entries can be Run all the time (Run registry entry) or only once (RunOnce registry entry.) ; Note ..........: ; Author(s) .....: guinness ; Remarks .......: Special thanks to KaFu for EnumRegKeys2Array() which I used as inspiration for enumerating the Registry Keys. ; =============================================================================================================================== ; #INCLUDES# ==================================================================================================================== #include <StringConstants.au3> ; #GLOBAL VARIABLES# ============================================================================================================ Global Enum $STARTUP_RUN = 0, $STARTUP_RUNONCE, $STARTUP_RUNONCEEX ; #CURRENT# ===================================================================================================================== ; _StartupFolder_Exists: Checks if an entry exits in the 'All Users/Current Users' startup folder. ; _StartupFolder_Install: Creates an entry in the 'All Users/Current Users' startup folder. ; _StartupFolder_Uninstall: Deletes an entry in the 'All Users/Current Users' startup folder. ; _StartupRegistry_Exists: Checks if an entry exits in the 'All Users/Current Users' registry. ; _StartupRegistry_Install: Creates an entry in the 'All Users/Current Users' registry. ; _StartupRegistry_Uninstall: Deletes the entry in the 'All Users/Current Users' registry. ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; See below. ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StartupFolder_Exists ; Description ...: Checks if an entry exits in the 'All Users/Current Users' startup folder. ; Syntax ........: _StartupFolder_Exists([$sName = @ScriptName[, $bAllUsers = False]]) ; Parameters ....: $sName - [optional] Name of the program. Default is @ScriptName. ; $bAllUsers - [optional] Add to Current Users (False) or All Users (True) Default is False. ; Return values .: Success - True ; Failure - False ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _StartupFolder_Exists($sName = @ScriptName, $bAllUsers = False) Local $sFilePath = Default __Startup_Format($sName, $sFilePath) Return FileExists(__StartupFolder_Location($bAllUsers) & '\' & $sName & '.lnk') EndFunc ;==>_StartupFolder_Exists ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StartupFolder_Install ; Description ...: Creates an entry in the 'All Users/Current Users' startup folder. ; Syntax ........: _StartupFolder_Install([$sName = @ScriptName[, $sFilePath = @ScriptFullPath[, $sCommandline = ''[, ; $bAllUsers = False]]]]) ; Parameters ....: $sName - [optional] Name of the program. Default is @ScriptName. ; $sFilePath - [optional] Location of the program executable. Default is @ScriptFullPath. ; $sCommandline - [optional] Commandline arguments to be passed to the application. Default is ''. ; $bAllUsers - [optional] Add to Current Users (False) or All Users (True) Default is False. ; Return values .: Success - True ; Failure - False & sets @error to non-zero ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _StartupFolder_Install($sName = @ScriptName, $sFilePath = @ScriptFullPath, $sCommandline = '', $bAllUsers = False) Return __StartupFolder_Uninstall(True, $sName, $sFilePath, $sCommandline, $bAllUsers) EndFunc ;==>_StartupFolder_Install ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StartupFolder_Uninstall ; Description ...: Deletes an entry in the 'All Users/Current Users' startup folder. ; Syntax ........: _StartupFolder_Uninstall([$sName = @ScriptName[, $sFilePath = @ScriptFullPath[, $bAllUsers = False]]]) ; Parameters ....: $sName - [optional] Name of the program. Default is @ScriptName. ; $sFilePath - [optional] Location of the program executable. Default is @ScriptFullPath. ; $bAllUsers - [optional] Was it added to Current Users (False) or All Users (True) Default is False. ; Return values .: Success - True ; Failure - False & sets @error to non-zero ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _StartupFolder_Uninstall($sName = @ScriptName, $sFilePath = @ScriptFullPath, $bAllUsers = False) Return __StartupFolder_Uninstall(False, $sName, $sFilePath, Default, $bAllUsers) EndFunc ;==>_StartupFolder_Uninstall ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StartupRegistry_Exists ; Description ...:Checks if an entry exits in the 'All Users/Current Users' registry. ; Syntax ........: _StartupRegistry_Exists([$sName = @ScriptName[, $bAllUsers = False[, $iRunOnce = $STARTUP_RUN]]]) ; Parameters ....: $sName - [optional] Name of the program. Default is @ScriptName. ; $bAllUsers - [optional] Add to Current Users (False) or All Users (True) Default is False. ; $iRunOnce - [optional] Always run at system startup $STARTUP_RUN (0), run only once before explorer is started $STARTUP_RUNONCE (1) ; or run only once after explorer is started $STARTUP_RUNONCEEX (2). Default is $STARTUP_RUN (0). ; Return values .: Success - True ; Failure - False ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _StartupRegistry_Exists($sName = @ScriptName, $bAllUsers = False, $iRunOnce = $STARTUP_RUN) Local $sFilePath = Default __Startup_Format($sName, $sFilePath) RegRead(__StartupRegistry_Location($bAllUsers, $iRunOnce) & '\', $sName) Return @error = 0 EndFunc ;==>_StartupRegistry_Exists ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StartupRegistry_Install ; Description ...: Creates an entry in the 'All Users/Current Users' registry. ; Syntax ........: _StartupRegistry_Install([$sName = @ScriptName[, $sFilePath = @ScriptFullPath[, $sCommandline = ''[, ; $bAllUsers = False[, $iRunOnce = $STARTUP_RUN]]]]]) ; Parameters ....: $sName - [optional] Name of the program. Default is @ScriptName. ; $sFilePath - [optional] Location of the program executable. Default is @ScriptFullPath. ; $sCommandline - [optional] Commandline arguments to be passed to the application. Default is ''. ; $bAllUsers - [optional] Add to Current Users (False) or All Users (True) Default is False. ; $iRunOnce - [optional] Always run at system startup $STARTUP_RUN (0), run only once before explorer is started $STARTUP_RUNONCE (1) ; or run only once after explorer is started $STARTUP_RUNONCEEX (2). Default is $STARTUP_RUN (0). ; Return values .: Success - True ; Failure - False & sets @error to non-zero ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _StartupRegistry_Install($sName = @ScriptName, $sFilePath = @ScriptFullPath, $sCommandline = '', $bAllUsers = False, $iRunOnce = $STARTUP_RUN) Return __StartupRegistry_Uninstall(True, $sName, $sFilePath, $sCommandline, $bAllUsers, $iRunOnce) EndFunc ;==>_StartupRegistry_Install ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StartupRegistry_Uninstall ; Description ...: Deletes the entry in the 'All Users/Current Users' registry. ; Syntax ........: _StartupRegistry_Uninstall([$sName = @ScriptName[, $sFilePath = @ScriptFullPath[, $bAllUsers = False[, ; $iRunOnce = Default]]]]) ; Parameters ....: $sName - [optional] Name of the program. Default is @ScriptName. ; $sFilePath - [optional] Location of the program executable. Default is @ScriptFullPath. ; $bAllUsers - [optional] Was it added to the current users (0) or all users (1). Default is 0. ; $iRunOnce - [optional] Was it run at system startup $STARTUP_RUN (0), run only once before explorer is started $STARTUP_RUNONCE (1) ; or run only once after explorer is started $STARTUP_RUNONCEEX (2). Default is $STARTUP_RUN (0). ; Return values .: Success - True ; Failure - False & sets @error to non-zero ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _StartupRegistry_Uninstall($sName = @ScriptName, $sFilePath = @ScriptFullPath, $bAllUsers = False, $iRunOnce = $STARTUP_RUN) Return __StartupRegistry_Uninstall(False, $sName, $sFilePath, Default, $bAllUsers, $iRunOnce) EndFunc ;==>_StartupRegistry_Uninstall ; #INTERNAL_USE_ONLY#============================================================================================================ Func __Startup_Format(ByRef $sName, ByRef $sFilePath) If $sFilePath = Default Then $sFilePath = @ScriptFullPath EndIf If $sName = Default Then $sName = @ScriptName EndIf $sName = StringRegExpReplace($sName, '\.[^.\\/]*$', '') ; Remove extension. Return Not (StringStripWS($sName, $STR_STRIPALL) == '') And FileExists($sFilePath) EndFunc ;==>__Startup_Format Func __StartupFolder_Location($bAllUsers) Return $bAllUsers ? @StartupCommonDir : @StartupDir EndFunc ;==>__StartupFolder_Location Func __StartupFolder_Uninstall($bIsInstall, $sName, $sFilePath, $sCommandline, $bAllUsers) If Not __Startup_Format($sName, $sFilePath) Then Return SetError(1, 0, False) ; $STARTUP_ERROR_EXISTS EndIf If $bAllUsers = Default Then $bAllUsers = False EndIf If $sCommandline = Default Then $sCommandline = '' EndIf Local Const $sStartup = __StartupFolder_Location($bAllUsers) Local Const $hSearch = FileFindFirstFile($sStartup & '\' & '*.lnk') Local $vReturn = 0 If $hSearch > -1 Then Local Const $iStringLen = StringLen($sName) Local $aFileGetShortcut = 0, _ $sFileName = '' While 1 $sFileName = FileFindNextFile($hSearch) If @error Then ExitLoop EndIf If StringLeft($sFileName, $iStringLen) = $sName Then $aFileGetShortcut = FileGetShortcut($sStartup & '\' & $sFileName) If @error Then ContinueLoop EndIf If $aFileGetShortcut[0] = $sFilePath Then $vReturn += FileDelete($sStartup & '\' & $sFileName) EndIf EndIf WEnd FileClose($hSearch) ElseIf Not $bIsInstall Then Return SetError(2, 0, False) ; $STARTUP_ERROR_EMPTY EndIf If $bIsInstall Then $vReturn = FileCreateShortcut($sFilePath, $sStartup & '\' & $sName & '.lnk', $sStartup, $sCommandline) > 0 Else $vReturn = $vReturn > 0 EndIf Return $vReturn EndFunc ;==>__StartupFolder_Uninstall Func __StartupRegistry_Location($bAllUsers, $iRunOnce) If $iRunOnce = Default Then $iRunOnce = $STARTUP_RUN EndIf Local $sRunOnce = '' Switch $iRunOnce Case $STARTUP_RUNONCE $sRunOnce = 'Once' Case $STARTUP_RUNONCEEX $sRunOnce = 'OnceEx' Case Else $sRunOnce = '' EndSwitch Return ($bAllUsers ? 'HKEY_LOCAL_MACHINE' : 'HKEY_CURRENT_USER') & _ ((@OSArch = 'X64') ? '64' : '') & '\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' & $sRunOnce EndFunc ;==>__StartupRegistry_Location Func __StartupRegistry_Uninstall($bIsInstall, $sName, $sFilePath, $sCommandline, $bAllUsers, $iRunOnce) If Not __Startup_Format($sName, $sFilePath) Then Return SetError(1, 0, False) ; $STARTUP_ERROR_EXISTS EndIf If $bAllUsers = Default Then $bAllUsers = False EndIf If $sCommandline = Default Then $sCommandline = '' EndIf Local Const $sRegistryKey = __StartupRegistry_Location($bAllUsers, $iRunOnce) Local $iInstance = 1, _ $sRegistryName = '', _ $vReturn = 0 While 1 $sRegistryName = RegEnumVal($sRegistryKey & '\', $iInstance) If @error Then ExitLoop EndIf If ($sRegistryName = $sName) And StringInStr(RegRead($sRegistryKey & '\', $sRegistryName), $sFilePath, $STR_NOCASESENSEBASIC) Then $vReturn += RegDelete($sRegistryKey & '\', $sName) EndIf $iInstance += 1 WEnd If $bIsInstall Then $vReturn = RegWrite($sRegistryKey & '\', $sName, 'REG_SZ', $sFilePath & ' ' & $sCommandline) > 0 Else $vReturn = $vReturn > 0 EndIf Return $vReturn EndFunc ;==>__StartupRegistry_UninstallExample 1: #include '_Startup.au3' Example() Func Example() _StartupFolder_Install() ; Add the running EXE to the Current Users startup folder. ShellExecute(@StartupDir & '\') Sleep(5000) _StartupFolder_Uninstall() ; Remove the running EXE from the Current Users startup folder. EndFunc ;==>ExampleExample 2: #include '_Startup.au3' Example() Func Example() _StartupRegistry_Install() ; Add the running EXE to the Current Users Run registry key. Sleep(5000) _StartupRegistry_Uninstall() ; Remove the running EXE from the Current Users Run registry key. EndFunc ;==>ExampleAll of the above has been included in a ZIP file. Startup.zipPrevious: 1447+ downloads.1 point
-
Baroque AutoIt3 Code Formatter - 08/15/2013
czardas reacted to jaberwacky for a topic
This will format your au3 source. It removes spaces between braces. It inserts spaces between operators and after commas. Tidy will do this and yes I have used Tidy. But Tidy also removes extra whitespace which misaligns sections of code which I have aligned particularly. I did ask for this feature in Tidy but for some reason or another it wasn't put in there. You can uncheck to not tidy the spaces but also doesn't insert spaces in the aforementioned areas. I made an au3 parser because I wanted the learning experience. It was also fun. There is the official tidy which does more than this but this won't strip away spaces and plus I plan add more features which would not be useful to the majority of AutoIt users. Thus, I made the Baroque AutoIt3 Parser. N.B. that this is never intended to replace the official Tidy. I could 1) never fill Jos' shoes and 2) never compete with flex and yacc -- I'm pretty sure those are used in Tidy. Just use this as either a curio, a discussion springboard or a learning experience. Updated: Works with ternary syntax now. #include-once Func baroque_autoit_parser(Const $au3_source) #region ; Tokens Local Const $space = ' ' Local Const $double_quote = Chr(34) Local Const $single_quote = Chr(39) Local Const $underscore = '_' Local Const $hash = '#' Local Const $comma = ',' Local Const $semicolon = ';' Local Const $equal = '=' Local Const $ampersand = '&' Local Const $plus = '+' Local Const $minus = '-' Local Const $asterisk = '*' Local Const $forward_slash = '/' Local Const $caret = '^' Local Const $open_bracket = '[' Local Const $close_bracket = ']' Local Const $open_parens = '(' Local Const $close_parens = ')' Local Const $open_angle_bracket = '<' Local Const $close_angle_bracket = '>' Local Const $question = '?' Local Const $colon = ':' #endregion Local Const $au3_length = StringLen($au3_source) Local $formatted_au3 = '' Local $within_double_quote_string = False Local $within_single_quote_string = False Local $within_comment = False Local $within_preprocessor = False Local $token = '' Local $previous_token = '' Local $next_token = '' Local $comment_token = '' Local $tmp_token = '' Local $line = 0 For $i = 1 To $au3_length $token = StringMid($au3_source, $i, 1) $previous_token = StringMid($au3_source, $i - 1, 1) $next_token = StringMid($au3_source, $i + 1, 1) ; increment the line count Switch $token Case @LF $line += 1 EndSwitch ; This switch structure tries to determine if the formatter is currently in a string section. Switch $token Case $double_quote $within_double_quote_string = Not $within_double_quote_string Case $single_quote $within_single_quote_string = Not $within_single_quote_string EndSwitch ; This switch structure tries to determine if the formatter is currently in a comment section. Switch $token Case $semicolon Switch (Not $within_double_quote_string) And (Not $within_single_quote_string) And (Not $within_comment) Case True $within_comment = True Switch $i <> 1 ; skip the semicolon on the first line Case True Switch $previous_token <> $space And $previous_token <> @LF Case True $token = $space & $token EndSwitch Switch $next_token <> $space Case True $token &= $space EndSwitch EndSwitch ; skip ahead until EOL For $j = $i + 1 To $au3_length $comment_token = StringMid($au3_source, $j, 1) Switch $comment_token Case @LF $within_comment = False $i = $j ExitLoop Case Else $token &= $comment_token EndSwitch Next EndSwitch Case $hash Select Case StringMid($au3_source, $i + 1, 14) = "comments-start" $within_comment = True ; skip to end of line For $j = $i + 1 To $au3_length Local $tmp_token = StringMid($au3_source, $j, 1) Switch $tmp_token Case @LF ExitLoop Case Else $i += 1 $token &= $tmp_token EndSwitch Next Case StringMid($au3_source, $i + 1, 2) = "cs" $within_comment = True ; skip to end of line For $j = $i + 1 To $au3_length Local $tmp_token = StringMid($au3_source, $j, 1) Switch $tmp_token Case @LF ExitLoop Case Else $i += 1 $token &= $tmp_token EndSwitch Next Case StringMid($au3_source, $i + 1, 12) = "comments-end" $within_comment = False ; skip to end of line For $j = $i + 1 To $au3_length Local $tmp_token = StringMid($au3_source, $j, 1) Switch $tmp_token Case @LF ExitLoop Case Else $i += 1 $token &= $tmp_token EndSwitch Next Case StringMid($au3_source, $i + 1, 2) = "ce" $within_comment = False ; skip to end of line For $j = $i + 1 To $au3_length Local $tmp_token = StringMid($au3_source, $j, 1) Switch $tmp_token Case @LF ExitLoop Case Else $i += 1 $token &= $tmp_token EndSwitch Next EndSelect EndSwitch ; This switch structure is where the formatting happens. Switch (Not $within_double_quote_string) And (Not $within_single_quote_string) And (Not $within_comment) Case True Switch $token Case $space Select Case $next_token = $comma ContinueLoop EndSelect Case $comma Select Case $previous_token = $space And $next_token <> $space $token = $token & $space Case $next_token <> $space $token = $token & $space EndSelect Case $equal Select Case $next_token = $equal ; if == $jump_two_tokens = StringMid($au3_source, $i + 2, 1) Select Case $previous_token <> $space And $jump_two_tokens <> $space ; if "==" $token = $space & $equal & $equal & $space $i += 1 Case $previous_token = $space And $jump_two_tokens <> $space ; if "== " $token = $equal & $equal & $space $i += 1 Case $previous_token <> $space And $jump_two_tokens = $space ; if ; " ==" $token = $space & $equal & $equal $i += 1 EndSelect Case $next_token <> $equal And $previous_token <> $open_angle_bracket And $previous_token <> $close_angle_bracket ; '=' Select Case $previous_token <> $space And $next_token <> $space $token = $space & $token & $space Case $previous_token <> $space And $next_token = $space $token = $space & $token Case $previous_token = $space And $next_token <> $space $token = $token & $space EndSelect EndSelect Case $semicolon Local $temp_token = '' For $i =($i + 1) To ($au3_length - 1) $temp_token = StringMid($au3_source, $i, 1) Switch $temp_token Case $space $i += 1 ContinueLoop Case Not $space ExitLoop EndSwitch Next Select Case $previous_token <> $space And $next_token <> $space ; ";" $token = $space & $token & $space Case $previous_token = $space And $next_token <> $space ; " ;" $token = $token & $space Case $previous_token <> $space And $next_token = $space ; "; " $token = $space & $token Case $previous_token <> $space And $previous_token <> @LF And $next_token <> $space $token = $space & $token & $space EndSelect Case $ampersand, $plus, $minus, $asterisk, $forward_slash, $caret Switch $next_token <> $equal Case True Select Case $previous_token <> $space And $next_token <> $space $token = $space & $token & $space Case $previous_token = $space And $next_token <> $space $token = $token & $space Case $previous_token <> $space And $next_token = $space $token = $space & $token EndSelect Case False $jump_two_tokens = StringMid($au3_source, $i + 2, 1) Select Case $previous_token = $space And $jump_two_tokens = $space $token = $token & $equal $i += 1 Case $previous_token <> $space And $jump_two_tokens <> $space $token = $space & $token & $equal & $space $i += 1 Case $previous_token = $space And $jump_two_tokens <> $space $token = $token & $equal & $space $i += 1 Case $previous_token <> $space And $jump_two_tokens = $space $token = $space & $token & $equal $i += 1 EndSelect EndSwitch Case $open_angle_bracket Switch $within_preprocessor Case True Select Case $previous_token <> $space $token = $space & $token EndSelect ; skip all of the spaces For $j = $i + 1 To $au3_length $tmp_token = StringMid($au3_source, $j, 1) Select Case $tmp_token = $space $i += 1 Case $tmp_token = $close_angle_bracket $within_preprocessor = False ExitLoop Case $tmp_token <> $space $i += 1 $token &= $tmp_token EndSelect Next EndSwitch Select Case $next_token = $equal $jump_two_tokens = StringMid($au3_source, $i + 2, 1) Select Case $previous_token <> $space And $jump_two_tokens <> $space $token = $space & $token & $next_token & $space $i += 1 Case $previous_token <> $space And $jump_two_tokens = $space $token = $space & $token & $next_token $i += 1 Case $previous_token = $space And $jump_two_tokens <> $space $token = $token & $next_token & $space $i += 1 EndSelect Case $next_token = $close_angle_bracket $jump_two_tokens = StringMid($au3_source, $i + 2, 1) Select Case $previous_token <> $space And $jump_two_tokens <> $space $token = $space & $token & $next_token & $space $i += 1 Case $previous_token <> $space And $jump_two_tokens = $space $token = $space & $token & $next_token $i += 1 Case $previous_token = $space And $jump_two_tokens <> $space $token = $token & $next_token & $space $i += 1 EndSelect EndSelect Case $close_angle_bracket Select Case $next_token = $equal $jump_two_tokens = StringMid($au3_source, $i + 2, 1) Select Case $previous_token <> $space And $jump_two_tokens <> $space $token = $space & $token & $next_token & $space $i += 1 Case $previous_token <> $space And $jump_two_tokens = $space $token = $space & $token & $next_token $i += 1 Case $previous_token = $space And $jump_two_tokens <> $space $token = $token & $next_token & $space $i += 1 EndSelect EndSelect Case $open_parens Select Case $next_token = $space $i += 1 EndSelect Case $close_parens Select Case $previous_token = $space And StringMid($au3_source, $i - 2, 1) <> $open_parens $formatted_au3 = StringTrimRight($formatted_au3, 1) EndSelect Case $open_bracket Select Case $next_token = $space $i += 1 EndSelect Case $close_bracket Select Case $previous_token = $space And StringMid($au3_source, $i - 2, 1) <> $open_bracket $formatted_au3 = StringTrimRight($formatted_au3, 1) EndSelect Case $question, $colon Select Case $previous_token <> $space And $next_token <> $space $token = $space & $token & $space Case $previous_token = $space And $next_token <> $space $token = $token & $space Case $previous_token <> $space And $next_token = $space $token = $space & $token EndSelect Case $hash $within_preprocessor = True Select Case StringMid($au3_source, $i + 1, 12) = "include-once" ; skip to end of line For $j = $i + 1 To $au3_length $tmp_token = StringMid($au3_source, $j, 1) Switch $tmp_token Case @LF $within_preprocessor = False ExitLoop Case Else $i += 1 $token &= $tmp_token EndSwitch Next Case StringMid($au3_source, $i + 1, 14) = "AutoIt3Wrapper" ; skip to end of line For $j = $i + 1 To $au3_length Local $tmp_token = StringMid($au3_source, $j, 1) Switch $tmp_token Case @LF $within_preprocessor = False ExitLoop Case Else $i += 1 $token &= $tmp_token EndSwitch Next EndSelect EndSwitch EndSwitch $formatted_au3 &= $token Next Return $formatted_au3 EndFunc How to use this: #include <Baroque AutoIt Parser.au3> Global Const $au3_source = FileRead([FILEPATH]) Global Const $formatted_autoit = baroque_autoit_parser($au3_source) ; Write $formatted_autoit to a file, the clipboard, to the console, etc. Turn this hot ratchet mess: #include-once #include<TEST.au3> #include< TEST.au3> #include<TEST.au3 > #include< TEST.au3 > ;COMMENT LINE! Nothing on this line should be ; formatted. $test=1+2-3*4/5 ; COMMENT LINE! Nothing on this line should be formatted. $test=$test>=$test ; COMMENT LINE! Nothing on this line should be formatted. $test=$test<=$test ;COMMENT LINE! Nothing on this line should be formatted. $test=$test-=$test Local $sSource=$vExpression?True:False ConsoleWrite(baroque_autoit_parser($sSource)&@CRLF) $test="This string 'should' ""remain"" untouched. ; $test=1+2-3*4/5 $test=$test-=$test $test=$test+=$test $test=$test/=$test" $test="This string 'should' remain untouched. ; $test=$test>=$test $test=$test-=$test $test=$test+=$test $test=$test/=$test" $test="This string 'should' remain untouched. ; $test=$test<=$test $test=$test-=$test $test=$test+=$test $test=$test/=$test" $test="This string 'should' remain untouched. ; $test=$test+=$test $test=$test-=$test $test=$test+=$test $test=$test/=$test" $test = 1 + 2 - 3 * 4 / 5 $test=1+2-3*4/5 $test= 1+ 2- 3* 4/ 5 $test =1 +2 -3 *4 /5 $test = $test <> $test $test = $test<>$test $test = $test<> $test $test = $test <>$test $test = $test >= $test $test=$test>=$test $test= $test>= $test $test =$test >=$test $test = $test <= $test $test=$test<=$test $test= $test<= $test $test =$test <=$test $test = $test += $test $test=$test+=$test $test= $test+= $test $test =$test +=$test $test = $test -= $test $test=$test-=$test $test= $test-= $test $test =$test -=$test $test = $test *= $test $test=$test*=$test $test= $test*= $test $test =$test *=$test $test = $test /= $test $test=$test/=$test $test= $test/= $test $test =$test /=$test $fEnd=TimerDiff($t) + 1000 $fEnd=TimerDiff($t ) -1000 $fEnd=TimerDiff( $t)* 1000 $fEnd=TimerDiff( $t )/1000 _MyFunction( $1 , $2 , $3 , ... ) _MyFunction( $1 , _ $2 , _ $3 , _ ... ) Global Const $TEST=$TEST;$TEST=0,$TEST=0 Global Const $TEST =$TEST ;$TEST =0,$TEST= 0 Global Const $TEST= $TEST; $TEST= 0,$TEST =0 Global Const $TEST= $TEST; $TEST= 0 ,$TEST = 0 Global Const $TEST= $TEST; $TEST= 0, $TEST =0 MsgBox ( 0, "TEST","") MsgBox (0, "TEST"," " ) MsgBox ( 0, "TEST","""" ) Global COnst $TEST[10]=[ ""," ",' ' ,'' , '', '' ] Global COnst $TEST[10] =[ "a","s","d" ,"e" , "f", "g" ] Global COnst $TEST[10]= [ '1','2','3' ,'4' , '5', '6' ] If $TEST==$TEST Then $TEST If $TEST ==$TEST Then $TEST If $TEST== $TEST Then $TEST Into this: #include-once #include <TEST.au3> #include <TEST.au3> #include <TEST.au3> #include <TEST.au3> ; COMMENT LINE! Nothing on this line should be ; formatted. $test=1+2-3*4/5 ; COMMENT LINE! Nothing on this line should be formatted. $test=$test>=$test ; COMMENT LINE! Nothing on this line should be formatted. $test=$test<=$test ; COMMENT LINE! Nothing on this line should be formatted. $test=$test-=$test Local $sSource = $vExpression ? True : False ConsoleWrite(baroque_autoit_parser($sSource) & @CRLF) $test = "This string 'should' ""remain"" untouched. ; $test=1+2-3*4/5 $test=$test-=$test $test=$test+=$test $test=$test/=$test" $test = "This string 'should' remain untouched. ; $test=$test>=$test $test=$test-=$test $test=$test+=$test $test=$test/=$test" $test = "This string 'should' remain untouched. ; $test=$test<=$test $test=$test-=$test $test=$test+=$test $test=$test/=$test" $test = "This string 'should' remain untouched. ; $test=$test+=$test $test=$test-=$test $test=$test+=$test $test=$test/=$test" $test = 1 + 2 - 3 * 4 / 5 $test = 1 + 2 - 3 * 4 / 5 $test = 1 + 2 - 3 * 4 / 5 $test = 1 + 2 - 3 * 4 / 5 $test = $test <> $test $test = $test <> $test $test = $test <> $test $test = $test <> $test $test = $test >= $test $test = $test >= $test $test = $test >= $test $test = $test >= $test $test = $test <= $test $test = $test <= $test $test = $test <= $test $test = $test <= $test $test = $test += $test $test = $test += $test $test = $test += $test $test = $test += $test $test = $test -= $test $test = $test -= $test $test = $test -= $test $test = $test -= $test $test = $test *= $test $test = $test *= $test $test = $test *= $test $test = $test *= $test $test = $test /= $test $test = $test /= $test $test = $test /= $test $test = $test /= $test $fEnd = TimerDiff($t) + 1000 $fEnd = TimerDiff($t) - 1000 $fEnd = TimerDiff($t) * 1000 $fEnd = TimerDiff($t) / 1000 _MyFunction($1, $2, $3, ...) _MyFunction($1, _ $2, _ $3, _ ...) Global Const $TEST = $TEST ; $TEST=0,$TEST=0 Global Const $TEST = $TEST ; $TEST =0,$TEST= 0 Global Const $TEST = $TEST ; $TEST= 0,$TEST =0 Global Const $TEST = $TEST ; $TEST= 0 ,$TEST = 0 Global Const $TEST = $TEST ; $TEST= 0, $TEST =0 MsgBox (0, "TEST", "") MsgBox (0, "TEST", " ") MsgBox (0, "TEST", """") Global COnst $TEST[10] = ["", " ", ' ', '', '', ''] Global COnst $TEST[10] = ["a", "s", "d", "e", "f", "g"] Global COnst $TEST[10] = ['1', '2', '3', '4', '5', '6'] If $TEST == $TEST Then $TEST If $TEST == $TEST Then $TEST If $TEST == $TEST Then $TEST1 point -
vortex91, You can use a technique similar to the following to build the SQL statement. ; local $array[random(1,10,1)] ConsoleWrite('Creating table with ' & ubound($array) & ' columns' & @LF) local $sqlstr = 'create table [test] (' for $1 = 0 to ubound($array) - 1 $sqlstr &= 'Col' & stringformat('%03i',$1+1) & ',' Next $sqlstr = stringtrimright($sqlstr,1) $sqlstr &= ');' ConsoleWrite($sqlstr & @LF) Then use the following function to execute the SQL _SQLite_Exec (-1, $sqlstr) kylomas edit: additional info _SQLite_SQLiteExe creates an instance of SQLite, opens whatever DB you specify, executes your SQL then shuts down. If you are doing a one time thing you might do it this way. Presumably you will be doing more with the DB after creating it. The following is a working example of the code above. #include <sqlite.au3> ;---------------------------------------------------------------------------------- ; ; SQLite startup section ; ;---------------------------------------------------------------------------------- _SQLite_Startup() if @error then ConsoleWrite('SQLite cannot be loaded' & @LF) Exit endif OnAutoItExitRegister("_SQLite_ShutDown") local $db = @scriptdir & '\test.db3' local $hDB = _sqlite_open($db) if @error then ConsoleWrite('Cannot open DB = ' & $db & @LF) Exit endif OnAutoItExitRegister("_DbClose") ;---------------------------------------------------------------------------------- ; ; format SQL and create table ; ;---------------------------------------------------------------------------------- _sqlite_exec(-1,'drop table if exists [test];') local $array[random(1,10,1)] ConsoleWrite('Creating table with ' & ubound($array) & ' columns' & @LF) local $sqlstr = 'create table [test] (' for $1 = 0 to ubound($array) - 1 $sqlstr &= 'Col' & stringformat('%03i',$1+1) & ',' Next $sqlstr = stringtrimright($sqlstr,1) $sqlstr &= ');' ConsoleWrite($sqlstr & @LF) if _sqlite_exec($hDB,$sqlstr) <> $sqlite_ok then ConsoleWrite('Table create failed' & @LF) Exit EndIf ;---------------------------------------------------------------------------------- ; ; display the table definition ; ;---------------------------------------------------------------------------------- local $arows, $icols, $irows, $str = '' _SQLite_GetTable2d(-1,'PRAGMA table_info(test);',$arows, $irows, $icols) _arraydisplay($arows) Func _DbClose() _SQLite_Close($hDB) EndFunc ;==>_DbClose1 point
-
Wombat, I have a perfectly good Y chromosome I would have you know! M231 point
-
_Startup() - Create Startup entries in the Startup Folder or Registry.
BinaryBrother reacted to guinness for a topic
No problem, thanks for the appreciation.1 point -
1 point
-
I don't really understand your problem. How about this then. While 1 Sleep(1000) If StringRight(String(@MIN), 1) == '0' Then ; every 10 minutes run your script ShellExecute('path\to\your\script.exe') SoundPlay(@WindowsDir & "\media\tada.wav", 1) Do Sleep(1000) Until StringRight(String(@MIN), 1) <> '0';wait until it is no longer on the ten minute mark, to avoid spwning more processes. EndIf WEnd1 point
-
1 point
-
Because it never leaves your loop. Have 1 loop and put everything in it.1 point
-
Yes of course. Don't divulge. Say hello to the participants for me.1 point
-
You want to make a program that stays running so it can start another that doesn't? Doesn't make sense. Just add loop that checks the time and conditionally runs your functions based on it. Or use task schedualer1 point
-
Because this is how to use WM_DROPFILES with the current beta... #include <APIConstants.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <WinAPIEx.au3> Global $__aDropFiles = 0 Example() Func Example() Local $hGUI = GUICreate('', 500, 500, -1, -1, -1, $WS_EX_ACCEPTFILES) ; Create a label that is transparent which will accept 'drop' events. GUICtrlCreateLabel('', 0, 0, 500, 500) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES') GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_DROPPED If $__aDropFiles[0] > 0 Then _ArrayDisplay($__aDropFiles) EndIf EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example Func WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $lParam Switch $iMsg Case $WM_DROPFILES Local Const $aReturn = _WinAPI_DragQueryFileEx($wParam) If UBound($aReturn) Then $__aGUIDropFiles = $aReturn Else Local Const $aError[1] = [0] $__aGUIDropFiles = $aError EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_DROPFILES1 point
-
Try waiting for the window to be active. WinWaitActive()1 point
-
I just forgot to mention that this code won't work if the M0 line is the very first line in the file. If that is an issue, just add a question mark in the pattern after the first capture, like that: Func Add_M47() Local $ReadInput1 = GUICtrlRead($Input1) Local $sText = FileRead($ReadInput1) Local $sTextM47 = Execute("'" & StringRegExpReplace($sText, "(?m)(N\d+M\d+\R)?N(\d+)(M0\R)", "$1N' & StringFormat('%04.1f', $2 - 0.9) & 'M47" & @CRLF & "N$2$3", 1) & "'") MsgBox(0, "Only first M47 added", $sTextM47) ; do whatever you want with the modified text EndFunc1 point
-
BartDog, Use the $BS_PUSHLIKE style on a checkbox control- then it stays pushed until you push it again: #include <GUIConstantsEx.au3> #include <Constants.au3> #include <ButtonConstants.au3> $hGUI = GUICreate("Test", 500, 500) GUICtrlCreateButton("Normal", 10, 10, 80, 30) GUICtrlCreateCheckBox("PushLike", 10, 50, 80, 30, $BS_PUSHLIKE) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd How is that? M231 point
-
DrLarch, If you want multiple dropped files we need to go another route - look for the <<<<<<<< lines: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListBox.au3> #include <Array.au3> ;Global $a_SelectedItems ; No need to declare as Global - we only need it as Local within the function <<<<<<<<< Global $aDrop_List ; Declare array to hold dropped items <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Opt("GUIOnEventMode", 1) $hGUI = GUICreate("Send File to Fax", 362, 223, 258, 162, Default, $WS_EX_ACCEPTFILES) ; You need the extended style here <<<<<<<< GUISetOnEvent($GUI_EVENT_CLOSE, "hGUIClose") $cList = GUICtrlCreateList("", 0, 0, 361, 145, $LBS_EXTENDEDSEL) ; Permit multiple selections <<<<<<<<<<<<<<<<<< $bSend = GUICtrlCreateButton("Fax!", 280, 184, 57, 28) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") GUICtrlSetOnEvent(-1, "bSendClick") $fNumber = GUICtrlCreateInput("", 128, 184, 145, 28) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") ;GUICtrlSetOnEvent(-1, "fNumberChange") $Label = GUICtrlCreateLabel("Fax Number:", 18, 187, 105, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") ;GUICtrlSetOnEvent(-1, "LabelClick") $bDelete = GUICtrlCreateButton("Delete Selected", 128, 152, 105, 25) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetOnEvent(-1, "bDeleteClick") $bClear = GUICtrlCreateButton("Clear All", 240, 152, 105, 25) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetOnEvent(-1, "bClearClick") $Icon = GUICtrlCreateIcon("C:\Windows\System32\shell32.dll", -106, 48, 150, 32, 32) $cDrop_Dummy = GUICtrlCreateDummy() GUICtrlSetOnEvent(-1, "_On_Drop") GUISetState(@SW_SHOW) ; Register $WM_DROPFILES function to detect drops anywhere on the GUI <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUIRegisterMsg(0x233, "On_WM_DROPFILES") ; $WM_DROPFILES While 1 Sleep(10) WEnd Func _On_Drop() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< For $i = 1 To $aDrop_List[0] GUICtrlSetData($cList, $aDrop_List[$i]) Next EndFunc ;==>_On_Drop Func bDeleteClick() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Local $a_SelectedItems = _GUICtrlListBox_GetSelItems($cList) For $i = $a_SelectedItems[0] To 1 Step -1 _GUICtrlListBox_DeleteString($cList, $a_SelectedItems[$i]) Next EndFunc ;==>bDeleteClick Func bClearClick() GUICtrlSetData($cList, "") EndFunc ;==>bClearClick Func bSendClick() $FileCount = _GUICtrlListBox_GetCount($cList) Global $FileList[$FileCount + 1] For $i = 0 To $FileCount $FileList[$i] = _GUICtrlListBox_GetText($cList, $i) Next _ArrayDelete($FileList, $i) _ArrayDisplay($FileList) bClearClick() EndFunc ;==>bSendClick Func FaxChange() MsgBox(0, "Test", "Test") EndFunc ;==>FaxChange Func hGUIClose() Exit EndFunc ;==>hGUIClose ; React to items dropped on the GUI <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Func On_WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam) ; Credit to ProgAndy for DLL calls #forceref $hWnd, $iMsg, $lParam Local $iSize, $pFileName ; Get number of files dropped Local $aRet = DllCall("shell32.dll", "int", "DragQueryFileW", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 0) ; Reset array to correct size Global $aDrop_List[$aRet[0] + 1] = [$aRet[0]] ; And add item names For $i = 0 To $aRet[0] - 1 $aRet = DllCall("shell32.dll", "int", "DragQueryFileW", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0) $iSize = $aRet[0] + 1 $pFileName = DllStructCreate("wchar[" & $iSize & "]") DllCall("shell32.dll", "int", "DragQueryFileW", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $iSize) $aDrop_List[$i + 1] = DllStructGetData($pFileName, 1) $pFileName = 0 Next ; Send the count to trigger the drop function in the main loop GUICtrlSendToDummy($cDrop_Dummy, $aDrop_List[0]) EndFunc ;==>On_WM_DROPFILES The multiple delete is pretty easy as you can see. Doing the same thing with a ListView (which is a very different animal to a ListBox) is not too difficult as the principles are the same - why not give it a go and see how you get on. M231 point