Jump to content

Update Script to use new database


Recommended Posts

Hello

we recently migrated off our old fileserver and moved everything over to a new file server (under another name) so rather than \\fp1 the server is now \\fp2

we have a script (i'm very new to autoit) that we use that is still pointing to the old server. how do i go about updating where it looks?

the exe file seems to reference an AU3 file that seems to reference a txt file all in the same location.

i need assistance on this asap

Link to comment
Share on other sites

  • Moderators

KrisTaracad,

Welcome to the AutoIt forums.

If that is the only change than just altering all instances of \\fp1 within the script file you use to create the executable to \\fp2 should do the trick.

M23

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

Open spoiler to see my UDFs:

Spoiler

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

 

Link to comment
Share on other sites

  • Moderators

KrisTaracad,

An AutoIt executable does not use the external AutoIt interpreter to run - it is self-contained. Do you have the original source file?

M23

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

Open spoiler to see my UDFs:

Spoiler

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

 

Link to comment
Share on other sites

Just now, KrisTaracad said:

I'm not sure what source files look like. i have a bunch of au3 files. what should i look for?

Here you have serious problems my friend, you should find an IT Specialist to help you.

Regards
Alien.

Link to comment
Share on other sites

  • Moderators

KrisTaracad,

if you send them all to me via PM (look for the "envelope" icon at top right of the page) I will take a look and see if I can do anything.

M23

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

Open spoiler to see my UDFs:

Spoiler

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

 

Link to comment
Share on other sites

Hi M23

sorry for messaging you directly.

so i was able to use the converter to generate the executable file but i get an error message when launching the exe file that says

 

---------------------------
AutoIt Error
---------------------------
Line 0:

Case $SIDTYPEUSER

Error: "Case" statement with no matching "Select" statement.
---------------------------
OK   
---------------------------
 

do you think something is wrong with my source au3 file?

Link to comment
Share on other sites

  • Moderators

KrisTaracad,

Indeed I do! As I suggested before, PM me the file (or post it here if you prefer - see here how to do it - and I will take look.

M23

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

Open spoiler to see my UDFs:

Spoiler

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

 

Link to comment
Share on other sites

i fear the au3 file i'm using to compile is an old one using an older version of the scripting software and some of the commands used in it are no longer working with version 3 of the software which is what I installed to convert it

I'll wait for your response M23

Link to comment
Share on other sites

  • Moderators

KrisTaracad,

1 hour ago, KrisTaracad said:

i fear the au3 file i'm using to compile is an old one using an older version of the scripting software and some of the commands used in it are no longer working with version 3 of the software which is what I installed to convert it

 

53 minutes ago, KrisTaracad said:

I feel that the include au3 files I have setup are not working correctly.

The file you PMed me looks fine - the syntax is correct and definitely v3 while the include files look to be the standard ones, although that script requires almost none of them.

But that script did not produce the error you mentioned above as there is no "Case $SIDTYPEUSER" line within it.  And it does not appear to reference any other AutoIt script files - so I am at a loss how to explain the error you received. Why do you say that it seems to "reference an AU3 file that seems to reference a txt file all in the same location"?

M23

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

Open spoiler to see my UDFs:

Spoiler

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

 

Link to comment
Share on other sites

  • Moderators

Kristaracad,

I have spent the day trying to understand the script and I now think I have a good grasp of most of what is going on inside. There are 3 HotKeys:

  • "Build_Database": This creates the database.txt file which is a list of all the files on the defined path of the server, the current copy of which is read into the script on start.
  • "Excel": This checks whether the content of the clipboard (evidently expected to be from an Excel spreadsheet) is the name of a file in the database and displays any similar names on different paths.
  • "Replace": This is more complex and depending on the clipboard content will either: Excel - do as above and then place the chosen file path in the clipboard; AutoCAD - do much as above but also prepare an AutoCAD xref command which is written to an Update. lsp file (deleting the old version).

I have rewritten the script to use some of the newer functions available in the latest AutoIt version - which significantly speeds up the execution on my machine - as well as streamlining a lot of the "stripping" code. You will need my Toast UDF (look in my sig for the link) which I have used in place the previous ProgressOn/Off commands - they were fed from within the old functions that have been replaced. All you need to do is check that the various paths are correctly set in the $sRoot, $sDatabase  & $sPassOut variables and reinstate the $sClipboard = ClipGet() lines at the start of the Excel & Replace functions.  I modified those sections for testing as you can see here:

#include <GUIConstantsEx.au3>
#include <File.au3>
#include "Toast.au3"

HotKeySet("^!x", "Excel") ;Ctrl-Alt-c
HotKeySet("^!c", "Replace") ;Ctrl-Alt-c
HotKeySet("^!b", "Build_Database") ;ctrl-alt-b

;~ Global $sRoot = "\\Server1\Design-Engineering"
;Global $sRoot = "\\3gdc01\DesignENG"
Global $sRoot = @ScriptDir

;Global $sDatabase = "\\3gdc01\DesignENG\AutoIt\FileFind\Database.txt"
;Global $sDatabase = "\\3gdc01\designeng\AutoIt\FileFind\Database.txt"
Global $sDatabase = @ScriptDir & "\Database.txt"

;Global $sPassOut = "\\3gdc01\DesignENG\AutoIt\AutoLisp\Update.lsp"
Global $sPassOut = @ScriptDir & "\Update.lsp"

Global $aFilename

Load_Database()

While 1 ; Main Wait Loop
    Sleep(10)
WEnd

Func Excel()

    ;Local $sClipboard = ClipGet()
    Local $sClipboard = "\\path1\path2\aef Pilot.dat" & Chr(13) & Chr(10)   ; Excel format

    If StringRight($sClipboard, 2) = Chr(13) & Chr(10) Then
        MsgBox($MB_SYSTEMMODAL,"You are in Excel","You are in Excel")
        $sClipboard = StringTrimRight($sClipboard, 2)
    EndIf

    ; Extract file name
    If StringInStr($sClipboard, "\") > 0 Then
        $sClipboard = StringRegExpReplace($sClipboard, "^.*\\", "")
    EndIf
    ; File all files
    Local $aFound = _ArrayFindAll($aFilename, $sClipboard)
    ; Show file sfound
    If IsArray($aFound) Then
        For $i = 0 To UBound($aFound) - 1
            MsgBox($MB_SYSTEMMODAL, "Found", $aFilename[$aFound[$i]][1] & " \" & $aFilename[$aFound[$i]][0])
        Next
    Else
        MsgBox($MB_SYSTEMMODAL, "Not Found", $sClipboard & " not found in database")
    EndIf

    ; But you do nothing with the result - is that what you want?

EndFunc   ;==>Excel

Func Replace()
    ;Local $sClipboard = ClipGet()

    ;Local $sClipboard = "\\path1\path2\aef Pilot.dat" & Chr(13) & Chr(10)  ; Excel
    Local $sClipboard = "|\\path1\path2\aef Pilot.dat|"                     ; AutoCad
    ;Local $sClipboard = ""                                                 ; Neither

    Local $sOutput = "", $hFile, $aFound

    If StringLeft($sClipboard, 1) = "|" Then ;Autocad Detected

        _Progress_On("Converting AutoCAD Data")

        $hFile = FileOpen($sPassOut, $FO_OVERWRITE)
        ; Check if file opened for reading OK ; <<<<<<<<<<<<<<<<<<<< No, open for overwriting, old version will be deleted
        If $hFile = -1 Then
            MsgBox($MB_SYSTEMMODAL, "Error", "Unable to open " & $sPassOut)
            Exit
        EndIf
        ; Remove any leading and trailing |
        $sClipboard = StringRegExpReplace($sClipboard, "^\|+(.*)\|+$", "$1")
        ; Extract file name
        If StringInStr($sClipboard, "\") > 0 Then
            $sClipboard = StringRegExpReplace($sClipboard, "^.*\\", "")
        EndIf
        ; If file does not exist
        If Not FileExists($sClipboard) Then
            ; Find all possible files
            $aFound = _ArrayFindAll($aFilename, $sClipboard)
            ; Select if more than one
            $sOutput = Filter($aFound, $sClipboard)
            ; Remove leading \ and .dwg
            $sOutPutStripped = StringRegExpReplace($sOutput, "^\\*(.*)\.dwg$", "$1")
            ; Create line
            $sOutputFinal = '(Command "xref" "p" "' & $sOutPutStripped & '" "' & StringReplace($sOutput, "\", "\\") & '")'
            ; Write to file
            FileWriteLine($hFile, $sOutputFinal)
        EndIf
        ; Tidy up
        FileClose($hFile)
        _Progress_Off()
        ClipPut("<")

        ConsoleWrite("AutoCAD - written to file: " & $sOutputFinal & @CRLF)

    ElseIf StringRight($sClipboard, 2) = Chr(13) & Chr(10) Then ; Excel detected

        MsgBox($MB_SYSTEMMODAL, "You are in Excel", "You are in Excel")

        $sClipboard = StringTrimRight($sClipboard, 2)
        ; Get file name
        If StringInStr($sClipboard, "\") > 0 Then
            $sClipboard = StringRegExpReplace($sClipboard, "^.*\\", "")
        EndIf
        ; Find file
        $aFound = _ArrayFindAll($aFilename, $sClipboard)
        ; Place file path into clipboard
        $sOutput = Filter($aFound, $sClipboard)
        ClipPut($sOutput)

        ConsoleWrite("Excel - Put in clipboard: " & $sOutput & @CRLF)

    EndIf



EndFunc   ;==>Replace

Func Filter($aFound, $sItem)

    Local $sAnswer = "", $aID, $iMsg

    If IsArray($aFound) Then
        If UBound($aFound) = 1 Then
            $sAnswer = $sItem
        Else
            $aID = $aFound
            $hWinMain = GUICreate("Clipboard Contents", @DesktopWidth - 20, @DesktopHeight - 30)
            For $i = 0 To UBound($aFound) - 1
                $aID[$i] = GUICtrlCreateButton($aFilename[$aFound[$i]][1] & "\" & $aFilename[$aFound[$i]][0], 10, ($i + 1) * 30, @DesktopWidth - 40, 30)
            Next
            GUISetState()
            While 1
                $iMsg = GUIGetMsg()
                Switch $iMsg
                    Case $GUI_EVENT_CLOSE
                        ExitLoop
                    Case Else
                        For $i = 0 To UBound($aID) - 1
                            If $iMsg = $aID[$i] Then
                                $sAnswer = $aFilename[$aFound[$i]][1] & "\" & $aFilename[$aFound[$i]][0]
                                ExitLoop 2
                            EndIf
                        Next
                EndSwitch
            WEnd
            GUIDelete($hWinMain)
        EndIf
    Else
        MsgBox($MB_SYSTEMMODAL, "Not Found", $sItem & " not found in database")
    EndIf

    Return $sAnswer

EndFunc   ;==>Filter

Func Build_Database()

    _Progress_On("Reading Directory Tree")

    $aFileNames = _FileListToArrayRec($sRoot, "*.*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH)
    ReDim $aFilename[$aFileNames[0]][2]
    For $i = 1 To $aFileNames[0]
        $aFilename[$i - 1][0] = StringRegExpReplace($aFileNames[$i], "^.*\\", "")
        $aFilename[$i - 1][1] = StringRegExpReplace($aFileNames[$i], "(^.*)\\(.*)", "\1")
    Next
    _ArraySort($aFilename)

    Save_Database()

    _Progress_Off()

EndFunc   ;==>Build_Database

Func Load_Database()

    _Progress_On("Reading Current Data")

    Sleep(1000)

    _FileReadToArray($sDatabase, $aFilename, $FRTA_NOCOUNT, "|")

    _Progress_Off()

EndFunc   ;==>Load_Database

Func Save_Database()

    _FileWriteFromArray($sDatabase, $aFilename, 1)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "Error", "Problems overwriting: " & @CRLF & $sDatabase)
        Exit
    EndIf

EndFunc   ;==>Save_Database

Func _Progress_On($sText)
    Local $aToast = _Toast_Show(0, "3G Lighting - Movable Data System", $sText & @CRLF & "Please be patient!" & @CRLF)
    GUICtrlCreateProgress(20, $aToast[1] - 25, $aToast[0] - 40, 10, 0x00000008) ; $PBS_MARQUEE
    GUICtrlSendMsg(-1, 0X40A, True, 50) ; $PBM_SETMARQUEE
EndFunc   ;==>_Progress_On

Func _Progress_Off()
    _Toast_Hide()
EndFunc   ;==>_Progress_Off

When I run this alongside your original script I get the same results - although I am only guessing at the correct format for the clipboard content. If I have guessed wrong then please let me know what would be a representative content and I will adjust the code accordingly.

M23

 

 

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

Open spoiler to see my UDFs:

Spoiler

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

 

Link to comment
Share on other sites

Hi M23

I have done the following.

Created a new script file

Ensured that all AU3 include files are located in the appropriate include directories

Add the toast.au3 file from your post to the local path

Updated the clipboard variable 

 

I receive the same error message. I'm not entirely sure what you mean by "let me know what would be a representative content" I can ask the guys that generally use this for some background info if you let me know what I should ask them. Thank you for your efforts!

Kris

Link to comment
Share on other sites

  • Moderators

KrisTaracad,

Oh dear - that does not sound good as I can obviously run the script without problem. The line giving you the error is in the include file Security.au3 - but that file is not used by the script I posted. Are you sure that there are no other .au3 files around which you might be running as well as this script?

What AutoIt version are you running? This will tell you if you do not know already:

MsgBox(0, "Version", @AutoItVersion)

A full reinstall might well be in order - but let us leave that to one side for the moment.

As to the "representative content" - could you ask the users to copy to a text file the contents of the clipboard that they would expect to have just before they use the Ctrl-Alt-X and Ctrl-Alt-C HotKeys. Then I will have actual strings to confirm that I have correctly updated the various functions.

M23

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

Open spoiler to see my UDFs:

Spoiler

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

 

Link to comment
Share on other sites

  • Moderators

KrisTaracad,

What! You do realise that version was released in February 2004! Would you run any other 12-year old software? Do you use AutoIt for other things that this particular script? Why have you never upgraded?

M23

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

Open spoiler to see my UDFs:

Spoiler

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

 

Link to comment
Share on other sites

We have taken over IT for this company and they never had IT staff that did anything to upgrade. So they are all using an old version. I don't believe they use AutoIT for anything else. I believe they only use it for the purpose of looking for file names within a folder structure. 

 

Kris

Link to comment
Share on other sites

Hi M23

This is what they do

Type in text with part of a filename or what not, then copy it to the clipboard then ctrl-alt-v then something pops up to allow them to find the file and double click on the file will copy the path to the clipboard

Does that make sense?

Kris

Link to comment
Share on other sites

Create an account or sign in to comment

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

Create an account

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

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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