Leaderboard
Popular Content
Showing content with the highest reputation on 10/26/2018 in all areas
-
Tidy major Update (2-Nov-2018)
FrancescoDiMuro and one other reacted to Jos for a topic
I am reaching out to you all to test this version of Tidy to see whether that works on your scripts and report back your finding. Changes in this version: Leave inline comments on the original position when the line is tidied, where possible. Handle None Breaking Spaces (NBS) for Ascii and UTF8 files: NBS characters within the leading & trailing whitespace and inside the code will be replaced by a regular space to allow tidy to properly tidy the code. NBS characters in a literal string will not be replaced as they are presumably there for a reason. NBS characters inside an inline comment will be left alone too. Added support for directive: #Tidy_ILC_Pos=nn (See below for details) Replaced /Skip_Commentblock & /scb for /Tidy_Comment block & /tcb and made the default not to tidy comment blocks, as they are frequently used for simple documentation which would making tidying impossible. /tcb=0 =>only indent the whole commentblock (default) /tcb or /tcb=1 =>Tidy inside commentblock /tcb=-1 =>leave whole commentbock alone Added support for the following tidy.ini settings: #-->Define the TabSize size tabsize=4 #--> Tidy commentblock 1=Tidy, 0=Do not tidy default=0 Tidy_commentblock=0 #-->Define the default column for inline comments, 0=keep current position icl_pos=0 Changed the logic for the comment part of #directives. See last example for an explanation Fixed issue in "Variable proper" function, sometimes not updating the variable to the proper caps. Changed the program to CUI to show console output when ran from CMD prompt. Changed the returncode to -1 when no changes are made. A change in AutoIt3Wrapper will test for this and show as such. Updated support for inline comments: One of the items that has been on my wish-/todolist for a long time was to leave inline comments as they were, instead of removing all whitespace between statement and inline comment: For example that this untidied code: global $A=1 if $a=1 then ; test $a $a=2 ; Set $a endif ; end test The current production version will change that to: Global $A = 1 If $a = 1 Then ; test $a $a = 2 ; Set $a EndIf ; end test The new Beta version will change that to: (leaving the Comment start column the same as it was) Global $A = 1 If $A = 1 Then ; test $a $A = 2 ; Set $a EndIf ; end test Tidy.Ini optional change Tidy will determine the position of the inline comment by using the tabchar & tabsize parameter from Tidy.ini: [ProgramSettings] * * * Indent 0 = Tabs >0 = Number of Space tabchar=0 tabsize=4 #-->Define the default column for inline comments, 0=keep current position icl_pos=0 #--> Tidy commentblock 0=only indent the whole commentblock (default=0) # 1=Tidy inside commentblock # -1=leave whole commentbock alone Tidy_commentblock=0 When not provided in the INI it will be defaulted to Using Tabs with a size of 4. When running from within SciTE, a warning is shown in the SciTE console, when they deviate from the SciTE Settings for: use.tabs=1 indent.size=4 It could help while testing to use Winmerge to see what exactly was changed during the Tidy run by adding this to Tidy.ini: ShowDiffPgm = """C:\Program Files (x86)\WinMerge\winmergeu.exe" "%new%" "%old%""" Support for directive #Tidy_ILC_Pos=nn Tidy will keep inline comment on their original position, but this can be overridden by the directive: #Tidy_ILC_Pos=nn When nn is greater than 0, Tidy will use the defined number as the Inline comment start column going forward. When nn= 0 then use the old ILC column. When nn= -1 then strip the spaces between Code and ILC (Old Tidy behavior) EG Original Tidied script: Global Enum _ $ADO_ERR_SUCCESS, _ ; No Error $ADO_ERR_GENERAL, _ ; General - some ADO Error - Not classified type of error $ADO_ERR_ENUMCOUNTER ; just for testing Global Const $ADO_EXT_DEFAULT ; default Extended Value Global Const $ADO_EXT_PARAM1 ; Error Occurs in Parameter #1 Global Const $ADO_EXT_PARAM2 ; Error Occurs in Parameter #2 Global Const $ADO_EXT_PARAM3 ; Error Occurs in Parameter #3 Now with new directive added to line up the inline comments: #Tidy_ILC_Pos=40 Global Enum _ $ADO_ERR_SUCCESS, _ ; No Error $ADO_ERR_GENERAL, _ ; General - some ADO Error - Not classified type of error $ADO_ERR_ENUMCOUNTER ; just for testing Global Const $ADO_EXT_DEFAULT ; default Extended Value Global Const $ADO_EXT_PARAM1 ; Error Occurs in Parameter #1 Global Const $ADO_EXT_PARAM2 ; Error Occurs in Parameter #2 Global Const $ADO_EXT_PARAM3 ; Error Occurs in Parameter #3 Example Setting the new column to different values and back to original (0) Before Tidy run: #Tidy_ILC_Pos=30 Global Enum _ $ADO_ERR_SUCCESS, _ ; No Error $ADO_ERR_GENERAL, _ ; General - some ADO Error - Not classified type of error $ADO_ERR_ENUMCOUNTER ; just for testing #Tidy_ILC_Pos=50 Global Const $ADO_EXT_DEFAULT ; default Extended Value Global Const $ADO_EXT_PARAM1 ; Error Occurs in Parameter #1 Global Const $ADO_EXT_PARAM2 ; Error Occurs in Parameter #2 Global Const $ADO_EXT_PARAM3 ; Error Occurs in Parameter #3 Global Const $ADO_EXT_PARAM4 ; Error Occurs in Parameter #4 #Tidy_ILC_Pos=0 Global Const $ADO_EXT_PARAM5 ; Error Occurs in Parameter #5 Global Const $ADO_EXT_PARAM6 ; Error Occurs in Parameter #6 Global Const $ADO_EXT_INTERNALFUNCTION ; Error Related to internal Function - should not happend - UDF Developer make something wrong ??? Global Const $ADO_EXT_ENUMCOUNTER ; just for testing After Tidy run: #Tidy_ILC_Pos=30 Global Enum _ $ADO_ERR_SUCCESS, _ ; No Error $ADO_ERR_GENERAL, _ ; General - some ADO Error - Not classified type of error $ADO_ERR_ENUMCOUNTER ; just for testing #Tidy_ILC_Pos=50 Global Const $ADO_EXT_DEFAULT ; default Extended Value Global Const $ADO_EXT_PARAM1 ; Error Occurs in Parameter #1 Global Const $ADO_EXT_PARAM2 ; Error Occurs in Parameter #2 Global Const $ADO_EXT_PARAM3 ; Error Occurs in Parameter #3 Global Const $ADO_EXT_PARAM4 ; Error Occurs in Parameter #4 #Tidy_ILC_Pos=0 Global Const $ADO_EXT_PARAM5 ; Error Occurs in Parameter #5 Global Const $ADO_EXT_PARAM6 ; Error Occurs in Parameter #6 Global Const $ADO_EXT_INTERNALFUNCTION ; Error Related to internal Function - should not happend - UDF Developer make something wrong ??? Global Const $ADO_EXT_ENUMCOUNTER ; just for testing Example what happens with the different directives Before Tidy run: #Tidy_ILC_Pos=40 #UnknowDirective test ; comment ; Know directives/preprocessor Table -> au3.keywords.properties ;~ au3.keywords.special=#endregion #forcedef #forceref #ignorefunc #pragma #region #Region test ;test ; comment there not enough spaces, so simply copy Eveything after #Region to #EndRegion #EndRegion test ; will be replaced #Region test ; comment there are 4 spaces after #region so can line it up with EndRegion #EndRegion test ; will be replaced #forcedef aaaaaa ; comment - linedup at Pos 40 #pragma compile(UPX, False) ; comment - linedup at Pos 40 ;~ au3.keywords.preprocessor=#ce #comments-end #comments-start #cs #include #include-once \ ;~ #notrayicon #onautoitstartregister #requireadmin #NoTrayIcon ; comment - linedup at Pos 40 #RequireAdmin ; comment - linedup at Pos 40 #OnAutoItStartRegister "test" ; comment - linedup at Pos 40 ; -- Special treatment in au3lexer #cs test ; comment Start - copy all after #CS to #CE #ce test ; will be replaced #comments-Start ; comment Start copy all after #CS to #CE #comments-end ; will be replaced ; Knows Direcitves/Special table -> autoit3wrapper.keywords.properties #AutoIt3Wrapper_Add_Constants=n ; comment - linedup at Pos 40 #Au3Stripper_Ignore_Variables ; comment - linedup at Pos 40 #Tidy_Parameters=1 ; comment - linedup at Pos 40 After Tidy run: #Tidy_ILC_Pos=40 #UnknowDirective test ; comment ; Know directives/preprocessor Table -> au3.keywords.properties ;~ au3.keywords.special=#endregion #forcedef #forceref #ignorefunc #pragma #region #Region test ;test ; comment there not enough spaces, so simply copy Eveything after #Region to #EndRegion #EndRegion test ;test ; comment there not enough spaces, so simply copy Eveything after #Region to #EndRegion #Region test ; comment there are 4 spaces after #region so can line it up with EndRegion #EndRegion test ; comment there are 4 spaces after #region so can line it up with EndRegion #forcedef aaaaaa ; comment - linedup at Pos 40 #pragma compile(UPX, False) ; comment - linedup at Pos 40 ;~ au3.keywords.preprocessor=#ce #comments-end #comments-start #cs #include #include-once \ ;~ #notrayicon #onautoitstartregister #requireadmin #NoTrayIcon ; comment - linedup at Pos 40 #RequireAdmin ; comment - linedup at Pos 40 #OnAutoItStartRegister "test" ; comment - linedup at Pos 40 ; -- Special treatment in au3lexer #cs test ; comment Start - copy all after #CS to #CE #ce test ; comment Start - copy all after #CS to #CE #comments-start ; comment Start copy all after #CS to #CE #comments-end ; comment Start copy all after #CS to #CE ; Knows Direcitves/Special table -> autoit3wrapper.keywords.properties #AutoIt3Wrapper_Add_Constants=n ; comment - linedup at Pos 40 #Au3Stripper_Ignore_Variables ; comment - linedup at Pos 40 #Tidy_Parameters=1 ; comment - linedup at Pos 40 I like to thank @mLipok for the testing/ideas/questions during the development of this change. Jos2 points -
Hi, It appears that my initial assumption that a GUI with a card table and a deck of cards was automatically game-related was not correct. The software involved is a calculator for specific circumstances and does not "play" poker as such. So I am reopening the thread. M23 P.S. The OP sent a polite PM explaining the situation and was patient enough to answer the various questions I posed to assure myself that this was not a "game" question. A perfect example of what should be done when a thread has been, in the OP's eyes, unjustly closed. Much more effective than the invective-laced diatribes we usually get - a point to ponder for some others, I feel.2 points
-
VLC Mover -- moves VLC to different monitor when playing certain files
coffeeturtle and one other reacted to Bilgus for a topic
I made this application at the behest of another user because it sounded like a really cool idea. I've been using it for a little over 7 months and I really like it. After Compiling: If you want to use it as a pass through you'll need to name the script Vlc.exe and the original vlc.exe to Vlc_Orig.exe. On first run it will create a settings.ini with default settings and pop up the settings dialog Running VLC.exe again only runs the script passes on the new commandline and exits the script the previous script stays running... Once you close the VLC window after a few seconds a pop up will appear F1- Help, F4 - settings, ESC - Quit without saving DEFAULTS TO: [Config] CloseOnInactive=0 MaximizeOnActivate=0 IgnoreFilesLessThanMB=0 KeyDelayMS=100 KeyDownDelayMS=50 ExecName=VLC_Orig.exe ActiveWindowCoords=0 InactiveWindowCoords=0 ExecOnActive= ExecOnInactive= KeysOnActivate=f KeysOnInactive= FileTypes=mp4,avi,mkv,wmv WindowName=VLC media player WindowTextFallback=VLC (Direct3D output) ;------------------------------------------------ [Config] CloseOnInactive=0 ;1 - Closes the vlc_orig.exe when the video ends MaximizeOnActivate=0 ;1 - Maximizes window when video is detected IgnoreFilesLessThanMB=0 ;0-1000x?? - Passthrough Ignores files less than this KeyDelayMS=100 KeyDownDelayMS=50 Exec_Name=VLC_Orig.exe ActiveWindowCoords=0 ;- moves window to this position on video stop 0 ignores or format 0,0,1000,1000 => x,y,w,h InactiveWindowCoords=0 ;- moves window to this position on video stop 0 ignores or format 0,0,1000,1000 => x,y,w,h ExecOnActive= ;execute this file when video is detected ExecOnInactive= ;execute this file when when video stops KeysOnActivate=f ;-keys to press when video is detected KeysOnInactive= ;-keys to press when video stops FileTypes=mp4,avi,mkv,wmv ;-Comma separated list of valid video files WindowName=VLC media player ; WindowText_Fallback=VLC (Direct3D output) ;if valid ext not found fallback to looking for windowname and this text If you don't want to use it as a pass through you'll probably need to change it a bit to do what you want VlcMover.ico #Region ;**** Directives created by AutoIt3Wrapper_GUI **** ;;#AutoIt3Wrapper_Icon=VlcMover.ico #AutoIt3Wrapper_Outfile=VLC86.exe #AutoIt3Wrapper_Outfile_x64=VLC64.exe #AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Global $gsINI_PATH = @AppDataDir & "\" & @ScriptName & "_PassThrough.ini" ;Needs to be in @AppDataDir to have write access Global Const $gsINI_SEC = "Config" If FileExists(@ScriptDir & "\" & @ScriptName & "_PassThrough.ini") Then $gsINI_PATH = @ScriptDir & "\" & @ScriptName & "_PassThrough.ini" EndIf ;Override with ini file in script directory, probably not writeable though ;------------------------------------------------------------------------------------ ;GUIConstantsEx Global Const $GUI_EVENT_CLOSE = -0x3 Global Const $giACTWAIT = 5 ;wait #seconds for window to become active Global Enum $ge_bClose = 0, $ge_bMaximize, $ge_iMinSize, $ge_iKeyDelay, $ge_iKeyDnDelay, $ge_sExecute, _ $ge_sActCoord, $ge_sInACoord, $ge_sActExec, $ge_sInAExec, $ge_sSendKeysAct, $ge_sSendKeysInA, _ $ge_sFileTypes, $ge_sWndName, $ge_sWndFbTxt, $ge_LASTCFG Global Const $gaIniKeys[$ge_LASTCFG] = ["CloseOnInactive", "MaximizeOnActivate", "IgnoreFilesLessThanMB", "KeyDelayMS", _ "KeyDownDelayMS", "ExecName", "ActiveWindowCoords", "InactiveWindowCoords", "ExecOnActive", "ExecOnInactive", _ "KeysOnActivate", "KeysOnInactive", "FileTypes", "WindowName", "WindowTextFallback"] ;------------------------------------------------------------------------------------ Global $g_aCfg[$ge_LASTCFG] ;Holds settings for the program $g_aCfg[$ge_bClose] = (Cfg_Read($ge_bClose, 0) = 0 ? False : True) $g_aCfg[$ge_bMaximize] = (Cfg_Read($ge_bMaximize, 0) = 0 ? False : True) $g_aCfg[$ge_iMinSize] = Cfg_Read($ge_iMinSize, "0") ;Mb $g_aCfg[$ge_iKeyDelay] = Cfg_Read($ge_iKeyDelay, 100) $g_aCfg[$ge_iKeyDnDelay] = Cfg_Read($ge_iKeyDnDelay, 50) $g_aCfg[$ge_sExecute] = Cfg_Read($ge_sExecute, StringTrimRight(@ScriptName, 4) & "_Orig.exe") $g_aCfg[$ge_sActCoord] = Cfg_Read($ge_sActCoord, "0") $g_aCfg[$ge_sInACoord] = Cfg_Read($ge_sInACoord, "0") $g_aCfg[$ge_sSendKeysAct] = Cfg_Read($ge_sSendKeysAct, "f") ;(#Win)(+Shift)(arrow)(f)ull screen $g_aCfg[$ge_sSendKeysInA] = Cfg_Read($ge_sSendKeysInA, "") $g_aCfg[$ge_sActExec] = Cfg_Read($ge_sActExec, "") $g_aCfg[$ge_sInAExec] = Cfg_Read($ge_sInAExec, "") $g_aCfg[$ge_sFileTypes] = Cfg_Read($ge_sFileTypes, "mp4,avi,mkv,wmv") ;What files should be intercepted? $g_aCfg[$ge_sWndName] = Cfg_Read($ge_sWndName, "VLC media player") $g_aCfg[$ge_sWndFbTxt] = Cfg_Read($ge_sWndFbTxt, "VLC (Direct3D output)") ;------------------------------------------------------------------------------------ Global $gsMatchFileTypes = BuildFileTypes($g_aCfg[$ge_sFileTypes]) Global $gsMatchWnd = "[REGEXPTITLE:(?i)(" & $gsMatchFileTypes & ")(.*" & $g_aCfg[$ge_sWndName] & ")]" Global $gsMatchWnd_Fb = "[REGEXPTITLE:(?i)(.*" & $g_aCfg[$ge_sWndName] & ")]" ;Fallback Matching Global $gaWndPosAct = GetRectFromString($g_aCfg[$ge_sActCoord]) Global $gaWndPosInact = GetRectFromString($g_aCfg[$ge_sInACoord]) Global $gbActivated = False Global $gPID = 0, $gsErr = "", $ghWndApp _Main() ;-------------------------------------------------------------------------------------- Func _Create_Message($sMessage) Local $iMsg = WinAPI_RegisterWindowMessage($sMessage) If $iMsg = 0 Then $gsErr &= "IPC Message Creation Failure " & $sMessage & @CRLF Return $iMsg EndFunc ;==>_Create_Message Func _Create_MessageHandler($iMsg, $sFunction) If $iMsg <> 0 Then Opt("GUIOnEventMode", 1) GUICreate(@ScriptName & "_IPC", 0, 0, 0, 0, 0, 0) ; create a top level window GUIRegisterMsg($iMsg, $sFunction) EndIf EndFunc ;==>_Create_MessageHandler Func _Exit() ;sets hotkeys and saves settings HotKeySet("{F4}", Settings_GUI) HotKeySet("{F1}", _Help) HotKeySet("{ESC}", _Exit_Now) ToolTip("Pass Through F1 - Help, F4 - Settings, ESC - Quit without saving", 0, 0) Sleep(5000) ToolTip("", 0, 0) HotKeySet("{F4}") HotKeySet("{F1}") HotKeySet("{ESC}") Settings_Save() Exit EndFunc ;==>_Exit Func _Exit_Now() OnAutoItExitUnRegister("_Exit") Exit EndFunc ;==>_Exit_Now Func _Help() MsgBox(0, "Pass Through", "Settings stored in:" & @CRLF & $gsINI_PATH & _ @CRLF & @CRLF & _ "Invoked: " & @ScriptDir & "\" & $g_aCfg[$ge_sExecute] & " " & $CmdLineRaw & _ @CRLF & "FileTypes: " & $gsMatchFileTypes & @CRLF & _ "Errors:" & $gsErr & @CRLF) EndFunc ;==>_Help Func _IsCompiled() ;wakillon Return @Compiled EndFunc ;==>_IsCompiled Func _Main() If Not FileExists($gsINI_PATH) Then ;FIRST RUN Settings_Save() Settings_GUI() EndIf Opt("SendKeyDelay", $g_aCfg[$ge_iKeyDelay]) Opt("SendKeyDownDelay", $g_aCfg[$ge_iKeyDnDelay]) If _IsCompiled() Then Local $iActMsg = _Create_Message("@ScriptFullPath" & "_msg") RunPassThrough($iActMsg) _Create_MessageHandler($iActMsg, "Activated_Ext") EndIf OnAutoItExitRegister("_Exit") Do $ghWndApp = WaitActive_Wnd($gaWndPosAct, $g_aCfg[$ge_sSendKeysAct]) Until (WaitNotExists_Wnd($ghWndApp, $gaWndPosInact, $g_aCfg[$ge_sSendKeysInA]) Or $g_aCfg[$ge_bClose]) If $g_aCfg[$ge_bClose] And WinExists($ghWndApp) Then WinClose($ghWndApp) Exit EndFunc ;==>_Main Func _Singleton_NOCHILD($sOccurrenceName, $iFlag = 0) ;Valik ;Without SECURITY_ATTRIBUTES;;; Local Const $ERROR_ALREADY_EXISTS = 183 Local $aHandle = DllCall("kernel32.dll", "handle", "CreateMutexW", "struct*", 0, "bool", 1, "wstr", $sOccurrenceName) If @error Then Return SetError(@error, @extended, 0) Local $aLastError = DllCall("kernel32.dll", "dword", "GetLastError") If @error Then Return SetError(@error, @extended, 0) If $aLastError[0] = $ERROR_ALREADY_EXISTS Then If BitAND($iFlag, 1) Then DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $aHandle[0]) If @error Then Return SetError(@error, @extended, 0) Return SetError($aLastError[0], $aLastError[0], 0) Else Exit -1 EndIf EndIf Return $aHandle[0] EndFunc ;==>_Singleton_NOCHILD ;------------------------------------------------------------------------------------------ Func Activated_Ext() ;($hWnd, $iMsg, $wParam, $lParam) ;Message Posted from other instances ;call this to notify of an active file $gbActivated = True EndFunc ;==>Activated_Ext Func ArrayToStr($aArray) ;returns single dimension array as comma delimited string ;on error returns 0 Local $sRet = "" Local $iCt = UBound($aArray) - 1 If $iCt < 0 Then Return SetError(1, 0, 0) For $i = 0 To $iCt $sRet &= $aArray[$i] & "," Next $sRet = StringTrimRight($sRet, 1) ;Remove the trailing ',' Return $sRet EndFunc ;==>ArrayToStr Func BuildFileTypes($sTypes) ;Build a regex string of file extensions from a comma separated one ;matches partial filenames too ;"txt,exe,.com,.avi,test.mp3" => ".*\.txt,.*\.exe,.*\.com,.*\.avi,.*test\.mp3" ;('\' escapes the '.') Local $sTmp, $sRet = "" Local $aExt = StringRegExp($sTypes, "(\w+?\.\w+)|\w+", 3) For $i = 0 To UBound($aExt) - 1 $sTmp = $aExt[$i] If StringInStr($sTmp, ".") = 0 Then $sTmp = "." & $sTmp $sRet &= ".*" & StringReplace($sTmp, ".", "\.") & "|" Next $sRet = StringTrimRight($sRet, 1) ;Remove the trailing '|' Return $sRet EndFunc ;==>BuildFileTypes Func Cfg_Read($iSetting, $sDefault) Return IniRead($gsINI_PATH, $gsINI_SEC, $gaIniKeys[$iSetting], $sDefault) EndFunc ;==>Cfg_Read Func Cfg_Write($iSetting, $sValue) If Not _IsCompiled() Then ConsoleWrite($gaIniKeys[$iSetting] & " = " & $sValue & @CRLF) Else IniWrite($gsINI_PATH, $gsINI_SEC, $gaIniKeys[$iSetting], $sValue) EndIf EndFunc ;==>Cfg_Write Func Execute_App($sPath) If FileExists( $sPath) Then Run(Chr(34) & $sPath & Chr(34), "") EndIf EndFunc Func GetRectFromString($sCoords) ;takes rect passed in string 'x, y, w, h' converts to array ;Returns [x, y, w, h] if string is valid or 0 if invalid ;You should check if return is an array with IsArray() Return StringRegExp($sCoords, "(\d+)\D+(\d+)\D+(\d+)\D+(\d+)", 1) EndFunc ;==>GetRectFromString Func RunPassThrough($iActMsg = 0) ;calls the original file passing through commandline arguments Local $sPath = @ScriptDir & "\" & $g_aCfg[$ge_sExecute] Local $sSwitches = $CmdLineRaw ;MsgBox(0, "Pass Through", $sPath & @CRLF & $sSwitches) $gPID = Run(Chr(34) & $sPath & Chr(34) & " " & $sSwitches, "") ; Run If $gPID Then RunSingleInstance($iActMsg) Sleep(1000) ;Wait a moment for the file to load EndFunc ;==>RunPassThrough Func RunSingleInstance($iActMsg) Local Const $iSZMB = (1024 * 1024) Local Const $HWND_BROADCAST = 0xFFFF If _Singleton_NOCHILD(@ScriptName, 1) = 0 Then If $CmdLine[0] > 1 And FileExists($CmdLine[2]) Then If $g_aCfg[$ge_iMinSize] And FileGetSize($CmdLine[2]) < ($g_aCfg[$ge_iMinSize] * $iSZMB) Then ;;;If file is less than $g_aCfg[$ge_iMinSize] Megabytes treat it like an inactive file ElseIf $iActMsg <> 0 Then ; Update script by posting a message from this (new) instance If StringRegExp($CmdLine[2], $gsMatchFileTypes) Then WinAPI_PostMessage($HWND_BROADCAST, $iActMsg, 0, 0) EndIf EndIf EndIf _Exit_Now() ;single instance of script ONLY EndIf EndFunc ;==>RunSingleInstance Func Settings_GUI() Opt("GUIOnEventMode", 0) ;GUIConstantsEx Local Const $GUI_ENABLE = 0x40 Local Const $GUI_DISABLE = 0x80 Local Const $GUI_CHECKED = 0x1 Local Const $GUI_SHOW = 16 Local $nMsg Local Enum $eS_KeySend = 0, $eS_Coords, $eS_SetWHelper, $eS_Exec, $eS_LAST Local $aCtlText[$eS_LAST] = ["Send Keys", "Coordinates (x, y, w, h)", "Set With Helper", "Execute"] Local $aActivCtls[$eS_LAST] ;Holds handles for the Active State Controls Local $aInactCtls[$eS_LAST] ;Holds handles for the Inactive State Controls Local $hForm1_1 = GUICreate("Pass Through Settings", 287, 245, 192, 124) GUICtrlCreateLabel($aCtlText[$eS_Exec], 8, 2, 74, 17) Local $hI_Exec = GUICtrlCreateInput($g_aCfg[$ge_sExecute], 100, 0, 180, 20) GUICtrlCreateLabel("Win Text FB", 8, 30, 74, 17) Local $hI_FbTxt = GUICtrlCreateInput($g_aCfg[$ge_sWndFbTxt], 100, 27, 180, 20) Local $hC_IClose = GUICtrlCreateCheckbox("Close on Inactive", 8, 50, 100, 17) GUICtrlSetState($hC_IClose, $g_aCfg[$ge_bClose] ? 1 : 4) GUICtrlCreateTab(8, 75, 275, 140) If GUICtrlCreateTabItem("Activated Settings") Then GUICtrlSetState(-1, $GUI_SHOW) ; will be display first GUICtrlCreateLabel("File Extensions", 10, 103, 74, 17) Local $hI_FTyp = GUICtrlCreateInput($g_aCfg[$ge_sFileTypes], 128, 100, 150, 20) GUICtrlCreateLabel($aCtlText[$eS_KeySend], 10, 126, 55, 20) $aActivCtls[$eS_KeySend] = GUICtrlCreateInput($g_aCfg[$ge_sSendKeysAct], 128, 122, 150, 20) GUICtrlCreateLabel($aCtlText[$eS_Exec], 10, 148, 55, 20) $aActivCtls[$eS_Exec] = GUICtrlCreateInput($g_aCfg[$ge_sActExec], 128, 144, 150, 20) GUICtrlCreateLabel($aCtlText[$eS_Coords], 10, 169, 111, 20) $aActivCtls[$eS_SetWHelper] = GUICtrlCreateButton($aCtlText[$eS_SetWHelper], 128, 190, 150, 17) $aActivCtls[$eS_Coords] = GUICtrlCreateInput(ArrayToStr($gaWndPosAct), 128, 166, 150, 20) Local $hC_AMaxm = GUICtrlCreateCheckbox("Maximize", 10, 189, 89, 17) GUICtrlSetState($hC_AMaxm, $g_aCfg[$ge_bMaximize] ? 1 : 4) EndIf If GUICtrlCreateTabItem("Inactivated Settings") Then GUICtrlCreateLabel($aCtlText[$eS_KeySend], 10, 103, 55, 20) $aInactCtls[$eS_KeySend] = GUICtrlCreateInput($g_aCfg[$ge_sSendKeysInA], 128, 100, 150, 20) GUICtrlCreateLabel($aCtlText[$eS_Exec], 10, 126, 55, 20) $aInactCtls[$eS_Exec] = GUICtrlCreateInput($g_aCfg[$ge_sInAExec], 128, 122, 150, 20) GUICtrlCreateLabel($aCtlText[$eS_Coords], 10, 148, 111, 20) $aInactCtls[$eS_SetWHelper] = GUICtrlCreateButton($aCtlText[$eS_SetWHelper], 128, 169, 150, 17) $aInactCtls[$eS_Coords] = GUICtrlCreateInput(ArrayToStr($gaWndPosInact), 128, 145, 150, 20) EndIf GUICtrlCreateTabItem("") ; end tabitem definition Local $hB_Cancel = GUICtrlCreateButton("Cancel", 8, 215, 49, 17) Local $hB_Save = GUICtrlCreateButton("Save", 71, 215, 49, 17) GUISetState(@SW_SHOW, $hForm1_1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $hB_Cancel ContinueCase Case $GUI_EVENT_CLOSE ExitLoop Case $aActivCtls[$eS_SetWHelper] ;Pops-up window to make setting coords easier GUICtrlSetState($aActivCtls[$eS_SetWHelper], $GUI_DISABLE) GUICtrlSetData($aActivCtls[$eS_Coords], Settings_PosHelper("Active Pos", _ GUICtrlRead($aActivCtls[$eS_Coords]))) GUICtrlSetState($aActivCtls[$eS_SetWHelper], $GUI_ENABLE) Case $aInactCtls[$eS_SetWHelper] ;Pops-up window to make setting coords easier GUICtrlSetState($aInactCtls[$eS_SetWHelper], $GUI_DISABLE) GUICtrlSetData($aInactCtls[$eS_Coords], Settings_PosHelper("Inactive Pos", _ GUICtrlRead($aInactCtls[$eS_Coords]))) GUICtrlSetState($aInactCtls[$eS_SetWHelper], $GUI_ENABLE) Case $hB_Save $g_aCfg[$ge_sExecute] = GUICtrlRead($hI_Exec) $g_aCfg[$ge_sWndFbTxt] = GUICtrlRead($hI_FbTxt) $g_aCfg[$ge_bClose] = (BitAND(GUICtrlRead($hC_IClose), $GUI_CHECKED) = $GUI_CHECKED) ? 1 : 0 $g_aCfg[$ge_sFileTypes] = GUICtrlRead($hI_FTyp) $g_aCfg[$ge_sSendKeysAct] = GUICtrlRead($aActivCtls[$eS_KeySend]) $g_aCfg[$ge_sActExec] = GUICtrlRead($aActivCtls[$eS_Exec]) $g_aCfg[$ge_sActCoord] = GUICtrlRead($aActivCtls[$eS_Coords]) $gaWndPosAct = GetRectFromString($g_aCfg[$ge_sActCoord]) $g_aCfg[$ge_bMaximize] = (BitAND(GUICtrlRead($hC_AMaxm), $GUI_CHECKED) = $GUI_CHECKED) ? 1 : 0 $g_aCfg[$ge_sSendKeysInA] = GUICtrlRead($aInactCtls[$eS_KeySend]) $g_aCfg[$ge_sInAExec] = GUICtrlRead($aInactCtls[$eS_Exec]) $g_aCfg[$ge_sInACoord] = GUICtrlRead($aInactCtls[$eS_Coords]) $gaWndPosInact = GetRectFromString($g_aCfg[$ge_sInACoord]) Settings_Save() ExitLoop EndSwitch WEnd GUIDelete($hForm1_1) Return ; EndFunc ;==>Settings_GUI Func Settings_PosHelper($sTitle, $sRect) ;Pops-up window to make setting coords easier ;sRect is a string format 'x, y, w, h' OR '0' ;Returns new sRect in same format ;WindowsConstants Local Const $WS_OVERLAPPEDWINDOW = 0x00CF0000 Local $nMsg Local $hForm1_2 = GUICreate($sTitle, 0, 0, -1, -1, $WS_OVERLAPPEDWINDOW) WndMoveArray($hForm1_2, GetRectFromString($sRect)) Local $hB_Set = GUICtrlCreateButton("Set", 0, 0, 50, 17) GUISetState(@SW_SHOW, $hForm1_2) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $hB_Set $sRect = ArrayToStr(WinGetPos($hForm1_2)) ContinueCase Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hForm1_2) Return $sRect ; EndFunc ;==>Settings_PosHelper Func Settings_Save() Local $vVal ; If Not _IsCompiled() Then ConsoleWrite("SETTINGS_SAVE:" & @CRLF) For $i = 0 To $ge_LASTCFG - 1 $vVal = $g_aCfg[$i] If IsBool($vVal) Then Cfg_Write($i, $vVal ? 1 : 0) ElseIf IsArray($vVal) Then Cfg_Write($i, ArrayToStr($vVal)) Else Cfg_Write($i, $vVal) EndIf Next EndFunc ;==>Settings_Save Func WinAPI_PostMessage($hWnd, $iMsg, $wParam, $lParam) Local $aResult = DllCall("user32.dll", "bool", "PostMessage", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc ;==>WinAPI_PostMessage Func WinAPI_RegisterWindowMessage($sMessage) Local $aResult = DllCall("user32.dll", "uint", "RegisterWindowMessageW", "wstr", $sMessage) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc ;==>WinAPI_RegisterWindowMessage Func WaitActive_Wnd($aRect, $sKeys) ; Loops waiting for a trigger from vlc window either filename(s) ; in the title or window name and text ; if PID is defined and doesn't exist closes script ; Returns window handle Local $hWnd Do $hWnd = WndTryActivate($gsMatchWnd, "") ; Wait for active window If $hWnd = 0 Then ;Fallback $hWnd = WndTryActivate($gsMatchWnd_Fb, $g_aCfg[$ge_sWndFbTxt]) If $hWnd <> 0 Then ExitLoop If $gPID And Not ProcessExists($gPID) And Not WinExists($gsMatchWnd) Then Exit Sleep(1000) EndIf Until ($hWnd <> 0) WndMoveArray($hWnd, $aRect) WndSendKeys($hWnd, $sKeys) If $g_aCfg[$ge_bMaximize] Then WinSetState($hWnd, "", @SW_MAXIMIZE) Execute_App($g_aCfg[$ge_sActExec]) Return $hWnd EndFunc ;==>WaitActive_Wnd Func WaitNotExists_Wnd($hWnd, $aRect, $sKeys) ;Returns False if Title Does Not exist but $hWnd DOES exist ;Returns True if $hWnd + $title DOES NOT exist Do $gbActivated = False WinWaitClose(WinGetTitle($ghWndApp)) Until (Not $gbActivated) ;can be overidden by message posted from another instance If WinExists($hWnd) Then WndSendKeys($hWnd, $sKeys) If $g_aCfg[$ge_bMaximize] Then WinSetState($hWnd, "", @SW_RESTORE) WndMoveArray($hWnd, $aRect) Execute_App($g_aCfg[$ge_sInAExec]) Return False EndIf Return True EndFunc ;==>WaitNotExists_Wnd Func WndMoveArray($hWnd, $aC) ;Moves $hWnd to coords specified by array If UBound($aC) >= 4 Then WinMove($hWnd, "", $aC[0], $aC[1], $aC[2], $aC[3]) EndIf EndFunc ;==>WndMoveArray Func WndSendKeys($hWnd, $sKeys) If $sKeys <> "" Then ControlSend($hWnd, "", 0, $sKeys) Sleep(100) EndIf EndFunc ;==>WndSendKeys Func WndTryActivate($Title, $Text = "") ;attemps to activate a window / waits $giACTWAIT seconds for window to become active WinActivate($Title, $Text) Local $hWnd = WinWaitActive($Title, $Text, $giACTWAIT) ; Wait for active window for number of seconds Return $hWnd EndFunc ;==>WndTryActivate2 points -
Application to back up
FrancescoDiMuro reacted to Belini for a topic
I needed to do a backup program that meets my needs and I want to share it with you. #RequireAdmin #region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=.\Bk.ico #AutoIt3Wrapper_Compression=0 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Res_Comment=Funรงรฃo: Application to backup #AutoIt3Wrapper_Res_Description=Autoit3 3.3.9.4 #AutoIt3Wrapper_Res_Fileversion=1.1.10.18 #AutoIt3Wrapper_Res_LegalCopyright=Made by Belini #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ------------------------------------------------- Title: Backup Personal Objective: Back up of the files and folders Author: Belini (Brazil) Autoit Version: 3.3.9.4 Version: 1.0.10.18 Forum: http://www.autoitbrasil.com/forum #ce ------------------------------------------------- #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include "_UskinLibrary.au3" #include <GuiListView.au3> #include "Skin_03.au3" #include <File.au3> Global $iFix_Col = 1, $Dir_backup, $Input, $Listv, $Listv_Files, $Updated = 0, $Sustained = 0 Global $nMsg, $proceed = 1, $item_num, $But[8], $item_text[4], $Check, $lab[3] _Arq_ini() _Uskin_LoadDLL() _USkin_Init(_Skin_03(True)) _Gui_backup() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $But[1] _Add_Line() Case $But[2] _Del_line() Case $But[3] _Opt_Dir() Case $But[4] _Opt_Backup() Case $But[5] _Dir_Backup() Case $But[6] $proceed = 0 Case $But[7] _Start_backup() Case $Check _Opt_Finalize() EndSwitch WEnd Func _Add_Line() Local $dir = FileSelectFolder("Searching for folder.", "") If IniRead(@ScriptDir & "\Config.ini", "Folders", $dir, "") = "" Then GUICtrlCreateListViewItem($dir & "|Include Subfolders" & "|Yes", $Listv) IniWrite(@ScriptDir & "\Config.ini", "Folders", $dir, "|Include Subfolders" & "|Yes") Else MsgBox(4096, "", "This directory has already been chosen!", 3) EndIf EndFunc ;==>_Add_Line Func _Arq_ini() If Not FileExists(@ScriptDir & "\Config.ini") Then _ FileWrite(@ScriptDir & "\Config.ini", "[BACKUP]" & @CRLF & "address= " & @CRLF & @CRLF & "[TURN OFF]" & @CRLF & "option=0" & @CRLF & @CRLF & "[FOLDERS]") EndFunc ;==>_Arq_ini Func _Backup_Files($path = "") Local $searh_files, $i $searh_files = _FileListToArray($path, "*.*", 1) If Not @error Then For $i = 1 To $searh_files[0] If GUIGetMsg() = $But[6] Then $proceed = 0 If $proceed = 0 Then ExitLoop _Compare_files($path & "\" & $searh_files[$i]) Next EndIf EndFunc ;==>_Backup_Files Func _Backup_Full($path = "", $counter = 0) $counter = 0 $path &= '\' Local $file, $searh_files $searh_files = FileFindFirstFile($path & '*') If $searh_files = -1 Then Return '' While 1 If GUIGetMsg() = $But[6] Then $proceed = 0 $file = FileFindNextFile($searh_files) If @error Or $proceed = 0 Then ExitLoop If @extended Then If $counter >= 10 Then ContinueLoop _Backup_Full($path & $file, $counter + 1) Else _Compare_files($path & $file) EndIf WEnd FileClose($searh_files) EndFunc ;==>_Backup_Full Func _Compare_files($file = "") Local $File_backup, $item, $folder $item = StringTrimLeft($file, StringInStr($file, "\", 1, -1)) $folder = StringTrimLeft($file, StringInStr($file, "\", 1, -2)) $folder = StringMid($folder, 1, StringInStr($folder, "\", 1, -1) -1 ) $File_backup = StringReplace($file, StringMid($file, 1, 2), $Dir_backup, 0, 2) $file = FileGetShortName($file) $File_backup = FileGetShortName($File_backup) _GUICtrlListView_SetItemText($Listv, 0, $folder, 2) _GUICtrlListView_SetItemText($Listv, 0, $item, 1) If FileGetTime($file, 0, 1) > FileGetTime($File_backup, 0, 1) Then $Updated += 1 FileCopy($file, $File_backup, 9) GUICtrlSetData($lab[2], "Updated: " & $Updated) Else $Sustained += 1 GUICtrlSetData($lab[1], "Sustained: " & $Sustained) EndIf EndFunc ;==>_Compare_files Func _Del_line() $item_num = _GUICtrlListView_GetSelectedIndices(GUICtrlGetHandle($Listv)) $item_text[1] = _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listv), Number($item_num)) _GUICtrlListView_DeleteItemsSelected(GUICtrlGetHandle($Listv)) IniDelete(@ScriptDir & "\Config.ini", "Folders", $item_text[1]) EndFunc ;==>_Del_line Func _Dir_Backup() $Dir_backup = FileSelectFolder("Searching for folder.", "", 1) ;GUICtrlSetState($Input, $GUI_FOCUS) GUICtrlSetData($Input, $Dir_backup) IniWrite(@ScriptDir & "\Config.ini", "BACKUP", "address", $Dir_backup) EndFunc ;==>_Dir_Backup Func _Gui_backup() GUICreate("Backup Personal - Made by Belini", 660, 679, -1, -1) GUICtrlCreateGroup("Directory for backup ", 352, 11, 290, 69) $But[1] = GUICtrlCreateButton("Include address", 15, 16, 140, 25) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $But[2] = GUICtrlCreateButton("Delete address", 15, 56, 140, 25) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $But[3] = GUICtrlCreateButton("Archives / Subfolders", 170, 16, 170, 25) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $But[4] = GUICtrlCreateButton("Mark / Unmark", 170, 56, 170, 25) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $But[5] = GUICtrlCreateButton("Search", 553, 36, 75, 25) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $But[6] = GUICtrlCreateButton("Cancel", 514, 631, 130, 33) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") $But[7] = GUICtrlCreateButton("Start", 390, 631, 110, 33) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") $Input = GUICtrlCreateInput(IniRead(@ScriptDir & "\Config.ini", "BACKUP", "address", ""), 368, 38, 183, 21) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Check = GUICtrlCreateCheckbox("Turn off the computer when the task is finished.", 15, 647, 352, 25) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $lab[1] = GUICtrlCreateLabel("Sustained: 0", 32, 623, 175, 25) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $lab[2] = GUICtrlCreateLabel("Updated: 0", 210, 623, 175, 25) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Listv = GUICtrlCreateListView("Folder Address|List Files|Make Backup", 16, 96, 627, 520, _ BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL), BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000000) _GUICtrlListView_SetColumnWidth($Listv, 0, 395) _GUICtrlListView_SetColumnWidth($Listv, 1, 120) _GUICtrlListView_SetColumnWidth($Listv, 2, 105) _GUICtrlListView_JustifyColumn($Listv, 1, 2) _GUICtrlListView_JustifyColumn($Listv, 2, 2) GUISetState(@SW_SHOW) Local $aArray = IniReadSection(@ScriptDir & "\Config.ini", "Folders") _ArraySort($aArray) If Not @error Then For $i = 1 To $aArray[0][0] If FileExists($aArray[$i][0]) Then GUICtrlCreateListViewItem(StringReplace($aArray[$i][0] & $aArray[$i][1], "=|", "|"), $Listv) Else GUICtrlCreateListViewItem($aArray[$i][0] & "|Inexistent Folder|Not", $Listv) EndIf Next EndIf If IniRead(@ScriptDir & "\Config.ini", "TURN OFF", "option", "1") = "1" Then GUICtrlSetState($Check, $GUI_CHECKED) EndFunc ;==>_Gui_backup Func _Opt_Dir() $item_num = _GUICtrlListView_GetSelectedIndices(GUICtrlGetHandle($Listv)) $item_text[1] = _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listv), Number($item_num), 1) $item_text[2] = _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listv), Number($item_num), 2) Switch $item_text[1] Case "Directory Only" _GUICtrlListView_SetItemText($Listv, $item_num, "Include Subfolders", 1) IniWrite(@ScriptDir & "\Config.ini", "Folders", _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listv), Number($item_num)), "|Include Subfolders|" & $item_text[2]) Case "Include Subfolders" _GUICtrlListView_SetItemText($Listv, $item_num, "Directory Only", 1) IniWrite(@ScriptDir & "\Config.ini", "Folders", _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listv), Number($item_num)), "|Directory Only|" & $item_text[2]) Case "Inexistent Folder" MsgBox(4096, "", "Directory does not exist!", 3) EndSwitch EndFunc ;==>_Opt_Dir Func _Opt_Backup() $item_num = _GUICtrlListView_GetSelectedIndices(GUICtrlGetHandle($Listv)) $item_text[1] = _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listv), Number($item_num), 1) $item_text[2] = _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listv), Number($item_num), 2) If $item_text[1] <> "Inexistent Folder" Then Switch $item_text[2] Case "Yes" _GUICtrlListView_SetItemText($Listv, $item_num, "Not", 2) IniWrite(@ScriptDir & "\Config.ini", "Folders", _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listv), Number($item_num)), "|" & $item_text[1] & "|Not") Case "Not" _GUICtrlListView_SetItemText($Listv, $item_num, "Yes", 2) IniWrite(@ScriptDir & "\Config.ini", "Folders", _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listv), Number($item_num)), "|" & $item_text[1] & "|Yes") EndSwitch Else MsgBox(4096, "", "Directory does not exist!", 3) EndIf EndFunc ;==>_Opt_Backup Func _Opt_Finalize() If GUICtrlRead($Check) = 1 Then IniWrite(@ScriptDir & "\Config.ini", "TURN OFF", "option", "1") Else IniWrite(@ScriptDir & "\Config.ini", "TURN OFF", "option", "0") EndIf EndFunc ;==>_Opt_Finalize Func _Start_backup() Local $itens = _GUICtrlListView_GetItemCount($Listv) If $itens > 0 Then $Dir_backup = GUICtrlRead($Input) If FileExists($Dir_backup) Then For $i = 1 To $itens If $proceed = 0 Then ExitLoop $item_text[1] = _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listv), 0, 0) $item_text[2] = _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listv), 0, 1) $item_text[3] = _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listv), 0, 2) If $item_text[2] <> "Inexistent Folder" And $item_text[3] = "Yes" Then If $item_text[2] = "Include Subfolders" Then _Backup_Full($item_text[1], 0) Else _Backup_Files($item_text[1]) EndIf EndIf If $proceed = 1 Then _GUICtrlListView_DeleteItem($Listv, 0) Next If $proceed = 1 Then If GUICtrlRead($Check) = 1 Then Shutdown(1) Else GUICtrlSetState($Listv_Files, $GUI_HIDE) MsgBox(4096, "", "Task Completed!") Exit EndIf Else $proceed = 1 _GUICtrlListView_SetItemText($Listv, 0, $item_text[2], 1) _GUICtrlListView_SetItemText($Listv, 0, $item_text[3], 2) EndIf Else MsgBox(4096, "", "Backup directory does not exist!", 3) EndIf EndIf EndFunc ;==>_Start_backup Download full: https://mega.nz/#!5JEylSoB!AvebLVC9bFq_8a33MA2LzaRra6ZEgbYKH5MGcDS8khE1 point -
Window Style Tool
ioa747 reacted to boomingranny for a topic
A simple tool I made to help me pick the right window style combination. select the style(s) you want for your new window gui and see them live in the preview window to the right, then copy the resulting text out of the preview window, in to your guicreate line... #include <EditConstants.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> #include <TreeViewConstants.au3> #include <GUIConstantsEx.au3> #include <Array.au3> #include <String.au3> opt("GUIOnEventMode",1) global $Win,$Win2 global $styles[1], $extStyles[1] global $TVStyles, $TVExtStyles global $tvStyleItems[1], $tvExtStyleItems[1] global $oldpos[4] global $CreatingWindow global $inTitle,$text,$styletext,$extStyleText global $heightOffset, $widthOffset global $TreeviewItem_Clicked global $lblStyle,$lblExtStyle global $width=300, $height = 300 global $TimerCreateWindow ;prevents recreating window too many times at once - as it can lag the program out ;missing extended window const const $WS_EX_NOREDIRECTIONBITMAP = 0x00200000 addstyles() addExtStyles() main() func main() redim $tvStyleItems[UBound($styles)] redim $tvExtStyleItems[UBound($Extstyles)] $win = GUICreate("Windows Styles",500,590,-1,-1,BitOR($WS_THICKFRAME,$WS_MINIMIZEBOX )) GUISetOnEvent($GUI_EVENT_CLOSE,"_exit") GUICtrlCreateLabel("Title:",4,10) GUICtrlSetResizing(-1,BitOR($GUI_DOCKTOP,$GUI_DOCKHEIGHT)) $inTitle = GUICtrlCreateInput("",30,5,250,22) GUICtrlSetResizing(-1,BitOR($GUI_DOCKTOP,$GUI_DOCKHEIGHT)) GUICtrlSetOnEvent(-1,"titlechange") $btnSetTitle = GUICtrlCreateButton("Set",280,4,40,24) GUICtrlSetResizing(-1,BitOR($GUI_DOCKTOP,$GUI_DOCKHEIGHT)) GUICtrlSetOnEvent(-1,"titlechange") $lblStyle = GUICtrlCreateLabel("Style: 00000000000000000000000000000000",4,30,400) GUICtrlSetFont(-1,9,500,0,"Courier New") GUICtrlSetResizing(-1,BitOR($GUI_DOCKTOP,$GUI_DOCKHEIGHT)) $lblExtStyle = GUICtrlCreateLabel("Extended Style: 00000000000000000000000000000000",4,50,400) GUICtrlSetFont(-1,9,500,0,"Courier New") GUICtrlSetResizing(-1,BitOR($GUI_DOCKTOP,$GUI_DOCKHEIGHT)) $TVStyles = GUICtrlCreateTreeView(0,70,247,495,$TVS_CHECKBOXES) GUICtrlSetResizing(-1,BitOR($GUI_DOCKLEFT,$GUI_DOCKTOP,$GUI_DOCKBOTTOM)) for $i = 1 to UBound($Styles)-1 $tvStyleItems[$i] = GUICtrlCreateTreeViewItem($styles[$i],$tvStyles) GUICtrlSetOnEvent(-1,"TreeviewItem_Click") Next $TVExtStyles = GUICtrlCreateTreeView(250,70,247,495,$TVS_CHECKBOXES) GUICtrlSetResizing(-1,BitOR($GUI_DOCKRIGHT,$GUI_DOCKTOP,$GUI_DOCKBOTTOM)) for $i = 1 to UBound($ExtStyles)-1 $tvExtStyleItems[$i] = GUICtrlCreateTreeViewItem($extStyles[$i],$TVExtStyles) GUICtrlSetOnEvent(-1,"TreeviewItem_Click") Next GUISetState() ;this function creates the initial preview gui on the right ($win2) CreatePreviewGUI() $oldMouseX = -1 $oldMouseY = -1 While 1 setWinPos() sleep(50) $mouseX = MouseGetPos(0) $mouseY = MouseGetPos(1) if $mouseX <> $oldMouseX or $mouseY <> $oldMouseY then SetTip() $oldMouseX = $mouseX $oldMouseY = $mouseY endif WEnd EndFunc func setWinPos() if not IsHWnd($win) then return if not IsHWnd($win2) then return $pos = WinGetPos($win) $bUpdateText = false ;if window has moved if $oldpos[0] <> $pos[0] or $oldpos[1] <> $pos[1] or $oldpos[2] <> $pos[2] or $oldpos[3] <> $pos[3] then $top = $pos[1] $left = $pos[0]+$pos[2] winmove($win2,"",$left,$top,Default,Default) $oldpos = $pos UpdateText() endif EndFunc func TreeviewItem_Click() CreatePreviewGUI() EndFunc func CreatePreviewGUI() if $CreatingWindow or TimerDiff($TimerCreateWindow) < 500 then $CreatingWindow = false AdlibRegister("CreatePreviewGUI",1000) return endif AdlibUnRegister("CreatePreviewGUI") $TimerCreateWindow = TimerInit() $CreatingWindow = true Local $SelectedStyleCount Local $SelectedExtStyleCount $styletext = "" $ExtStyleText = "" local $style = 0, $extStyle = 0 $SelectedStyleCount = 0 for $i = 1 to UBound($styles)-1 if _GUICtrlTreeView_GetChecked($TVStyles,$tvStyleItems[$i]) then $SelectedStyleCount += 1 $style = bitor($style,Execute($Styles[$i])) $styletext &= $Styles[$i] &" , " endif Next $styletext = StringTrimRight($styletext,3) ;remove the " , " on the end $SelectedExtStyleCount = 0 for $i = 1 to UBound($extStyles)-1 if _GUICtrlTreeView_GetChecked($TVExtStyles,$tvExtStyleItems[$i]) then $SelectedExtStyleCount += 1 $Extstyle = bitor($extStyle,Execute($ExtStyles[$i])) $ExtStyleText &= $ExtStyles[$i] &" , " endif Next $extstyletext = StringTrimRight($extStyletext,3) ;remove the " , " on the end $pos = WinGetPos($win) if IsHWnd($win2) then GUIDelete($win2) $left = $pos[0]+$pos[2] $top = $pos[1] $win2 = GUICreate(GUICtrlRead($inTitle),$width,$height ,$left,$top,$style,$extStyle,$win) GUISetOnEvent($GUI_EVENT_CLOSE,"_deleteWin2") $timer = TimerInit() while not IsHWnd($win2) sleep(5) if TimerDiff($timer) > 1000 then $CreatingWindow = false ;failed to create window Return endif WEnd If $SelectedStyleCount > 1 Then $styletext = "BitOr ("&$styletext&")" If $SelectedExtStyleCount > 1 Then $extstyletext = "BitOr ("&$extstyletext&")" If $styletext = "" Then $styletext = 0 If $extstyletext = "" Then $extstyletext = 0 GUICtrlSetData($lblStyle, " Style: "&NumberToBinary($style)) GUICtrlSetData($lblExtStyle,"Extended Style: "&NumberToBinary($extstyle)) $size = WinGetClientSize ($win2) $text = GUICtrlCreateEdit("",-2,-2,$size[0]+4,$size[1]+4,BitOR($ES_READONLY,$ES_MULTILINE )) UpdateText() GUICtrlSetResizing($text,$GUI_DOCKBORDERS) GUICtrlSetBkColor($text,$GUI_BKCOLOR_TRANSPARENT ) GUISetState() WinActivate($win) $CreatingWindow = false EndFunc func addstyle($style) _ArrayAdd($Styles,$style) EndFunc func addextstyle($style) _arrayadd($extStyles,$style) EndFunc ;GUISetStyle($style,$extstyle) func addstyles() addstyle("$WS_MAXIMIZEBOX") addstyle("$WS_MINIMIZEBOX") addstyle("$WS_SIZEBOX") addstyle("$WS_SYSMENU") addstyle("$WS_HSCROLL") addstyle("$WS_VSCROLL") addstyle("$WS_DLGFRAME") addstyle("$WS_BORDER") addstyle("$WS_MAXIMIZE") addstyle("$WS_CLIPCHILDREN") addstyle("$WS_CLIPSIBLINGS") addstyle("$WS_DISABLED") addstyle("$WS_VISIBLE") addstyle("$WS_MINIMIZE") addstyle("$WS_CHILD") addstyle("$WS_POPUP") addstyle("$WS_OVERLAPPED") addstyle("$WS_TILED") addstyle("$WS_TABSTOP") addstyle("$WS_GROUP") addstyle("$WS_THICKFRAME") addstyle("$WS_CAPTION") addstyle("$WS_OVERLAPPEDWINDOW") addstyle("$WS_TILEDWINDOW") addstyle("$WS_ICONIC") addstyle("$WS_CHILDWINDOW") addstyle("$WS_POPUPWINDOW") EndFunc func _exit() exit EndFunc func addExtStyles() addExtStyle("$WS_EX_TOOLWINDOW") addExtStyle("$WS_EX_TOPMOST") addExtStyle("$WS_EX_LAYOUTRTL") addExtStyle("$WS_EX_ACCEPTFILES") addExtStyle("$WS_EX_APPWINDOW") addExtStyle("$WS_EX_COMPOSITED") addExtStyle("$WS_EX_CONTROLPARENT") addExtStyle("$WS_EX_CLIENTEDGE") addExtStyle("$WS_EX_CONTEXTHELP") addExtStyle("$WS_EX_DLGMODALFRAME") addExtStyle("$WS_EX_LAYERED") addExtStyle("$WS_EX_LEFT") addExtStyle("$WS_EX_LEFTSCROLLBAR") addExtStyle("$WS_EX_LTRREADING") addExtStyle("$WS_EX_MDICHILD") addExtStyle("$WS_EX_NOACTIVATE") addExtStyle("$WS_EX_NOINHERITLAYOUT") addExtStyle("$WS_EX_NOPARENTNOTIFY") addExtStyle("$WS_EX_RIGHT") addExtStyle("$WS_EX_RIGHTSCROLLBAR") addExtStyle("$WS_EX_RTLREADING") addExtStyle("$WS_EX_STATICEDGE") addExtStyle("$WS_EX_TRANSPARENT") addExtStyle("$WS_EX_WINDOWEDGE") addExtStyle("$WS_EX_NOREDIRECTIONBITMAP") EndFunc ; ============================================================================================== ; Func NumberToBinary($iNumber) ; ; Converts a 32-bit signed or unsigned # to a binary bit string. (32-bit is AutoIT limit) ; NOTE: range for 32-bit values is -2147483648 to 4294967295 ; Anything outside the range will return an empty string! ; ; $iNumber = # to convert, obviously ; ; Returns: ; Success: Binary bit string ; Failure: "" and @error set ; ; Author: Ascend4nt, with help from picaxe (Changing 'If BitAND/Else' to just one line) ; See it @ http://www.autoitscript.com/forum/index.php?showtopic=90056 ; ============================================================================================== Func NumberToBinary($iNumber) Local $iTopBit,$sBinString = "" ; Maximum 32-bit # range is -2147483648 to 4294967295 If $iNumber<-2147483648 Or $iNumber>4294967295 Then Return SetError(1,0,"") ; Any number <0 or >2147483647 will have the 32nd (top) bit set If $iNumber>2147483647 Or $iNumber<0 Then $iTopBit=1 Else $iTopBit=0 EndIf ; Remove topbit, otherwise the function will enter an endless loop Local $iUnsignedNumber=BitAND($iNumber,0x7FFFFFFF) ; Cycle through each bit, shifting to the right until 0 Do $sBinString = BitAND($iUnsignedNumber, 1) & $sBinString $iUnsignedNumber = BitShift($iUnsignedNumber, 1) Until Not $iUnsignedNumber ; PAD to 32-bits (or alternatively see below for #'s that don't need it) Return $iTopBit & StringRight("000000000000000000000000000000" & $sBinString,31) ; If you prefer not to pad numbers that don't need it (anything >0 and <2147483647): #cs If $iTopBit Then Return $iTopBit & StringRight("000000000000000000000000000000" & $sBinString,31) Return $sBinString #ce EndFunc ;==>_NumberToBinary func titleChange() WinSetTitle($win2,"",GUICtrlRead($inTitle)) UpdateText() EndFunc func UpdateText() GUICtrlSetData($text , "GUICreate("""&GUICtrlRead($inTitle)&""", Width, Height, Left, Top, "&$styletext &", "&$extStyleText&")") EndFunc Func SetTip() $aHwnd = DllCall("user32.dll", "hwnd", "WindowFromPoint", "uint", MouseGetPos(0), "uint", MouseGetPos(1)) Switch $aHwnd[0] Case GUICtrlGetHandle($tvStyles), GUICtrlGetHandle($TVExtStyles) $tMPos = _WinAPI_GetMousePos(True, $aHwnd[0]) $hItem = _GUICtrlTreeView_HitTestItem($aHwnd[0], DllStructGetData($tMPos, 1), DllStructGetData($tMPos, 2)) If $hItem = 0 Then ToolTip("") Else ToolTip(StyleHelp(_GUICtrlTreeView_GetText($aHwnd[0], $hItem)),Default,Default,Default,1,4) EndIf case Else ToolTip("") EndSwitch EndFunc func StyleHelp($styleName) switch $styleName case "$WS_BORDER" return "The window has a thin-line border." case "$WS_CAPTION" Return "The window has a title bar ($WS_BORDER | $WS_DIALOGFRAME)." case "$WS_CHILD" return "The window is a child window. A window with this style cannot have a menu bar. This style cannot be used with the $WS_POPUP style." case "$WS_CHILDWINDOW" return "Same as the $WS_CHILD style." case "$WS_CLIPCHILDREN" return "Excludes the area occupied by child windows when drawing occurs within the parent window. This style is used when creating the parent window." case "$WS_CLIPSIBLINGS" return "Clips child windows relative to each other; that is, when a particular child window receives a WM_PAINT message, the $WS_CLIPSIBLINGS style clips all other overlapping child windows out of the region of the child window to be updated. If $WS_CLIPSIBLINGS is not specified and child windows overlap, it is possible, when drawing within the client area of a child window, to draw within the client area of a neighboring child window." case "$WS_DISABLED" return "The window is initially disabled. A disabled window cannot receive input from the user. To change this after a window has been created, use the EnableWindow function." case "$WS_DLGFRAME" return "The window has a border of a style typically used with dialog boxes. A window with this style cannot have a title bar." case "$WS_GROUP" return "(BUGGED: same value as $WS_MINIMIZEBOX) The window is the first control of a group of controls. The group consists of this first control and all controls defined after it, up to the next control with the $WS_GROUP style. The first control in each group usually has the $WS_TABSTOP style so that the user can move from group to group. The user can subsequently change the keyboard focus from one control in the group to the next control in the group by using the direction keys. You can turn this style on and off to change dialog box navigation. To change this style after a window has been created, use the SetWindowLong function." case "$WS_HSCROLL" return "The window has a horizontal scroll bar." case "$WS_ICONIC" return "The window is initially minimized. Same as the $WS_MINIMIZE style." case "$WS_MAXIMIZE" return "The window is initially maximized." case "$WS_MAXIMIZEBOX" return "The window has a maximize button. Cannot be combined with the $WS_EX_CONTEXTHELP style. The $WS_SYSMENU style must also be specified." case "$WS_MINIMIZE" return "The window is initially minimized. Same as the $WS_ICONIC style." case "$WS_MINIMIZEBOX" return "The window has a minimize button. Cannot be combined with the $WS_EX_CONTEXTHELP style. The $WS_SYSMENU style must also be specified." case "$WS_OVERLAPPED" return "VALUE IS 0) The window is an overlapped window. An overlapped window has a title bar and a border. Same as the $WS_TILED style." case "$WS_OVERLAPPEDWINDOW" return "The window is an overlapped window. Same as the $WS_TILEDWINDOW style. ($WS_OVERLAPPED | $WS_CAPTION | $WS_SYSMENU | $WS_THICKFRAME | $WS_MINIMIZEBOX | $WS_MAXIMIZEBOX)" case "$WS_POPUP" return "The windows is a pop-up window. This style cannot be used with the $WS_CHILD style." case "$WS_POPUPWINDOW" return "The window is a pop-up window. The $WS_CAPTION and $WS_POPUPWINDOW styles must be combined to make the window menu visible. ($WS_POPUP | $WS_BORDER | $WS_SYSMENU)" case "$WS_SIZEBOX" return "The window has a sizing border. Same as the $WS_THICKFRAME style." case "$WS_SYSMENU" return "The window has a window menu on its title bar. The $WS_CAPTION style must also be specified." case "$WS_TABSTOP" return "(BUGGED: same value as $WS_MAXIMIZEBOX) The window is a control that can receive the keyboard focus when the user presses the TAB key. Pressing the TAB key changes the keyboard focus to the next control with the WS_TABSTOP style. You can turn this style on and off to change dialog box navigation. To change this style after a window has been created, use the SetWindowLong function. For user-created windows and modeless dialogs to work with tab stops, alter the message loop to call the IsDialogMessage function." case "$WS_THICKFRAME" return "The window has a sizing border. Same as the $WS_SIZEBOX style." case "$WS_TILED" return "(VALUE IS 0) The window is an overlapped window. An overlapped window has a title bar and a border. Same as the $WS_OVERLAPPED style. " case "$WS_TILEDWINDOW" return "The window is an overlapped window. Same as the $WS_OVERLAPPEDWINDOW style. ($WS_OVERLAPPED | $WS_CAPTION | $WS_SYSMENU | $WS_THICKFRAME | $WS_MINIMIZEBOX | $WS_MAXIMIZEBOX)" case "$WS_VISIBLE" return "The window is initially visible. This style can be turned on and off by using the ShowWindow or SetWindowPos function." case "$WS_VSCROLL" return "The window has a vertical scroll bar." case "$WS_EX_ACCEPTFILES" return "The window accepts drag-drop files." case "$WS_EX_APPWINDOW" return "Forces a top-level window onto the taskbar when the window is visible." case "$WS_EX_CLIENTEDGE" return "The window has a border with a sunken edge." case "$WS_EX_COMPOSITED" return "Paints all descendants of a window in bottom-to-top painting order using double-buffering. This cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC. Windows 2000: This style is not supported." case "$WS_EX_CONTEXTHELP" return "The title bar of the window includes a question mark. When the user clicks the question mark, the cursor changes to a question mark with a pointer. If the user then clicks a child window, the child receives a WM_HELP message. The child window should pass the message to the parent window procedure, which should call the WinHelp function using the HELP_WM_HELP command. The Help application displays a pop-up window that typically contains help for the child window. $WS_EX_CONTEXTHELP cannot be used with the $WS_MAXIMIZEBOX or $WS_MINIMIZEBOX styles." case "$WS_EX_CONTROLPARENT" return "The window itself contains child windows that should take part in dialog box navigation. If this style is specified, the dialog manager recurses into children of this window when performing navigation operations such as handling the TAB key, an arrow key, or a keyboard mnemonic." case "$WS_EX_DLGMODALFRAME" return "The window has a double border; the window can, optionally, be created with a title bar by specifying the $WS_CAPTION style in the dwStyle parameter." case "$WS_EX_LAYERED" return "The window is a layered window. This style cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC. Windows 8: The $WS_EX_LAYERED style is supported for top-level windows and child windows. Previous Windows versions support $WS_EX_LAYERED only for top-level windows." case "$WS_EX_LAYOUTRTL" return "If the shell language is Hebrew, Arabic, or another language that supports reading order alignment, the horizontal origin of the window is on the right edge. Increasing horizontal values advance to the left." case "$WS_EX_LEFT" return "The window has generic left-aligned properties. This is the default." case "$WS_EX_LEFTSCROLLBAR" return "If the shell language is Hebrew, Arabic, or another language that supports reading order alignment, the vertical scroll bar (if present) is to the left of the client area. For other languages, the style is ignored." case "$WS_EX_LTRREADING" return "The window text is displayed using left-to-right reading-order properties. This is the default." case "$WS_EX_MDICHILD" return "The window is a MDI child window." case "$WS_EX_NOACTIVATE" return "A top-level window created with this style does not become the foreground window when the user clicks it. The system does not bring this window to the foreground when the user minimizes or closes the foreground window. The window should not be activated through programmatic access or via keyboard navigation by accessible technology, such as Narrator. To activate the window, use the SetActiveWindow or SetForegroundWindow function. The window does not appear on the taskbar by default. To force the window to appear on the taskbar, use the $WS_EX_APPWINDOW style." case "$WS_EX_NOINHERITLAYOUT" return "The window does not pass its window layout to its child windows." case "$WS_EX_NOPARENTNOTIFY" return "The child window created with this style does not send the WM_PARENTNOTIFY message to its parent window when it is created or destroyed." case "$WS_EX_NOREDIRECTIONBITMAP" return "The window does not render to a redirection surface. This is for windows that do not have visible content or that use mechanisms other than surfaces to provide their visual." case "$WS_EX_RIGHT" return "The window has generic ""right-aligned"" properties. This depends on the window class. This style has an effect only if the shell language is Hebrew, Arabic, or another language that supports reading-order alignment; otherwise, the style is ignored. Using the $WS_EX_RIGHT style for static or edit controls has the same effect as using the SS_RIGHT or ES_RIGHT style, respectively. Using this style with button controls has the same effect as using BS_RIGHT and BS_RIGHTBUTTON styles." case "$WS_EX_RIGHTSCROLLBAR" return "The vertical scroll bar (if present) is to the right of the client area. This is the default." case "$WS_EX_RTLREADING" return "If the shell language is Hebrew, Arabic, or another language that supports reading-order alignment, the window text is displayed using right-to-left reading-order properties. For other languages, the style is ignored." case "$WS_EX_STATICEDGE" return "The window has a three-dimensional border style intended to be used for items that do not accept user input." case "$WS_EX_TOOLWINDOW" return "The window is intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the taskbar or in the dialog that appears when the user presses ALT+TAB. If a tool window has a system menu, its icon is not displayed on the title bar. However, you can display the system menu by right-clicking or by typing ALT+SPACE." case "$WS_EX_TOPMOST" return "The window should be placed above all non-topmost windows and should stay above them, even when the window is deactivated. To add or remove this style, use the SetWindowPos function." case "$WS_EX_TRANSPARENT" return "The window should not be painted until siblings beneath the window (that were created by the same thread) have been painted. The window appears transparent because the bits of underlying sibling windows have already been painted. To achieve transparency without these restrictions, use the SetWindowRgn function." case "$WS_EX_WINDOWEDGE" return "The window has a border with a raised edge." EndSwitch EndFunc func _deleteWin2() GUIDelete($win2) EndFunc1 point -
I understand what the trigger of the issue is and doubt there is a easy solution other than the options specified at the end of this post. The With in the last commentblock is recognised as the "With" Keyword and it is trying to tidy the comments block so missing the EndWith. Easiest solution here is to ensure commentblock lines never start with "invalid code", add a semicolon in front of the lines, or Skip_Commentblock tidying by adding this line to the top: #Tidy_Parameters=/Skip_commentblock Jos1 point
-
Window Style Tool
coffeeturtle reacted to Melba23 for a topic
boomingranny, The best practice method for combining styles is to use BitOr rather than simple addition - the Setting Styles tutorial in the Wiki explains why. It should not be too hard to amend the code to do this. M231 point -
Input/ComboBoxEx AutoComplete function
boomingranny reacted to Subz for a topic
Wanted to create an AutoComplete function like "Start ยป Run" functionality for both Urls and Files using SHAutoComplete function, Unfortunately my knowledge is quite limited and so put the following together based on existing functions and snippets online. While everything works fine, I'm not sure if I've written the function correctly and was hoping someone with more experience with WinAPI could look it over and let me know if I've missed anything. Thanks in advance. #include <GuiComboBoxEx.au3> #include <GUIConstantsEx.au3> Global Const $SHACF_AUTOAPPEND_FORCE_OFF = 0x80000000 Global Const $SHACF_AUTOAPPEND_FORCE_ON = 0x40000000 Global Const $SHACF_AUTOSUGGEST_FORCE_OFF = 0x20000000 Global Const $SHACF_AUTOSUGGEST_FORCE_ON = 0x10000000 Global Const $SHACF_DEFAULT = 0x00000000 Global Const $SHACF_FILESYS_ONLY = 0x00000010 Global Const $SHACF_FILESYS_DIRS = 0x00000020 Global Const $SHACF_FILESYSTEM = 0x00000001 Global Const $SHACF_URLHISTORY = 0x00000002 Global Const $SHACF_URLMRU = 0x00000004 Global Const $SHACF_USETAB = 0x00000008 Global Const $SHACF_URLALL = BitOR($SHACF_URLHISTORY, $SHACF_URLMRU) Global Const $SHACF_VIRTUAL_NAMESPACE = 0x00000040 ; #FUNCTION# =========================================================================================================== ; Name...........: __WinAPI_SHAutoComplete ; Description ...: Instructs system edit controls to use AutoComplete to help complete URLs or file system paths in a ; Input or ComboBoxEx control. ; Syntax.........: __WinAPI_SHAutoComplete ( $hWnd [, $dwFlag = $SHACF_DEFAULT] ) ; Parameters ....: $hWnd - Handle of parent window ; $dwFlags - The flags to control the operation of SHAutoComplete: ; | $SHACF_AUTOAPPEND_FORCE_OFF - Ignore the registry default and force the AutoAppend feature off. ; This flag must be used in combination with one or more of the ; SHACF_FILESYS* or SHACF_URL* flags. ; | $SHACF_AUTOAPPEND_FORCE_ON - Ignore the registry value and force the AutoAppend feature on. The ; completed string will be displayed in the edit box with the added ; characters highlighted. This flag must be used in combination with ; one or more of the SHACF_FILESYS* or SHACF_URL* flags. ; |$SHACF_AUTOSUGGEST_FORCE_OFF - Ignore the registry default and force the AutoSuggest feature off. ; This flag must be used in combination with one or more of the ; SHACF_FILESYS* or SHACF_URL* flags. ; |$SHACF_AUTOSUGGEST_FORCE_ON - Ignore the registry value and force the AutoSuggest feature on. A ; selection of possible completed strings will be displayed as a ; drop-down list, below the edit box. ; This flag must be used in combination with one or more of the ; SHACF_FILESYS* or SHACF_URL* flags. ; |$SHACF_DEFAULT - The default setting, equivalent to SHACF_FILESYSTEM + SHACF_URLALL. ; SHACF_DEFAULT cannot be combined with any other flags. ; |$SHACF_FILESYS_ONLY - Include the file system only. ; |$SHACF_FILESYS_DIRS - Include the file system and directories, UNC servers, and UNC server ; shares. ; |$SHACF_FILESYSTEM - Include the file system and the rest of the Shell (Desktop, Computer, ; and Control Panel, for example). ; |$SHACF_URLHISTORY - Include the URLs in the user's History list. ; |$SHACF_URLMRU - Include the URLs in the user's Recently Used list. ; |$SHACF_USETAB - Allow the user to select from the autosuggest list by pressing the ; TAB key. If this flag is not set, pressing the TAB key will shift ; focus to the next control and close the autosuggest list. If ; SHACF_USETAB is set, pressing the TAB key will select the first item ; in the list. Pressing TAB again will select the next item in the list, ; and so on. When the user reaches the end of the list, the next TAB key ; press will cycle the focus back to the edit control. This flag must be ; used in combination with one or more of the SHACF_FILESYS* or ; SHACF_URL* flags listed on this page. ; |$SHACF_URLALL - Include the URLs in the users History and Recently Used lists. ; Equivalent to SHACF_URLHISTORY + SHACF_URLMRU. ; |$SHACF_VIRTUAL_NAMESPACE ; Author ........: Subz ; Remarks .......: The first four flags are used to override the Internet Explorer registry settings. The user can change these ; settings manually by launching the Internet Options property sheet from the Tools menu and clicking the ; Advanced tab. ; https://msdn.microsoft.com/en-us/library/windows/desktop/bb759862(v=vs.85).aspx ; =============================================================================================================================== Func __WinAPI_SHAutoComplete($hWnd, $dwFlags = $SHACF_DEFAULT) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local $hWndEdit, $aResult Switch _WinAPI_GetClassName($hWnd) Case 'ComboBoxEx32' $hWndEdit = _GUICtrlComboBoxEx_GetEditControl($hWnd) Case 'Edit' $hWndEdit = $hWnd Case Else Return EndSwitch $aResult = DllCall('shlwapi.dll', 'long', 'SHAutoComplete', 'hwnd', $hWndEdit, 'int', $dwFlags) If @error Or Not $aResult[0] Then Return SetError(@error, @extended, '') Return SetExtended($aResult[0], $aResult[2]) EndFunc ;==>__WinAPI_SHAutoComplete Global $hGui_FileSystem Global $hGui_WebHistory Example() Func Example() ; Create GUI $hGui = GUICreate('Example', 600, 100) GUICtrlCreateLabel('Website History:', 5, 5, 150, 21) $hGui_WebHistory = GUICtrlCreateInput('http://', 2, 2, 380, 21) __WinAPI_SHAutoComplete($hGui_WebHistory, BitOR($SHACF_AUTOAPPEND_FORCE_ON, $SHACF_URLHISTORY, $SHACF_USETAB)) $hGui_FileSystem = _GUICtrlComboBoxEx_Create($hGui, "", 2, 42, 396, 120) GUISetState(@SW_SHOW) _GUICtrlComboBoxEx_BeginUpdate($hGui_FileSystem) _GUICtrlComboBoxEx_AddDir($hGui_FileSystem, @WindowsDir & "\*.exe") _GUICtrlComboBoxEx_EndUpdate($hGui_FileSystem) __WinAPI_SHAutoComplete($hGui_FileSystem, BitOR($SHACF_AUTOAPPEND_FORCE_ON, $SHACF_FILESYSTEM, $SHACF_USETAB)) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example1 point -
Multiple Arrays needed?
FrancescoDiMuro reacted to Jos for a topic
Ever considered that it also could be the receiver of the message that is misinterpreting the send message? To me, only facts were listed.... You might not like that, but hey that really is your problem. We are here in a community with many none English folks, so many will simply translate the word without considering the emotions of the receiver as they do not master the Language enough to even know that words could have a different "emotional" meaning. Same counts for you: When somebody reacts like that you could simply think "fuck it" and ignore that member and keep on doing what you enjoy. That is basically what I do each day around here. Just my 2 cents (from another none English person) Jos1 point -
If Win (Does Not) Exist Question
FrancescoDiMuro reacted to Jos for a topic
Post split into new topic as that is better than posting in an 14 year old thread. Jos1 point -
$str = "AX 123 26OCT ABC 23 1800 UHS TIM XON LIST A12B20C213" msgbox(0, '' , Execute(StringRegExpReplace(stringmid($str , stringinstr($str , " " , 0 , -1) + 1) , "\D" , "+")))1 point
-
A small refactoring.... #include-Once ; https://www.autoitscript.com/forum/topic/82353-dual-monitor-resolution-detection/?do=findComment&comment=1405494 #AutoIt3Wrapper_Run_AU3Check=Y #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 Global $__g_aMonitorList[1][5] $__g_aMonitorList[0][0] = 0 ; For testing - uncomment following line 'CTRL+Q in SciTE4AutoIt' ;~ If Not @Compiled Then _Example_ShowMonitorInfo() ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Example_ShowMonitorInfo ; Description ...: Show the info in $__g_aMonitorList in a msgbox (line 0 is entire screen) ; Syntax ........: _Example_ShowMonitorInfo() ; Parameters ....: None ; Return values .: None ; Author ........: xrxca (autoit@forums.xrx.ca) ; Modified ......: mLipok ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Example_ShowMonitorInfo() If $__g_aMonitorList[0][0] == 0 Then _GetMonitors() Local $sMessage = "" For $i = 0 To $__g_aMonitorList[0][0] $sMessage &= $i & " - L:" & $__g_aMonitorList[$i][1] & ", T:" & $__g_aMonitorList[$i][2] $sMessage &= ", R:" & $__g_aMonitorList[$i][3] & ", B:" & $__g_aMonitorList[$i][4] If $i < $__g_aMonitorList[0][0] Then $sMessage &= @CRLF Next MsgBox(0, $__g_aMonitorList[0][0] & " Monitors: ", $sMessage) EndFunc ;==>_Example_ShowMonitorInfo ; #FUNCTION# ==================================================================================================================== ; Name ..........: _MaxOnMonitor ; Description ...: Maximize a window on a specific monitor (or the monitor the mouse is on) ; Syntax ........: _MaxOnMonitor($sTitle[, $sText = ''[, $iMonitor = -1]]) ; Parameters ....: $sTitle - a string value. The title/hWnd/class of the window to Move/Maximize ; $sText - [optional] a string value. Default is ''. The text of the window to Move/Maximize ; $iMonitor - [optional] an integer value. Default is -1. The monitor, to which window should be moved (1..NumMonitors). Use default -1 to select monitor on which mouse is on ; Return values .: None, or sets the @error flag to non-zero if the window is not found. ; Author ........: xrxca (autoit@forums.xrx.ca) ; Modified ......: mLipok ; Remarks .......: ; Related .......: WinGetHandle ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _MaxOnMonitor($sTitle, $sText = '', $iMonitor = -1) _CenterOnMonitor($sTitle, $sText, $iMonitor) If @error Then Return SetError(@error, @extended) WinSetState($sTitle, $sText, @SW_MAXIMIZE) EndFunc ;==>_MaxOnMonitor ; #FUNCTION# ==================================================================================================================== ; Name ..........: _CenterOnMonitor ; Description ...: Center a window on a specific monitor (or the monitor the mouse is on) ; Syntax ........: _CenterOnMonitor($Title[, $sText = ''[, $iMonitor = -1]]) ; Parameters ....: $Title - an unknown value. The title/hWnd/class of the window to center on monitor ; $sText - [optional] a string value. Default is ''. The text of the window to center on monitor ; $iMonitor - [optional] an integer value. Default is -1. The monitor, to which window should be moved (1..NumMonitors). Use default -1 to select monitor on which mouse is on ; Return values .: None, or sets the @error flag to non-zero if the window is not found. ; Author ........: xrxca (autoit@forums.xrx.ca) ; Modified ......: mLipok ; Remarks .......: Should probably have specified return/error codes but haven't put them in yet ; Remarks .......: ; Related .......: WinGetHandle ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _CenterOnMonitor($Title, $sText = '', $iMonitor = -1) Local $hWindow = WinGetHandle($Title, $sText) If @error Then Return SetError(1) If $iMonitor == -1 Then $iMonitor = _GetMonitorFromPoint() If $__g_aMonitorList[0][0] == 0 Then _GetMonitors() If ($iMonitor > 0) And ($iMonitor <= $__g_aMonitorList[0][0]) Then ; Restore the window if necessary Local $WinState = WinGetState($hWindow) If BitAND($WinState, 16) Or BitAND($WinState, 32) Then WinSetState($hWindow, '', @SW_RESTORE) EndIf Local $WinSize = WinGetPos($hWindow) Local $x = Int(($__g_aMonitorList[$iMonitor][3] - $__g_aMonitorList[$iMonitor][1] - $WinSize[2]) / 2) + $__g_aMonitorList[$iMonitor][1] Local $y = Int(($__g_aMonitorList[$iMonitor][4] - $__g_aMonitorList[$iMonitor][2] - $WinSize[3]) / 2) + $__g_aMonitorList[$iMonitor][2] WinMove($hWindow, '', $x, $y) EndIf EndFunc ;==>_CenterOnMonitor ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GetMonitorFromPoint ; Description ...: Get a monitor number from an x/y pos or the current mouse position ; Syntax ........: _GetMonitorFromPoint([$XorPoint = 0[, $y = 0]]) ; Parameters ....: $XorPoint - [optional] an unknown value. Default is 0. X Position or Array with X/Y as items 0,1 (ie from MouseGetPos()) ; $y - [optional] an unknown value. Default is 0. Y Position ; Return values .: $iMonitor, or set @error to 1 ; Author ........: xrxca (autoit@forums.xrx.ca) ; Modified ......: mLipok ; Remarks .......: Used to use MonitorFromPoint DLL call, but it didn't seem to always work. ; Related .......: MouseGetPos ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _GetMonitorFromPoint($XorPoint = 0, $y = 0) Local $i_MouseX, $i_MouseY If @NumParams = 0 Then Local $aMousePos = MouseGetPos() $i_MouseX = $aMousePos[0] $i_MouseY = $aMousePos[1] ElseIf (@NumParams = 1) And IsArray($XorPoint) Then If UBound($XorPoint) <> 2 Then Return SetError(1, 1) $i_MouseX = $XorPoint[0] If Not IsInt($i_MouseX) Then Return SetError(2, 2) $i_MouseY = $XorPoint[1] If Not IsInt($i_MouseY) Then Return SetError(2, 3) Else If Not IsInt($XorPoint) Then Return SetError(2, 1) If Not IsInt($y) Then Return SetError(2, 2) $i_MouseX = $XorPoint $i_MouseY = $y EndIf If $__g_aMonitorList[0][0] == 0 Then _GetMonitors() Local $iMonitor = 0 For $i = 1 To $__g_aMonitorList[0][0] If ($i_MouseX >= $__g_aMonitorList[$i][1]) _ And ($i_MouseX < $__g_aMonitorList[$i][3]) _ And ($i_MouseY >= $__g_aMonitorList[$i][2]) _ And ($i_MouseY < $__g_aMonitorList[$i][4]) Then $iMonitor = $i Next Return $iMonitor EndFunc ;==>_GetMonitorFromPoint ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GetMonitors ; Description ...: Load monitor positions ; Syntax ........: _GetMonitors() ; Parameters ....: None ; Return values .: $__g_aMonitorList and 2D Array of Monitors ; [0][0] = Number of Monitors ; [i][0] = HMONITOR handle of this monitor. ; [i][1] = Left Position of Monitor ; [i][2] = Top Position of Monitor ; [i][3] = Right Position of Monitor ; [i][4] = Bottom Position of Monitor ; Author ........: xrxca (autoit@forums.xrx.ca) ; Modified ......: mLipok ; Remarks .......: [0][1..4] are set to Left,Top,Right,Bottom of entire screen ; hMonitor is returned in [i][0], but no longer used by these routines. ; Also sets $__g_aMonitorList Global variable (for other subs to use) ; Related .......: ; Link ..........: ; Example .......: _Example_ShowMonitorInfo() ; =============================================================================================================================== Func _GetMonitors() $__g_aMonitorList[0][0] = 0 ; Added so that the global array is reset if this is called multiple times Local $handle = DllCallbackRegister(__MonitorEnumProc, "int", "hwnd;hwnd;ptr;lparam") DllCall("user32.dll", "int", "EnumDisplayMonitors", "hwnd", 0, "ptr", 0, "ptr", DllCallbackGetPtr($handle), "lparam", 0) DllCallbackFree($handle) For $i = 1 To $__g_aMonitorList[0][0] If $__g_aMonitorList[$i][1] < $__g_aMonitorList[0][1] Then $__g_aMonitorList[0][1] = $__g_aMonitorList[$i][1] If $__g_aMonitorList[$i][2] < $__g_aMonitorList[0][2] Then $__g_aMonitorList[0][2] = $__g_aMonitorList[$i][2] If $__g_aMonitorList[$i][3] > $__g_aMonitorList[0][3] Then $__g_aMonitorList[0][3] = $__g_aMonitorList[$i][3] If $__g_aMonitorList[$i][4] > $__g_aMonitorList[0][4] Then $__g_aMonitorList[0][4] = $__g_aMonitorList[$i][4] Next Return $__g_aMonitorList EndFunc ;==>_GetMonitors ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: __MonitorEnumProc ; Description ...: Enum Callback Function for EnumDisplayMonitors in _GetMonitors ; Syntax ........: __MonitorEnumProc($hMonitor, $hDC, $lRect, $lParam) ; Parameters ....: $hMonitor - a handle value. ; $hDC - a handle value. ; $lRect - an unknown value. ; $lParam - an unknown value. ; Return values .: 1 and set $__g_aMonitorList ; Author ........: xrxca (autoit@forums.xrx.ca) ; Modified ......: mLipok ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func __MonitorEnumProc($hMonitor, $hDC, $lRect, $lParam) #forceref $hDC, $lParam Local $tRect = DllStructCreate("int left;int top;int right;int bottom", $lRect) $__g_aMonitorList[0][0] += 1 ReDim $__g_aMonitorList[$__g_aMonitorList[0][0] + 1][5] $__g_aMonitorList[$__g_aMonitorList[0][0]][0] = $hMonitor $__g_aMonitorList[$__g_aMonitorList[0][0]][1] = DllStructGetData($tRect, "left") $__g_aMonitorList[$__g_aMonitorList[0][0]][2] = DllStructGetData($tRect, "top") $__g_aMonitorList[$__g_aMonitorList[0][0]][3] = DllStructGetData($tRect, "right") $__g_aMonitorList[$__g_aMonitorList[0][0]][4] = DllStructGetData($tRect, "bottom") Return 1 ; Return 1 to continue enumeration EndFunc ;==>__MonitorEnumProc1 point