Jump to content
rm4453

File Open Keeps Repeating Itself.

Recommended Posts

rm4453

I have a problem with my code where the File Open keeps opening itself... This gui is not fully functional. I am trying to allow the user to select an image for each of the image buttons, when they do all I want to grab is the full file path ex: C:\windows\user\username\images\image.jpg to a variable. "I am just diving into guis myself and have used Koda for most of this form generation. The custom code I have either written myself " most of it " or got help for it on here or the help files. I have searched for at least an hour now and can't seem to figure out what is causing the infinite loop where the file open box continually opens... I am sure its something simple like changing the state of the button that was clicked back to not clicked however I can't figure out how to do that or if that is even the answer... Here is all of the code I can share "This is an NDA project so I will have to take some parts out that are non pertinent etc...."  (ANY * are edits to protect the NDA any missing lines are as well.... :D)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <***Login.au3>

$section = "Test"
$Item_Wanted = "false"
$For_Sale = "true"
$Business_Listing = "false"
$Private_Listing = "true"
$Posts = 0
$Submit = 0
$SaveListingSettings = 0
$Image1_Description = 0
$Image2_Description = 0
$Image3_Description = 0
$Image4_Description = 0
$Image5_Description = 0
$Image6_Description = 0
$Description1 = 0
$Description2 = 0
$Description3 = 0
$Description4 = 0
$Image1_Pressed = 0

; AutoItSetOption ("GUIOnEventMode", 1)

Func ReadIni()

;Login Info
Global $Email_ini = IniRead("Settings.ini", $section, "Email", "Email")
Global $Password_ini = IniRead("Settings.ini", $section, "Password", "Password")

;Listing Info
Global $Price_ini = IniRead("Settings.ini", $section, "Price", "0")
Global $Title_ini = IniRead("Settings.ini", $section, "Title", "Title Example")

  ;Listing Type
Global $For_Sale_ini = IniRead("Settings.ini", $section, "For_Sale", "True")
Global $Item_Wanted_ini = IniRead("Settings.ini", $section, "Item_Wanted", "False")

If $For_Sale_ini = "false" Then
    GUICtrlSetState($Item_Wanted, 1)
Else
    If $For_Sale_ini = "true" Then
        GUICtrlSetState($For_Sale, 1)
    EndIf
EndIf


  ;Business Or Private
Global $Business_Listing_ini = IniRead("Settings.ini", $section, "Business_Listing", "False")
Global $Private_Listing_ini = IniRead("Settings.ini", $section, "Private_Listing", "True")

If $Private_Listing_ini = "false" Then
    GUICtrlSetState($Business_Listing, 1)
Else
    If $Private_Listing_ini = "true" Then
        GUICtrlSetState($Private_Listing, 1)
    EndIf
EndIf


  ;Image FilePaths and Descriptions
Global $Image1_ini = IniRead("Settings.ini", $section, "Image1", "C:\image1.jpg")
Global $Image1_Description_ini = IniRead("Settings.ini", $section, "Image1_Description", "Default Descrip")
Global $Image2_ini = IniRead("Settings.ini", $section, "Image2", "C:\image2.jpg")
Global $Image2_Description_ini = IniRead("Settings.ini", $section, "Image2_Description", "Default Descrip")
Global $Image3_ini = IniRead("Settings.ini", $section, "Image3", "C:\image3.jpg")
Global $Image3_Description_ini = IniRead("Settings.ini", $section, "Image3_Description", "Default Descrip")
Global $Image4_ini = IniRead("Settings.ini", $section, "Image4", "C:\image4.jpg")
Global $Image4_Description_ini = IniRead("Settings.ini", $section, "Image4_Description", "Default Descrip")
Global $Image5_ini = IniRead("Settings.ini", $section, "Image5", "C:\image5.jpg")
Global $Image5_Description_ini = IniRead("Settings.ini", $section, "Image5_Description", "Default Descrip")
Global $Image6_ini = IniRead("Settings.ini", $section, "Image6", "C:\image6.jpg")
Global $Image6_Description_ini = IniRead("Settings.ini", $section, "Image6_Description", "Default Descrip")

  ;Listing Descriptions
Global $Description1_ini = IniRead("Settings.ini", $section, "Description1", "Default Descrip")
Global $Description2_ini = IniRead("Settings.ini", $section, "Description2", "Default Descrip")
Global $Description3_ini = IniRead("Settings.ini", $section, "Description3", "Default Descrip")
Global $Description4_ini = IniRead("Settings.ini", $section, "Description4", "Default Descrip")

  ;Contact Info
Global $Phone1_ini = IniRead("Settings.ini", $section, "Phone1", "888")
Global $Phone2_ini = IniRead("Settings.ini", $section, "Phone2", "999")
Global $Phone3_ini = IniRead("Settings.ini", $section, "Phone3", "9090")
Global $Address_ini = IniRead("Settings.ini", $section, "Address", "491 S 231 E")
Global $City_ini = IniRead("Settings.ini", $section, "City", "Sandy")
Global $State_ini = IniRead("Settings.ini", $section, "State", "WA")
Global $Zip_ini = IniRead("Settings.ini", $section, "Zip", "84119")

  ;Post Interval in Minutes
Global $Post_Interval_In_Minutes_ini = IniRead("Settings.ini", $section, "Post_Interval_In_Minutes", "10")

EndFunc

Func Gui()
$***AutoPoster = GUICreate("*** Auto Poster", 615, 437, 340, 172)
$LoginInfo = GUICtrlCreateGroup("Login Info", 8, 8, 177, 113)
$Submit = GUICtrlCreateButton("Submit", 58, 84, 75, 25)


GUICtrlSetTip(-1, "Verify Login Information")
Global $Email = GUICtrlCreateInput($Email_ini, 23, 31, 145, 21)
GUICtrlSetTip(-1, "*** Email")
Global $Password = GUICtrlCreateInput($Password_ini, 23, 57, 145, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
GUICtrlSetTip(-1, "*** Password")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $ListingInfo = GUICtrlCreateGroup("Listing Info", 200, 8, 401, 417)
Global $Price = GUICtrlCreateInput($Price_ini, 232, 40, 137, 21)
GUICtrlSetTip(-1, "Asking Price For Listing")
Global $Title = GUICtrlCreateInput($Title_ini, 232, 72, 137, 21)
GUICtrlSetTip(-1, "Title Of Listing")
Global $ListingType = GUICtrlCreateGroup("Listing Type", 376, 24, 193, 81)
Global $For_Sale = GUICtrlCreateRadio("For Sale", 384, 39, 193, 21)
GUICtrlSetTip(-1, "Is Item For Sale")
Global $Item_Wanted = GUICtrlCreateRadio("Item Wanted", 384, 71, 193, 21)
GUICtrlSetTip(-1, "Are You Looking For Item")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Business_or_Private = GUICtrlCreateGroup("Business or Private", 232, 112, 337, 65)
Global $Business_Listing = GUICtrlCreateRadio("Business Listing", 248, 136, 137, 25)
GUICtrlSetTip(-1, "Is This A Business Listing")
Global $Private_Listing = GUICtrlCreateRadio("Private Listing", 408, 136, 137, 25)
GUICtrlSetTip(-1, "Is This A Private Listing")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $ContactInfo = GUICtrlCreateGroup("Contact Info", 232, 312, 337, 73)
Global $Phone1 = GUICtrlCreateInput($Phone1_ini, 237, 330, 33, 21)
GUICtrlSetTip(-1, "Phone Number Area Code")
Global $Phone3 = GUICtrlCreateInput($Phone3_ini, 317, 330, 33, 21)
GUICtrlSetTip(-1, "Last 4 Numbers Of Phone Number")
Global $Phone2 = GUICtrlCreateInput($Phone2_ini, 277, 330, 33, 21)
GUICtrlSetTip(-1, "First 3 Numbers Of Phone Number")
Global $Address = GUICtrlCreateInput($Address_ini, 360, 328, 201, 21)
GUICtrlSetTip(-1, "Address For Listing")
Global $City = GUICtrlCreateInput($City_ini, 360, 352, 49, 21)
GUICtrlSetTip(-1, "City For Listing")
Global $State = GUICtrlCreateInput($State_ini, 416, 352, 97, 21)
GUICtrlSetTip(-1, "State For Listing (Only Use Abrieviations)")
Global $Zip = GUICtrlCreateInput($Zip_ini, 520, 352, 41, 21)
GUICtrlSetTip(-1, "Zip Code For Listing")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $SaveListingSettings = GUICtrlCreateButton("Save Listing Settings", 456, 392, 114, 25)


GUICtrlSetTip(-1, "Save Listing Settings")
Global $Post_Interval_In_Minutes = GUICtrlCreateInput($Post_Interval_In_Minutes_ini, 232, 392, 209, 21)
GUICtrlSetTip(-1, "How Often Program Should Auto Post (Will Be Randomized Somewhat For Validity)")
Global $Description1_Button = GUICtrlCreateButton($Description1_ini, 232, 189, 145, 49)


Global $Description2_Button = GUICtrlCreateButton($Description2_ini, 426, 189, 145, 49)


Global $Description3_Button = GUICtrlCreateButton($Description3_ini, 232, 252, 145, 49)


Global $Description4_Button = GUICtrlCreateButton($Description4_ini, 426, 252, 145, 49)


GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Select_Images = GUICtrlCreateGroup("Select Images", 8, 136, 177, 89)
Global $Image1 = GUICtrlCreateButton($Image1_ini, 16, 160, 41, 25)


Global $Image2 = GUICtrlCreateButton($Image2_ini, 69, 160, 41, 25)


Global $Image3 = GUICtrlCreateButton($Image3_ini, 128, 160, 41, 25)


Global $Image4 = GUICtrlCreateButton($Image4_ini, 17, 192, 41, 25)


Global $Image5 = GUICtrlCreateButton($Image5_ini, 69, 192, 41, 25)


Global $Image6 = GUICtrlCreateButton($Image6_ini, 129, 192, 41, 25)


GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $PostCounter = GUICtrlCreateGroup("Post Counter", 8, 240, 177, 65)
Global $TotalPosts = GUICtrlCreateLabel("Total Posts", 32, 267, 57, 18)
Global $PostCount = GUICtrlCreateLabel($Posts, 104, 267, 50, 18)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $ListingSelection = GUICtrlCreateGroup("Listing Selection", 8, 312, 177, 113)
Global $SelectListing = GUICtrlCreateButton("Select Listing", 24, 336, 145, 33)


Global $BeginSubmission = GUICtrlCreateButton("Begin Submission", 24, 376, 145, 33)


GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
EndFunc


Func OpenImages()
    $message = "Please Find and Select Your Image."
    $var = FileOpenDialog($message, @WindowsDir & "\", "Images (*.jpg;*.gif)")
    FileChangeDir(@ScriptDir)
    Global $imagePath = $var
    ;$filepathmsg = MsgBox("Path","Here is File Path", $imagePath)
EndFunc

$Save_Section = 1
Func SaveIni()
    IniWrite ( "Settings.ini", $Save_Section, "Email", GUICtrlRead($Email))
    IniWrite ( "Settings.ini", $Save_Section, "Password", GUICtrlRead($Password))
    IniWrite ( "Settings.ini", $Save_Section, "Price", GUICtrlRead($Price))
    IniWrite ( "Settings.ini", $Save_Section, "Title", GUICtrlRead($Title))
    IniWrite ( "Settings.ini", $Save_Section, "For_Sale", GUICtrlRead($For_Sale))
    IniWrite ( "Settings.ini", $Save_Section, "Item_Wanted", GUICtrlRead($Item_Wanted))
    IniWrite ( "Settings.ini", $Save_Section, "Business_Listing", GUICtrlRead($Business_Listing))
    IniWrite ( "Settings.ini", $Save_Section, "Private_Listing", GUICtrlRead($Private_Listing))
    IniWrite ( "Settings.ini", $Save_Section, "Image1", GUICtrlRead($Image1))
    IniWrite ( "Settings.ini", $Save_Section, "Image1_Description", GUICtrlRead($Image1_Description))
    IniWrite ( "Settings.ini", $Save_Section, "Image2", GUICtrlRead($Image2))
    IniWrite ( "Settings.ini", $Save_Section, "Image2_Description", GUICtrlRead($Image2_Description))
    IniWrite ( "Settings.ini", $Save_Section, "Image3", GUICtrlRead($Image3))
    IniWrite ( "Settings.ini", $Save_Section, "Image3_Description", GUICtrlRead($Image3_Description))
    IniWrite ( "Settings.ini", $Save_Section, "Image4", GUICtrlRead($Image4))
    IniWrite ( "Settings.ini", $Save_Section, "Image4_Description", GUICtrlRead($Image4_Description))
    IniWrite ( "Settings.ini", $Save_Section, "Image5", GUICtrlRead($Image5))
    IniWrite ( "Settings.ini", $Save_Section, "Image5_Description", GUICtrlRead($Image5_Description))
    IniWrite ( "Settings.ini", $Save_Section, "Image6", GUICtrlRead($Image6))
    IniWrite ( "Settings.ini", $Save_Section, "Image6_Description", GUICtrlRead($Image6_Description))
    IniWrite ( "Settings.ini", $Save_Section, "Description1", GUICtrlRead($Description1))
    IniWrite ( "Settings.ini", $Save_Section, "Description2", GUICtrlRead($Description2))
    IniWrite ( "Settings.ini", $Save_Section, "Description3", GUICtrlRead($Description3))
    IniWrite ( "Settings.ini", $Save_Section, "Description4", GUICtrlRead($Description4))
    IniWrite ( "Settings.ini", $Save_Section, "Phone1", GUICtrlRead($Phone1))
    IniWrite ( "Settings.ini", $Save_Section, "Phone2", GUICtrlRead($Phone2))
    IniWrite ( "Settings.ini", $Save_Section, "Phone3", GUICtrlRead($Phone3))
    IniWrite ( "Settings.ini", $Save_Section, "Address", GUICtrlRead($Address))
    IniWrite ( "Settings.ini", $Save_Section, "City", GUICtrlRead($City))
    IniWrite ( "Settings.ini", $Save_Section, "State", GUICtrlRead($State))
    IniWrite ( "Settings.ini", $Save_Section, "Zip", GUICtrlRead($Zip))
    IniWrite ( "Settings.ini", $Save_Section, "Post_Interval_In_Minutes", GUICtrlRead($Post_Interval_In_Minutes))
EndFunc


$GuiOpened = 1
$im = 1

While 1 = 1
    If $GuiOpened = 1 Then
        ReadIni()
        Gui()
        ReadIni()
        $GuiOpened = 2
    EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Submit
            $email = $Email_ini
            $pass = $Password_ini
            Login()
        Case $SaveListingSettings
            $Save_Section = InputBox("Listing Name", "Please Type The Name For Your Listing", "EXAMPLE: Blue Blanket")
            SaveIni()
        Case $Image1
            OpenImages()
            Global $Image1 = $imagePath
            Global $Image1_Description = GUICtrlCreateEdit("Image Description", 615, 437, 50, 40)

    EndSwitch
WEnd

 

Edited by rm4453
Code would not insert so I Posted Topic then added Code

Share this post


Link to post
Share on other sites
Melba23

rm4453,

The first time you run the script, $Image1 is set the controlID of the button as intended - thus the Switch functions correctly. However, as soon as that button fires, you run the OpenImages functions and reset the variable to what seems to be the string returned from the FileOpenDialog call within the function:

Case $Image1
    OpenImages()
    Global $Image1 = $imagePath

As AutoIt expects a number within the Switch statement it tries to convert that string to a number - which as the string will always start with a letter - will result in $Image1 being set to 0. That is the default return from GUIGetMsg when there are no events to process - and so the $Image1 case fires on every pass.

Solution: Do not reuse variables which refer to ControlIDs.

M23

P.S. That code is, quite frankly, appallingly written - for example, you declare practically every Global variable within a function. I think a complete recast of the code would be a very good idea.

P.P.S Having just seen this line:

GUICtrlSetTip(-1, "How Often Program Should Auto Post (Will Be Randomized Somewhat For Validity)")

I have also decided that this is not a script we are prepared to support. Having to make that sort of statement leads me to believe that the site which you are attempting to spam would not approve of the script being used. Thread closed - PM me if you wish to explain why you feel I should reopen it.

M23


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

Spoiler

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

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Similar Content

    • nooneclose
      By nooneclose
      Hey. I'm working on a new project and was wondering if there is a better way to "update" my Column E array. 
      Here is my code: 
      Local $nI  = 0                                                            ;Creates a name index of 0: nI = Name index Local $nII = 1                                                            ;Creates a name index of 1 for second loop: nII = Name Index 2 For    $iN = 0 To $IndexRows Step 1                                       ;Checks the roster for any names that appear twice      For $iN2 = 0 To $IndexRows Step 1          if $d_Names[$nI] == $d_Names[$nII] And $d_Names[$nII] <> "" Then              Local $timeSheetName = _ArraySearch($e_Names, $d_Names[$nI], 0, 0, 0, 0, 1)              ;MsgBox($MB_SYSTEMMODAL, "Found it", $d_Names[$nI] & " In column E on Row " & $timeSheetName)              Local $eI  = $timeSheetName + 1              ;ConsoleWrite($timeSheetName & @CRLF)              ;ConsoleWrite($eI & @CRLF)              ;ConsoleWrite(@CRLF)              _Excel_RangeInsert($OpenWorkbook.ActiveSheet, "E" & $eI & ":F" & $eI, $xlShiftDown)                                                                          ;Inserts a empty cell in columns E and F.              _Excel_RangeWrite($OpenWorkbook, $OpenWorkbook.ActiveSheet, $d_Names[$nII], "E" & $eI)                                                                         ;Fills the empty cell in columns E with the doubled name              $aArray_Index = 2                                           ;Array element counter              For $Index = 2 To $IndexRows Step 1                        ;Loops through every row in the Excel file unto no rows are found or a null row is found                  $Array_Value_E = _Excel_RangeRead($OpenWorkbook, Default, "E"&$Index)                  $e_names[$aArray_Index] = $Array_Value_E                ;While the code loops every value in column E is stored in the E array (updating the array)                  $aArray_Index += 1              Next              ExitLoop          EndIf      Next      $nI  += 1      $nII += 1 Next Basically, It checks a roster for people whose name appears twice then inserts a new "row" for that person because they work in two different departments.
      I have to find that name however in Column E if two appear in column D. My code works but I think it is not as efficient as it could be. 
      Any ideas on how to improve the "update" for my array?
      (once it finds the double names in Column D it then searches for that name by going name by name in the Column E array and once it finds it inserts a new row. However, the E array doesn't have that new row stored in it so I have to "update" the array to properly find the next name)
      Any and all tips would be greatly appreciated. 
       
      NOTE: Just assume I'm opening the excel file properly please do not add that code in, it only complicates your answer. 
    • Miliardsto
      By Miliardsto
      Hello Im wondering if using this https://ohtejera.github.io/ImperiusAutoIt/#started
      UDF can i make that I can control my windows application with phone?
      like for example click button Start on android phone and then something would be done in my windows app?
    • nooneclose
      By nooneclose
      How do I properly convert this to Autoit? This is a VBA macro that I recorded in Excel.
       ActiveSheet.Outline.ShowLevels RowLevels:=2 I need this to close my subtotal once it is finished. 
      any help will be greatly appreciated. 
    • iMacg3
      By iMacg3
      Hi,
      I was looking into a way to delete a registry key (not a specific value, an entire key) if it is present. I was considering using RegRead and RegDelete. However, RegRead appears to only read values, not just keys. Is there a way to delete an entire registry key if it is present? I have heard that the below function may help.
       
      #include-once ; #UDF# ======================================================================================================================= ; Title .........: Reads\Search the name of a Key\Subkey\Value ; AutoIt Version : 3.3.8.1 ; Language ......: English ; Description ...: Lists all Keys\Subkeys\Values in a specified registry key ; Author(s) .....: DXRW4E ; Notes .........: ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ;~ _RegEnumKeyEx ;~ _RegEnumValEx ; =============================================================================================================================== #Region ;**** Global constants and vars **** Global Const $sValueTypes[12] = ["REG_NONE","REG_SZ","REG_EXPAND_SZ","REG_BINARY","REG_DWORD","REG_DWORD_BIG_ENDIAN","REG_LINK","REG_MULTI_SZ","REG_RESOURCE_LIST","REG_FULL_RESOURCE_DESCRIPTOR","REG_RESOURCE_REQUIREMENTS_LIST","REG_QWORD"] #EndRegion ;**** Global constants and vars **** ; #FUNCTION# ======================================================================================================================== ; Name...........: _RegEnumKeyEx ; Description ...: Lists all subkeys in a specified registry key ; Syntax.........: _RegEnumKeyEx($KeyName[, $iFlag = 0[, $sFilter = "*"]]) ; Parameters ....: $KeyName - The registry key to read. ; $iFlag - Optional specifies Recursion (add the flags together for multiple operations): ; |$iFlag = 0 (Default) All Key-SubKeys Recursive Mod ; |$iFlag = 1 All SubKeys Not Recursive Mod ; |$iFlag = 2 Include in ArrayList in the first element $KeyName ; |$iFlag = 16 $sFilter do Case-Sensitive matching (By Default $sFilter do Case-Insensitive matching) ; |$iFlag = 32 Disable the return the count in the first element - effectively makes the array 0-based (must use UBound() to get the size in this case). ; By Default the first element ($array[0]) contains the number of strings returned, the remaining elements ($array[1], $array[2], etc.) ; |$iFlag = 64 $sFilter is REGEXP Mod, See Pattern Parameters in StringRegExp ; |$iFlag = 128 Enum value's name (_RegEnumKeyEx Return a 2D array, maximum Array Size limit is 3999744 Key\Value) ; |$iFlag = 256 Reads a value data, this flag will be ignored if the $iFlag = 128 is not set ; $sFilter - Optional the filter to use, default is *. (Multiple filter groups such as "All "*.XXx|*.YYY|*.ZZZ") ; Search the Autoit3 helpfile for the word "WildCards" For details. ; $vFilter - Optional the filter to use for ValueName, $vFilter will be ignored if the $iFlag = 128 is not set ; default is *. (Multiple filter groups such as "All "*.XXx|*.YYY|*.ZZZ") Search the Autoit3 helpfile for the word "WildCards" For details. ; $iValueTypes - Optional, set Value Types to search (Default $iValueTypes = 0 Read All), $iValueTypes will be ignored if the $iFlag = 128 is not set ; (add the flags together for multiple operations): ; 1 = REG_SZ ; 2 = REG_EXPAND_SZ ; 3 = REG_BINARY ; 4 = REG_DWORD ; 5 = REG_DWORD_BIG_ENDIAN ; 6 = REG_LINK ; 7 = REG_MULTI_SZ ; 8 = REG_RESOURCE_LIST ; 9 = REG_FULL_RESOURCE_DESCRIPTOR ; 10 = REG_RESOURCE_REQUIREMENTS_LIST ; 11 = REG_QWORD ; Return values .: Success - Return Array List (See Remarks) ; Failure - @Error ; |1 = Invalid $sFilter ; |2 = No Key-SubKey(s) Found ; |3 = Invalid $vFilter ; |4 = No Value-Name(s) Found ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: The array returned is one-dimensional and is made up as follows: ; $array[0] = Number of Key-SubKeys returned ; $array[1] = 1st Key\SubKeys ; $array[2] = 2nd Key\SubKeys ; $array[3] = 3rd Key\SubKeys ; $array[n] = nth Key\SubKeys ; ; If is set the $iFlag = 128 The array returned is 2D array and is made up as follows: ; $array[0][0] = Number of Key-SubKeys returned ; $array[1][0] = 1st Key\SubKeys ; $array[1][1] = 1st Value name ; $array[1][2] = 1st Value Type (REG_NONE or REG_SZ or REG_EXPAND_SZ ect ect) ; $array[1][3] = 1st Value Data (If is set $iFlag = 256 Else Value Data = "") ; $array[2][0] = 2nd Key\SubKeys ; $array[2][1] = 2nd Value name ; $array[2][2] = 2nd Value Type (REG_NONE or REG_SZ or REG_EXPAND_SZ ect ect) ; $array[2][3] = 2nd Value Data (If is set $iFlag = 256 Else Value Data = "") ; $array[n][0] = nth Key\SubKeys ; Related .......: _RegEnumValEx() ; Link ..........: ; Example .......: _RegEnumKeyEx("HKEY_CURRENT_USER\Software\AutoIt v3") ; Note ..........: ; =================================================================================================================================== Func _RegEnumKeyEx($KeyName, $iFlag = 0, $sFilter = "*", $vFilter = "*", $iValueTypes = 0) If StringRegExp($sFilter, StringReplace("^\s*$|\v|\\|^\||\|\||\|$", Chr(BitAND($iFlag, 64) + 28) & "\|^\||\|\||\|$", "\\\\")) Then Return SetError(1, 0, "") Local $IndexSubKey[101] = [100], $SubKeyName, $BS = "\", $sKeyList, $I = 1, $sKeyFlag = BitAND($iFlag, 1), $sKeyFilter = StringReplace($sFilter, "*", "") If BitAND($iFlag, 2) Then $sKeyList = @LF & $KeyName If Not BitAND($iFlag, 64) Then $sFilter = StringRegExpReplace(BitAND($iFlag, 16) & "(?i)(", "16\(\?\i\)|\d+", "") & StringRegExpReplace(StringRegExpReplace(StringRegExpReplace(StringRegExpReplace($sFilter, "[^*?|]+", "\\Q$0\\E"), "\\E(?=\||$)", "$0\$"), "(?<=^|\|)\\Q", "^$0"), "\*+", ".*") & ")" While $I $IndexSubKey[$I] += 1 $SubKeyName = RegEnumKey($KeyName, $IndexSubKey[$I]) If @error Then $IndexSubKey[$I] = 0 $I -= 1 $KeyName = StringLeft($KeyName, StringInStr($KeyName, "\", 1, -1) - 1) ContinueLoop EndIf If $sKeyFilter Then If StringRegExp($SubKeyName, $sFilter) Then $sKeyList &= @LF & $KeyName & $BS & $SubKeyName Else $sKeyList &= @LF & $KeyName & $BS & $SubKeyName EndIf If $sKeyFlag Then ContinueLoop $I += 1 If $I > $IndexSubKey[0] Then $IndexSubKey[0] += 100 ReDim $IndexSubKey[$IndexSubKey[0] + 1] EndIf $KeyName &= $BS & $SubKeyName WEnd If Not $sKeyList Then Return SetError(2, 0, "") If BitAND($iFlag, 128) <> 128 Then Return StringSplit(StringTrimLeft($sKeyList, 1), @LF, StringReplace(BitAND($iFlag, 32), "32", 2)) $sKeyList = _RegEnumValEx(StringSplit(StringTrimLeft($sKeyList, 1), @LF), $iFlag, $vFilter, $iValueTypes) Return SetError(@Error, 0, $sKeyList) EndFunc ; #FUNCTION# ======================================================================================================================== ; Name...........: _RegEnumValEx ; Description ...: Lists all values in a specified registry key ; Syntax.........: _RegEnumValEx($KeyName[, $iFlag = 0[, $sFilter = "*"]]) ; Parameters ....: $KeyName - The registry key to read Or one-dimensional array RegKeyList ; use _RegEnumKeyEx() to get $RegKeyList (example $RegKeyList = [3, 1st Key\SubKeys, 2st Key\SubKeys, nth Key\SubKeys]) ; |$iFlag = 16 $sFilter do Case-Sensitive matching (By Default $sFilter do Case-Insensitive matching) ; |$iFlag = 32 Disable the return the count in the first element - effectively makes the array 0-based (must use UBound() to get the size in this case). ; By Default the first element ($array[0]) contains the number of strings returned, the remaining elements ($array[1], $array[2], etc.) ; |$iFlag = 64 $sFilter is REGEXP Mod, See Pattern Parameters in StringRegExp ; |$iFlag = 256 Reads a value data ; $sFilter - Optional the filter to use, default is *. (Multiple filter groups such as "All "*.XXx|*.YYY|*.ZZZ") ; Search the Autoit3 helpfile for the word "WildCards" For details. ; $iValueTypes - Optional, set Value Types to search (Default $iValueTypes = 0 Read All) ; (add the flags together for multiple operations): ; 1 = REG_SZ ; 2 = REG_EXPAND_SZ ; 3 = REG_BINARY ; 4 = REG_DWORD ; 5 = REG_DWORD_BIG_ENDIAN ; 6 = REG_LINK ; 7 = REG_MULTI_SZ ; 8 = REG_RESOURCE_LIST ; 9 = REG_FULL_RESOURCE_DESCRIPTOR ; 10 = REG_RESOURCE_REQUIREMENTS_LIST ; 11 = REG_QWORD ; Return values .: Success - Return Array List (See Remarks) ; Failure - @Error ; |3 = Invalid $sFilter ; |4 = No Value-Name(s) Found ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: The array returned is 2D array and is made up as follows: ; $array[0][0] = Number of Key-SubKeys returned ; $array[1][0] = 1st Key\SubKeys ; $array[1][1] = 1st Value name ; $array[1][2] = 1st Value Type (REG_NONE or REG_SZ or REG_EXPAND_SZ ect ect) ; $array[1][3] = 1st Value Data (If is set $iFlag = 256 Else Value Data = "") ; $array[2][0] = 2nd Key\SubKeys ; $array[2][1] = 2nd Value name ; $array[2][2] = 2nd Value Type (REG_NONE or REG_SZ or REG_EXPAND_SZ ect ect) ; $array[2][3] = 2nd Value Data (If is set $iFlag = 256 Else Value Data = "") ; $array[n][0] = nth Key\SubKeys ; Related .......: _RegEnumKeyEx() ; Link ..........: ; Example .......: _RegEnumValEx("HKEY_CURRENT_USER\Software\AutoIt v3") ; Note ..........: ; =================================================================================================================================== Func _RegEnumValEx($aKeyList, $iFlag = 0, $sFilter = "*", $iValueTypes = 0) If StringRegExp($sFilter, "\v") Then Return SetError(3, 0, "") If Not IsArray($aKeyList) Then $aKeyList = StringSplit($aKeyList, @LF) Local $aKeyValList[1954][4], $iKeyVal = Int(BitAND($iFlag, 32) = 0), $sKeyVal = 1953, $sRegEnumVal, $iRegEnumVal, $RegRead = BitAND($iFlag, 256), $vFilter = StringReplace($sFilter, "*", "") If Not BitAND($iFlag, 64) Then $sFilter = StringRegExpReplace(BitAND($iFlag, 16) & "(?i)(", "16\(\?\i\)|\d+", "") & StringRegExpReplace(StringRegExpReplace(StringRegExpReplace(StringRegExpReplace($sFilter, "[^*?|]+", "\\Q$0\\E"), "\\E(?=\||$)", "$0\$"), "(?<=^|\|)\\Q", "^$0"), "\*+", ".*") & ")" For $i = 1 To $aKeyList[0] $iRegEnumVal = 0 While 1 If $iKeyVal = $sKeyVal Then If $sKeyVal = 3999744 Then ExitLoop $sKeyVal *= 2 ReDim $aKeyValList[$sKeyVal + 1][4] EndIf $aKeyValList[$iKeyVal][0] = $aKeyList[$i] $iRegEnumVal += 1 $sRegEnumVal = RegEnumVal($aKeyList[$i], $iRegEnumVal) If @Error <> 0 Then If $iRegEnumVal = 1 And $vFilter = "" Then $iKeyVal += 1 ExitLoop EndIf $aKeyValList[$iKeyVal][2] = $sValueTypes[@Extended] If BitAND(@Extended, $iValueTypes) <> $iValueTypes Then ContinueLoop If $vFilter And Not StringRegExp($sRegEnumVal, $sFilter) Then ContinueLoop $aKeyValList[$iKeyVal][1] = $sRegEnumVal If $RegRead Then $aKeyValList[$iKeyVal][3] = RegRead($aKeyList[$i], $sRegEnumVal) $iKeyVal += 1 WEnd Next $sRegEnumVal = $iKeyVal - Int(BitAND($iFlag, 32) = 0) If Not $sRegEnumVal Or ($sRegEnumVal = 1 And $vFilter = "" And $aKeyValList[$iKeyVal - $sRegEnumVal][2] = "") Then Return SetError(4, 0, "") ReDim $aKeyValList[$iKeyVal][4] If Not BitAND($iFlag, 32) Then $aKeyValList[0][0] = $iKeyVal - 1 Return $aKeyValList EndFunc Thanks.
       
    • great77
      By great77
      ; put the root in a variable $sRoot = "C:\Project\PHexample\" Global $sCurrentTime = _NowCalc() ; We can use that variable here Global $aList = _FileListToArray($sRoot, Default, 2) If @error Then Exit ;;;;;;MsgBox(0, "Error", "_FileListToArray returned @error = " & @error) ;;;;;;;;;;;This is a loop that runs from 1 to the number of items listed in the first element of the returned  array For $i = 1 To UBound($aList) - 1     MsgBox(0, "Folder date", $sRoot & "" & $aList[$i] & @CRLF & @CRLF & FileGetTime($sRoot & "" & $aList[$i], 1, 1))     MsgBox(0, "Folder date", FileGetTime($sRoot & "" & $aList[$i], 1, 1))      $a_filenew = StringReplace(StringReplace(StringReplace(_NowCalc(), "/", ""), ":", ""), " ", "")       MsgBox(0, "Folder date", $a_filenew) $adex =  _DateDiff('D', FileGetTime($sRoot & "" & $aList[$i], 1, 1), $a_filenew)  MsgBox(0,"ade", $adex) Next I have a code as seen above, but the difference in time is returning zero. I understand that the date yyyymmddhhmmss but how can I find the difference.
      The purpose is to try find the difference in days. Any suggestion?  
×