Jump to content

Variable not declared


Docfxit
 Share

Recommended Posts

I'm getting an error saying "Variable used without being declared" on the variable $SourceFolder. on line 13

Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)
AutoItSetOption("TrayIconDebug", 1) ;0-off
; Set so that tray displays current line number

If _OSVersion() = 'Win7' Or _OSVersion() = 'Win7SP1' Or _OSVersion() = 'Win7X64' Or _OSVersion() = 'Win7SP1x64' Then
    $ProgramFiles = "C:\Programs\"
Else
    $ProgramFiles = "C:\Program Files\"
EndIf
_FindFile($SourceFolder) ;<<<<<< error saying "Variable used without being declared" on the variable $SourceFolder.

Run($SourceFolder & '\' & $sFileName)
WinWait("IrfanView Setup", "Create IrfanView sho")
If Not WinActive("IrfanView Setup", "Create IrfanView sho") Then WinActivate("IrfanView Setup", "Create IrfanView sho")
WinWaitActive("IrfanView Setup", "Create IrfanView sho")
Send($ProgramFiles & "\{SHIFTDOWN}i{SHIFTUP}rfanfiew{SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{DOWN}{SHIFTDOWN}{TAB}{TAB}{SHIFTUP}{SPACE}{SHIFTDOWN}{TAB}{SHIFTUP}{SPACE}{SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{ENTER}")
WinWait("IrfanView Setup", "What's new in this v")
If Not WinActive("IrfanView Setup", "What's new in this v") Then WinActivate("IrfanView Setup", "What's new in this v")
WinWaitActive("IrfanView Setup", "What's new in this v")
Send("{ENTER}")
WinWait("IrfanView Setup", "Do you want to assoc")
If Not WinActive("IrfanView Setup", "Do you want to assoc") Then WinActivate("IrfanView Setup", "Do you want to assoc")
WinWaitActive("IrfanView Setup", "Do you want to assoc")
Send("{ALTDOWN}n{ALTUP}")
WinWait("IrfanView Setup", "Include Google &Chro")
If Not WinActive("IrfanView Setup", "Include Google &Chro") Then WinActivate("IrfanView Setup", "Include Google &Chro")
WinWaitActive("IrfanView Setup", "Include Google &Chro")
Send("{SPACE}{ALTDOWN}n{ALTUP}")
WinWait("IrfanView Setup", "Destination director")
If Not WinActive("IrfanView Setup", "Destination director") Then WinActivate("IrfanView Setup", "Destination director")
WinWaitActive("IrfanView Setup", "Destination director")
Send("{ALTDOWN}n{ALTUP}")
WinWait("IrfanView Setup", "Open IrfanView &FAQs")
If Not WinActive("IrfanView Setup", "Open IrfanView &FAQs") Then WinActivate("IrfanView Setup", "Open IrfanView &FAQs")
WinWaitActive("IrfanView Setup", "Open IrfanView &FAQs")
Send("{SPACE}{ALTDOWN}d{ALTUP}")
WinWait("IrfanView Frequently Asked Questions - Mozilla Firefox", "")
If Not WinActive("IrfanView Frequently Asked Questions - Mozilla Firefox", "") Then WinActivate("IrfanView Frequently Asked Questions - Mozilla Firefox", "")
WinWaitActive("IrfanView Frequently Asked Questions - Mozilla Firefox", "")
Send("{SHIFTDOWN}{CTRLDOWN}w{SHIFTUP}{CTRLUP}")
Exit

Func _FindFile($SourceFolder)
    If FileExists("C:\Dnload\IrfanView*.exe") Then
        $SourceFolder = "C:\Dnload\"
    Else
        If FileExists("D:\Dnload\IrfanView*.exe") Then
            $SourceFolder = "D:\Dnload\"
        Else
            If FileExists("D:\Dnload\9xAddons\IrfanView*.exe") Then
                $SourceFolder = "D:\Dnload\9xAddons"
            Else
                If FileExists("C:\Dnload\9xAddons\IrfanView*.exe") Then
                    $SourceFolder = "C:\Dnload\9xAddons"
                Else
                    MsgBox(0, "Find", "IrfanView*.exe not found" & @CRLF & "Please download IrfanView.exe")
                EndIf
            EndIf
        EndIf
    EndIf

    ; Assign a Local variable the search handle of all files in the current directory.
    Local $hSearch = FileFindFirstFile($SourceFolder & "\IrfanView*.exe")
    ; Check if the search was successful, if not display a message and return False.
    If $hSearch = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Error: No files/directories matched the search pattern.")
        Return False
    EndIf

    ; Assign a Local variable the empty string which will contain the files names found.
    Local $sFileName = "", $iResult = 0

    ;While 1
    $sFileName = FileFindNextFile($hSearch)
    ; If there is no more file matching the search.
    ;       If @error Then ExitLoop

    ; Display the file name.
;   $iResult = MsgBox(BitOR($MB_SYSTEMMODAL, $MB_OKCANCEL), "", "File: " & $sFileName)
    ;       If $iResult <> $IDOK Then ExitLoop ; If the user clicks on the cancel/close button.
    ;WEnd

    ; Close the search handle.
    FileClose($hSearch)
EndFunc   ;==>FindFile

Func _OSVersion()
    Local $OS_Version, $servicepack_version
    $OS_Version = StringStripWS(StringRegExpReplace(@OSVersion, "(WIN_)|(Microsoft )|(Windows )|(\(TM\))|( Ultimate)", ""), 8)
    $OS_Version = StringRegExpReplace(StringRegExpReplace($OS_Version, '2008', 'Win7'), 'VISTA', 'Vista')
    If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", 'CurrentBuildNumber') > 7000 Then $OS_Version = 'Win7'
    $servicepack_version = StringReplace(@OSServicePack, "Service Pack ", "SP")
    If @error = -1 Then $servicepack_version = ""

    ConsoleWrite($OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '') & @CRLF)
    Return $OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '')
EndFunc   ;==>_OSVersion

I don't understand why it doesn't feel it's not declared.

Thank you,

Docfxit

Link to comment
Share on other sites

Thank you for the reply...

After declaring the $SourceFolder, I am now getting the same error on $sFileName  on line 17

That's defiantly after the function when it should have been declared.  Do I need to put the file in the func call?

Thanks,

Docfxit

Link to comment
Share on other sites

Your variables are local to the function, the rest of the script doesn't know anything about them so they're undeclared in the Global scope.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I tried to declare the two variables before the function _FindFile.

Both variables are blank on the Run line.  What am I doing wrong?

Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)
AutoItSetOption("TrayIconDebug", 1) ;0-off
; Set so that tray displays current line number

If _OSVersion() = 'Win7' Or _OSVersion() = 'Win7SP1' Or _OSVersion() = 'Win7X64' Or _OSVersion() = 'Win7SP1x64' Then
    $ProgramFiles = "C:\Programs\"
Else
    $ProgramFiles = "C:\Program Files\"
EndIf

; Assign a Local variable the empty string which will contain the files names found.
Global $sFileName = "", $iResult = 0, $SourceFolder = ""

_FindFile($SourceFolder, $sFileName) ;Find the folder IrfanView is in, And the name of the file

MsgBox(0, "File", "File to run = " & $SourceFolder & '\' & $sFileName)  ;<<<<<<  Both variables are empty
Run($SourceFolder & '\' & $sFileName)
WinWait("IrfanView Setup", "Create IrfanView sho")
If Not WinActive("IrfanView Setup", "Create IrfanView sho") Then WinActivate("IrfanView Setup", "Create IrfanView sho")
WinWaitActive("IrfanView Setup", "Create IrfanView sho")
Send($ProgramFiles & "\{SHIFTDOWN}i{SHIFTUP}rfanfiew{SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{DOWN}{SHIFTDOWN}{TAB}{TAB}{SHIFTUP}{SPACE}{SHIFTDOWN}{TAB}{SHIFTUP}{SPACE}{SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{ENTER}")
WinWait("IrfanView Setup", "What's new in this v")
If Not WinActive("IrfanView Setup", "What's new in this v") Then WinActivate("IrfanView Setup", "What's new in this v")
WinWaitActive("IrfanView Setup", "What's new in this v")
Send("{ENTER}")
WinWait("IrfanView Setup", "Do you want to assoc")
If Not WinActive("IrfanView Setup", "Do you want to assoc") Then WinActivate("IrfanView Setup", "Do you want to assoc")
WinWaitActive("IrfanView Setup", "Do you want to assoc")
Send("{ALTDOWN}n{ALTUP}")
WinWait("IrfanView Setup", "Include Google &Chro")
If Not WinActive("IrfanView Setup", "Include Google &Chro") Then WinActivate("IrfanView Setup", "Include Google &Chro")
WinWaitActive("IrfanView Setup", "Include Google &Chro")
Send("{SPACE}{ALTDOWN}n{ALTUP}")
WinWait("IrfanView Setup", "Destination director")
If Not WinActive("IrfanView Setup", "Destination director") Then WinActivate("IrfanView Setup", "Destination director")
WinWaitActive("IrfanView Setup", "Destination director")
Send("{ALTDOWN}n{ALTUP}")
WinWait("IrfanView Setup", "Open IrfanView &FAQs")
If Not WinActive("IrfanView Setup", "Open IrfanView &FAQs") Then WinActivate("IrfanView Setup", "Open IrfanView &FAQs")
WinWaitActive("IrfanView Setup", "Open IrfanView &FAQs")
Send("{SPACE}{ALTDOWN}d{ALTUP}")
WinWait("IrfanView Frequently Asked Questions - Mozilla Firefox", "")
If Not WinActive("IrfanView Frequently Asked Questions - Mozilla Firefox", "") Then WinActivate("IrfanView Frequently Asked Questions - Mozilla Firefox", "")
WinWaitActive("IrfanView Frequently Asked Questions - Mozilla Firefox", "")
Send("{SHIFTDOWN}{CTRLDOWN}w{SHIFTUP}{CTRLUP}")
Exit

Func _FindFile($SourceFolder, $sFileName)
    If FileExists("C:\Dnload\IrfanView*.exe") Then
        $SourceFolder = "C:\Dnload\"
    Else
        If FileExists("D:\Dnload\IrfanView*.exe") Then
            $SourceFolder = "D:\Dnload\"
        Else
            If FileExists("D:\Dnload\9xAddons\IrfanView*.exe") Then
                $SourceFolder = "D:\Dnload\9xAddons"
            Else
                If FileExists("C:\Dnload\9xAddons\IrfanView*.exe") Then
                    $SourceFolder = "C:\Dnload\9xAddons"
                Else
                    MsgBox(0, "Find", "IrfanView*.exe not found" & @CRLF & "Please download IrfanView.exe")
                EndIf
            EndIf
        EndIf
    EndIf

    ; Assign a Local variable the search handle of all files in the current directory.
    Local $hSearch = FileFindFirstFile($SourceFolder & "\IrfanView*.exe")
    ; Check if the search was successful, if not display a message and return False.
    If $hSearch = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Error: No files/directories matched the search pattern.")
        Return False
    EndIf

    ;While 1
    $sFileName = FileFindNextFile($hSearch)
    ; If there is no more file matching the search.
    ;       If @error Then ExitLoop

    ; Display the file name.
    ;   $iResult = MsgBox(BitOR($MB_SYSTEMMODAL, $MB_OKCANCEL), "", "File: " & $sFileName)
    ;       If $iResult <> $IDOK Then ExitLoop ; If the user clicks on the cancel/close button.
    ;WEnd

    ; Close the search handle.
    FileClose($hSearch)
EndFunc   ;==>_FindFile

Func _OSVersion()
    Local $OS_Version, $servicepack_version
    $OS_Version = StringStripWS(StringRegExpReplace(@OSVersion, "(WIN_)|(Microsoft )|(Windows )|(\(TM\))|( Ultimate)", ""), 8)
    $OS_Version = StringRegExpReplace(StringRegExpReplace($OS_Version, '2008', 'Win7'), 'VISTA', 'Vista')
    If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", 'CurrentBuildNumber') > 7000 Then $OS_Version = 'Win7'
    $servicepack_version = StringReplace(@OSServicePack, "Service Pack ", "SP")
    If @error = -1 Then $servicepack_version = ""

    ConsoleWrite($OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '') & @CRLF)
    Return $OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '')
EndFunc   ;==>_OSVersion

Thank you all for the help in figuring this out.

Docfxit

Link to comment
Share on other sites

There are a number of ways you can deal with that.

It's giving a value if it finds one to the local copy of the params you pass.

Here is one way to deal with that...

Change func body

Func _FindFile($SourceFolder, $sFileName)

To

Func _FindFile()

And remove the params from the call.

_FindFile();Find the folder IrfanView is in, And the name of the file

You are now using the global variables you declared.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

On line 33

WinWait("IrfanView Setup", "Include Google &Chro")

Sometimes during the install this window appears and sometimes it doesn't.

How can I incorporate an If statement to ignore this code and the next 3 lines after it if it doesn't appear?

Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)
AutoItSetOption("TrayIconDebug", 1) ;0-off
; Set so that tray displays current line number

If _OSVersion() = 'Win7' Or _OSVersion() = 'Win7SP1' Or _OSVersion() = 'Win7X64' Or _OSVersion() = 'Win7SP1x64' Then
    $ProgramFiles = "C:\Programs\"
Else
    $ProgramFiles = "C:\Program Files\"
EndIf

; Assign a Local variable the empty string which will contain the files names found.
Global $sFileName = "", $iResult = 0, $SourceFolder = ""

_FindFile() ;Find the folder IrfanView is in, And the name of the file

MsgBox(0, "File", "File to run = " & $SourceFolder & $sFileName)
Run($SourceFolder &  $sFileName)
WinWait("IrfanView Setup", "Create IrfanView sho")
If Not WinActive("IrfanView Setup", "Create IrfanView sho") Then WinActivate("IrfanView Setup", "Create IrfanView sho")
WinWaitActive("IrfanView Setup", "Create IrfanView sho")
Send($ProgramFiles & "\{SHIFTDOWN}i{SHIFTUP}rfanfiew{SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{DOWN}{SHIFTDOWN}{TAB}{TAB}{SHIFTUP}{SPACE}{SHIFTDOWN}{TAB}{SHIFTUP}{SPACE}{SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{ENTER}")
WinWait("IrfanView Setup", "What's new in this v")
If Not WinActive("IrfanView Setup", "What's new in this v") Then WinActivate("IrfanView Setup", "What's new in this v")
WinWaitActive("IrfanView Setup", "What's new in this v")
Send("{ENTER}")
WinWait("IrfanView Setup", "Do you want to assoc")
If Not WinActive("IrfanView Setup", "Do you want to assoc") Then WinActivate("IrfanView Setup", "Do you want to assoc")
WinWaitActive("IrfanView Setup", "Do you want to assoc")
Send("{ALTDOWN}n{ALTUP}")
WinWait("IrfanView Setup", "Include Google &Chro")
If Not WinActive("IrfanView Setup", "Include Google &Chro") Then WinActivate("IrfanView Setup", "Include Google &Chro")
WinWaitActive("IrfanView Setup", "Include Google &Chro")
Send("{SPACE}{ALTDOWN}n{ALTUP}")
WinWait("IrfanView Setup", "Destination director")
If Not WinActive("IrfanView Setup", "Destination director") Then WinActivate("IrfanView Setup", "Destination director")
WinWaitActive("IrfanView Setup", "Destination director")
Send("{ALTDOWN}n{ALTUP}")
WinWait("IrfanView Setup", "Open IrfanView &FAQs")
If Not WinActive("IrfanView Setup", "Open IrfanView &FAQs") Then WinActivate("IrfanView Setup", "Open IrfanView &FAQs")
WinWaitActive("IrfanView Setup", "Open IrfanView &FAQs")
Send("{SPACE}{ALTDOWN}d{ALTUP}")
WinWait("IrfanView Frequently Asked Questions - Mozilla Firefox", "")
If Not WinActive("IrfanView Frequently Asked Questions - Mozilla Firefox", "") Then WinActivate("IrfanView Frequently Asked Questions - Mozilla Firefox", "")
WinWaitActive("IrfanView Frequently Asked Questions - Mozilla Firefox", "")
Send("{SHIFTDOWN}{CTRLDOWN}w{SHIFTUP}{CTRLUP}")
Exit

Func _FindFile()
    If FileExists("C:\Dnload\IrfanView*.exe") Then
        $SourceFolder = "C:\Dnload\"
    Else
        If FileExists("D:\Dnload\IrfanView*.exe") Then
            $SourceFolder = "D:\Dnload\"
        Else
            If FileExists("D:\Dnload\9xAddons\IrfanView*.exe") Then
                $SourceFolder = "D:\Dnload\9xAddons"
            Else
                If FileExists("C:\Dnload\9xAddons\IrfanView*.exe") Then
                    $SourceFolder = "C:\Dnload\9xAddons"
                Else
                    MsgBox(0, "Find", "IrfanView*.exe not found" & @CRLF & "Please download IrfanView.exe")
                EndIf
            EndIf
        EndIf
    EndIf

    ; Assign a Local variable the search handle of all files in the current directory.
    Local $hSearch = FileFindFirstFile($SourceFolder & "\IrfanView*.exe")
    ; Check if the search was successful, if not display a message and return False.
    If $hSearch = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Error: No files/directories matched the search pattern.")
        Return False
    EndIf

    ;While 1
    $sFileName = FileFindNextFile($hSearch)
    ; If there is no more file matching the search.
    ;       If @error Then ExitLoop

    ; Display the file name.
    ;   $iResult = MsgBox(BitOR($MB_SYSTEMMODAL, $MB_OKCANCEL), "", "File: " & $sFileName)
    ;       If $iResult <> $IDOK Then ExitLoop ; If the user clicks on the cancel/close button.
    ;WEnd

    ; Close the search handle.
    FileClose($hSearch)
EndFunc   ;==>_FindFile

Func _OSVersion()
    Local $OS_Version, $servicepack_version
    $OS_Version = StringStripWS(StringRegExpReplace(@OSVersion, "(WIN_)|(Microsoft )|(Windows )|(\(TM\))|( Ultimate)", ""), 8)
    $OS_Version = StringRegExpReplace(StringRegExpReplace($OS_Version, '2008', 'Win7'), 'VISTA', 'Vista')
    If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", 'CurrentBuildNumber') > 7000 Then $OS_Version = 'Win7'
    $servicepack_version = StringReplace(@OSServicePack, "Service Pack ", "SP")
    If @error = -1 Then $servicepack_version = ""

    ConsoleWrite($OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '') & @CRLF)
    Return $OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '')
EndFunc   ;==>_OSVersion

Thank you,

Docfxit

 

PS:  How can I mark a line in the code to make it easier for you to find the line I am referring to?

Link to comment
Share on other sites

That is super.

Thank you very much,

When I run Tidy Windows 7 Pro sp1 64bit is giving me an error saying "Tidy you AutoIt3 scripts, has stopped working"

Running Tidy inside of SciTE 3.3.0

Does anyone have any idea what I can do to fix the error.

Autoit ver. 3.3.10.2

Beta ver. 3.3.11.4

Thank you,

Docfxit

Link to comment
Share on other sites

If Winwait(blah) Then

do stuff

endif

I guess I didn't insert it correctly because it isn't going by that code.  Still on line 33.

Thank you,

Docfxit

Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)
AutoItSetOption("TrayIconDebug", 1) ;0-off
; Set so that tray displays current line number

If _OSVersion() = 'Win7' Or _OSVersion() = 'Win7SP1' Or _OSVersion() = 'Win7X64' Or _OSVersion() = 'Win7SP1x64' Then
    $ProgramFiles = "C:\Programs\"
Else
    $ProgramFiles = "C:\Program Files\"
EndIf

; Assign a Local variable the empty string which will contain the files names found.
Global $sFileName = "", $iResult = 0, $SourceFolder = ""

_FindFile() ;Find the folder IrfanView is in, And the name of the file

MsgBox(0, "File", "File to run = " & $SourceFolder & $sFileName)
Run($SourceFolder & $sFileName)
WinWait("IrfanView Setup", "Create IrfanView sho")
If Not WinActive("IrfanView Setup", "Create IrfanView sho") Then WinActivate("IrfanView Setup", "Create IrfanView sho")
WinWaitActive("IrfanView Setup", "Create IrfanView sho")
Send($ProgramFiles & "\{SHIFTDOWN}i{SHIFTUP}rfanfiew{SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{DOWN}{SHIFTDOWN}{TAB}{TAB}{SHIFTUP}{SPACE}{SHIFTDOWN}{TAB}{SHIFTUP}{SPACE}{SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{ENTER}")
WinWait("IrfanView Setup", "What's new in this v")
If Not WinActive("IrfanView Setup", "What's new in this v") Then WinActivate("IrfanView Setup", "What's new in this v")
WinWaitActive("IrfanView Setup", "What's new in this v")
Send("{ENTER}")
WinWait("IrfanView Setup", "Do you want to assoc")
If Not WinActive("IrfanView Setup", "Do you want to assoc") Then WinActivate("IrfanView Setup", "Do you want to assoc")
WinWaitActive("IrfanView Setup", "Do you want to assoc")
Send("{ALTDOWN}n{ALTUP}")
If WinWait("IrfanView Setup", "Include Google &Chro") Then
    If Not WinActive("IrfanView Setup", "Include Google &Chro") Then WinActivate("IrfanView Setup", "Include Google &Chro")
    WinWaitActive("IrfanView Setup", "Include Google &Chro")
    Send("{SPACE}{ALTDOWN}n{ALTUP}")
EndIf
WinWait("IrfanView Setup", "Destination director")
If Not WinActive("IrfanView Setup", "Destination director") Then WinActivate("IrfanView Setup", "Destination director")
WinWaitActive("IrfanView Setup", "Destination director")
Send("{ALTDOWN}n{ALTUP}")
WinWait("IrfanView Setup", "Open IrfanView &FAQs")
If Not WinActive("IrfanView Setup", "Open IrfanView &FAQs") Then WinActivate("IrfanView Setup", "Open IrfanView &FAQs")
WinWaitActive("IrfanView Setup", "Open IrfanView &FAQs")
Send("{SPACE}{ALTDOWN}d{ALTUP}")
WinWait("IrfanView Frequently Asked Questions - Mozilla Firefox", "")
If Not WinActive("IrfanView Frequently Asked Questions - Mozilla Firefox", "") Then WinActivate("IrfanView Frequently Asked Questions - Mozilla Firefox", "")
WinWaitActive("IrfanView Frequently Asked Questions - Mozilla Firefox", "")
Send("{SHIFTDOWN}{CTRLDOWN}w{SHIFTUP}{CTRLUP}")
Exit

Func _FindFile()
    If FileExists("C:\Dnload\IrfanView*.exe") Then
        $SourceFolder = "C:\Dnload\"
    Else
        If FileExists("D:\Dnload\IrfanView*.exe") Then
            $SourceFolder = "D:\Dnload\"
        Else
            If FileExists("D:\Dnload\9xAddons\IrfanView*.exe") Then
                $SourceFolder = "D:\Dnload\9xAddons"
            Else
                If FileExists("C:\Dnload\9xAddons\IrfanView*.exe") Then
                    $SourceFolder = "C:\Dnload\9xAddons"
                Else
                    MsgBox(0, "Find", "IrfanView*.exe not found" & @CRLF & "Please download IrfanView.exe")
                EndIf
            EndIf
        EndIf
    EndIf

    ; Assign a Local variable the search handle of all files in the current directory.
    Local $hSearch = FileFindFirstFile($SourceFolder & "\IrfanView*.exe")
    ; Check if the search was successful, if not display a message and return False.
    If $hSearch = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Error: No files/directories matched the search pattern.")
        Return False
    EndIf

    ;While 1
    $sFileName = FileFindNextFile($hSearch)
    ; If there is no more file matching the search.
    ;       If @error Then ExitLoop

    ; Display the file name.
    ;   $iResult = MsgBox(BitOR($MB_SYSTEMMODAL, $MB_OKCANCEL), "", "File: " & $sFileName)
    ;       If $iResult <> $IDOK Then ExitLoop ; If the user clicks on the cancel/close button.
    ;WEnd

    ; Close the search handle.
    FileClose($hSearch)
EndFunc   ;==>_FindFile

Func _OSVersion()
    Local $OS_Version, $servicepack_version
    $OS_Version = StringStripWS(StringRegExpReplace(@OSVersion, "(WIN_)|(Microsoft )|(Windows )|(\(TM\))|( Ultimate)", ""), 8)
    $OS_Version = StringRegExpReplace(StringRegExpReplace($OS_Version, '2008', 'Win7'), 'VISTA', 'Vista')
    If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", 'CurrentBuildNumber') > 7000 Then $OS_Version = 'Win7'
    $servicepack_version = StringReplace(@OSServicePack, "Service Pack ", "SP")
    If @error = -1 Then $servicepack_version = ""

    ConsoleWrite($OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '') & @CRLF)
    Return $OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '')
EndFunc   ;==>_OSVersion
Link to comment
Share on other sites

 

I guess I didn't insert it correctly because it isn't going by that code.  Still on line 33.

Thank you,

Docfxit

 

I resolved this by using this code:

If WinExists("IrfanView Setup", "Include Google &Chro") Then
            WinWait("IrfanView Setup", "Include Google &Chro") Then
            If Not WinActive("IrfanView Setup", "Include Google &Chro") Then WinActivate("IrfanView Setup", "Include Google &Chro")
            WinWaitActive("IrfanView Setup", "Include Google &Chro")
            Send("{SPACE}{ALTDOWN}n{ALTUP}")
EndIf
Link to comment
Share on other sites

 

PS:  How can I mark a line in the code to make it easier for you to find the line I am referring to?

when posting your code using the "Code" button in the post editor, put a "1" where it asks "Starting Line Number". then your code lines will be numbered when posted. or you could start with another number if you are posting only partial script, then just state which line is causing error as you were before.

example using your own code from the post where you asked this question:

Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)
AutoItSetOption("TrayIconDebug", 1) ;0-off
; Set so that tray displays current line number

If _OSVersion() = 'Win7' Or _OSVersion() = 'Win7SP1' Or _OSVersion() = 'Win7X64' Or _OSVersion() = 'Win7SP1x64' Then
    $ProgramFiles = "C:\Programs\"
Else
    $ProgramFiles = "C:\Program Files\"
EndIf

; Assign a Local variable the empty string which will contain the files names found.
Global $sFileName = "", $iResult = 0, $SourceFolder = ""

_FindFile() ;Find the folder IrfanView is in, And the name of the file

MsgBox(0, "File", "File to run = " & $SourceFolder & $sFileName)
Run($SourceFolder &  $sFileName)
WinWait("IrfanView Setup", "Create IrfanView sho")
If Not WinActive("IrfanView Setup", "Create IrfanView sho") Then WinActivate("IrfanView Setup", "Create IrfanView sho")
WinWaitActive("IrfanView Setup", "Create IrfanView sho")
Send($ProgramFiles & "\{SHIFTDOWN}i{SHIFTUP}rfanfiew{SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{DOWN}{SHIFTDOWN}{TAB}{TAB}{SHIFTUP}{SPACE}{SHIFTDOWN}{TAB}{SHIFTUP}{SPACE}{SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{ENTER}")
WinWait("IrfanView Setup", "What's new in this v")
If Not WinActive("IrfanView Setup", "What's new in this v") Then WinActivate("IrfanView Setup", "What's new in this v")
WinWaitActive("IrfanView Setup", "What's new in this v")
Send("{ENTER}")
WinWait("IrfanView Setup", "Do you want to assoc")
If Not WinActive("IrfanView Setup", "Do you want to assoc") Then WinActivate("IrfanView Setup", "Do you want to assoc")
WinWaitActive("IrfanView Setup", "Do you want to assoc")
Send("{ALTDOWN}n{ALTUP}")
WinWait("IrfanView Setup", "Include Google &Chro")
If Not WinActive("IrfanView Setup", "Include Google &Chro") Then WinActivate("IrfanView Setup", "Include Google &Chro")
WinWaitActive("IrfanView Setup", "Include Google &Chro")
Send("{SPACE}{ALTDOWN}n{ALTUP}")
WinWait("IrfanView Setup", "Destination director")
If Not WinActive("IrfanView Setup", "Destination director") Then WinActivate("IrfanView Setup", "Destination director")
WinWaitActive("IrfanView Setup", "Destination director")
Send("{ALTDOWN}n{ALTUP}")
WinWait("IrfanView Setup", "Open IrfanView &FAQs")
If Not WinActive("IrfanView Setup", "Open IrfanView &FAQs") Then WinActivate("IrfanView Setup", "Open IrfanView &FAQs")
WinWaitActive("IrfanView Setup", "Open IrfanView &FAQs")
Send("{SPACE}{ALTDOWN}d{ALTUP}")
WinWait("IrfanView Frequently Asked Questions - Mozilla Firefox", "")
If Not WinActive("IrfanView Frequently Asked Questions - Mozilla Firefox", "") Then WinActivate("IrfanView Frequently Asked Questions - Mozilla Firefox", "")
WinWaitActive("IrfanView Frequently Asked Questions - Mozilla Firefox", "")
Send("{SHIFTDOWN}{CTRLDOWN}w{SHIFTUP}{CTRLUP}")
Exit

Func _FindFile()
    If FileExists("C:\Dnload\IrfanView*.exe") Then
        $SourceFolder = "C:\Dnload\"
    Else
        If FileExists("D:\Dnload\IrfanView*.exe") Then
            $SourceFolder = "D:\Dnload\"
        Else
            If FileExists("D:\Dnload\9xAddons\IrfanView*.exe") Then
                $SourceFolder = "D:\Dnload\9xAddons"
            Else
                If FileExists("C:\Dnload\9xAddons\IrfanView*.exe") Then
                    $SourceFolder = "C:\Dnload\9xAddons"
                Else
                    MsgBox(0, "Find", "IrfanView*.exe not found" & @CRLF & "Please download IrfanView.exe")
                EndIf
            EndIf
        EndIf
    EndIf

    ; Assign a Local variable the search handle of all files in the current directory.
    Local $hSearch = FileFindFirstFile($SourceFolder & "\IrfanView*.exe")
    ; Check if the search was successful, if not display a message and return False.
    If $hSearch = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Error: No files/directories matched the search pattern.")
        Return False
    EndIf

    ;While 1
    $sFileName = FileFindNextFile($hSearch)
    ; If there is no more file matching the search.
    ;       If @error Then ExitLoop

    ; Display the file name.
    ;   $iResult = MsgBox(BitOR($MB_SYSTEMMODAL, $MB_OKCANCEL), "", "File: " & $sFileName)
    ;       If $iResult <> $IDOK Then ExitLoop ; If the user clicks on the cancel/close button.
    ;WEnd

    ; Close the search handle.
    FileClose($hSearch)
EndFunc   ;==>_FindFile

Func _OSVersion()
    Local $OS_Version, $servicepack_version
    $OS_Version = StringStripWS(StringRegExpReplace(@OSVersion, "(WIN_)|(Microsoft )|(Windows )|(\(TM\))|( Ultimate)", ""), 8)
    $OS_Version = StringRegExpReplace(StringRegExpReplace($OS_Version, '2008', 'Win7'), 'VISTA', 'Vista')
    If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", 'CurrentBuildNumber') > 7000 Then $OS_Version = 'Win7'
    $servicepack_version = StringReplace(@OSServicePack, "Service Pack ", "SP")
    If @error = -1 Then $servicepack_version = ""

    ConsoleWrite($OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '') & @CRLF)
    Return $OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '')
EndFunc   ;==>_OSVersion
If @error Then
    MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!")
EndIf

"Yeah yeah yeah patience, how long will that take?"  -Ed Gruberman

REAL search results  |  SciTE4AutoIt3 Editor Full Version

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...