Sign in to follow this  
Followers 0
Docfxit

Syntax error in file open

6 posts in this topic

#1 ·  Posted (edited)

I am trying to send a full path to an open box. The path does have a space in it. I can't figure out how to send it.

This line in the code:

$AddonsFiles[$i] = '"' & $AddonsDir & $AddonsFiles[$i] & '"'

Only puts in $AddonsDir into $AddonsFiles[$i]

If I change that line to:

$AddonsFiles[$i] = $AddonsDir & $AddonsFiles[$i]

It put in $AddonsDir & $AddonsFiles[$i]

but

I then have a problem on this line:

Send($AddonsFiles[$i])

It only shows &AddonsFiles[$i]

There is a space in the path.

I can't figure out how to put quotes around &AddonsFiles[$i] so the entire contents will go into the open box.

#include "File.au3"
; Autoit code to instll extensions and themes into firefox
AutoItSetOption("TrayIconDebug", 1) ;0-off
; Set so that tray displays current line number
If _OSVersion() = "Win7" Or "Win7X64" Then
    $ProgramFiles = "C:\Programs"
Else
    $ProgramFiles = "C:\Program Files"
EndIf
;Declare Variables
$FireFoxDir = $ProgramFiles & '\FireFox\'
$FireFoxExe = $FireFoxDir & 'FireFox.exe'
$ScriptDir = "C:\Dnload\9xAddons"
$AddonsDir = @ScriptDir & '\FireFox Extensions\'
$AddonsFiles = _FileListToArray($AddonsDir)
For $i = 1 To $AddonsFiles[0]
    $AddonsFiles[$i] = ('"' & $AddonsDir & $AddonsFiles[$i] & '"')
Next
$appName = "[CLASS:MozillaWindowClass]"
$appHandle = WinGetHandle($appName, "")
If WinExists($appName) Then
    WinActivate($appHandle)
Else
    Run($FireFoxExe)
EndIf
WinActivate($appHandle)
For $i = 1 To $AddonsFiles[0]
    Switch StringRight($AddonsFiles[$i], 3)
        Case 'xpi'
;MsgBox(48, "File Number", $i)
            Send("{CTRLDOWN}o{CTRLUP}")
            WinWait("Open File", "Namespace Tree Contr")
            If Not WinActive("Open File", "Namespace Tree Contr") Then WinActivate("Open File", "Namespace Tree Contr")
            WinWaitActive("Open File", "Namespace Tree Contr")
MsgBox(48, "File Nname", $AddonsFiles[$i])
Send($AddonsFiles[$i])
            Send("{ALTDOWN}o{ALTUP}")
            WinWait("Software Installation", "")
            If Not WinActive("Software Installation", "") Then WinActivate("Software Installation", "")
            WinWaitActive("Software Installation", "")
;            Sleep(2500)
        Case 'jar'
            ; This is not working
            ;RunWait($FireFoxExe & ' -install-global-theme "' & $AddonsFiles[$i] & '"', $FireFoxDir)
        Case Else
            Sleep(0)
    EndSwitch
    ;close firefox
    ProcessClose('FireFox.exe *32')
Next
Exit
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
Edited by docfxit

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You dont need parentheses around $AddonsFiles[$i] = ('"' & $AddonsDir & $AddonsFiles[$i] & '"').

replace runwait with clipput and paste the results to troubleshoot. It looks like you are adding quotes in the array, then adding more quotes when you run it.

Edited by DicatoroftheUSA

Share this post


Link to post
Share on other sites

Try using

Send($AddonsFiles[$i], 1) ; sends the contents of $AddonsFiles[$i] without parsing its contents


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

Share this post


Link to post
Share on other sites

docfixit,

I would find out what value is in "$AddonsFiles[0]" as the following code works (quotation marks are similar to your code)

;
;

#include<array.au3>

local $AddonsDir = 'My dir for testing\'
local $AddonsFiles[2] = ['file1.addon','file2.addon']


For $i = 0 To ubound($AddonsFiles) - 1
$AddonsFiles[$i] = '"' & $AddonsDir & $AddonsFiles[$i] & '"'
Next

_arraydisplay($AddonsFiles)

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I have had success in formating the line correctly with this code:

#include "File.au3"

; Autoit code to instll extensions and themes into firefox
AutoItSetOption("TrayIconDebug", 1) ;0-off
; Set so that tray displays current line number
If _OSVersion() = "Win7" Or "Win7X64" Then
$ProgramFiles = "C:\Programs"
Else
$ProgramFiles = "C:\Program Files"
EndIf
;Declare Variables
$FireFoxDir = $ProgramFiles & '\FireFox\'
$FireFoxExe = $FireFoxDir & 'FireFox.exe'
$ScriptDir = "C:\Dnload\9xAddons"
$AddonsDir = @ScriptDir & '\FireFox Extensions\'
$AddonsFiles = _FileListToArray($AddonsDir)
For $i = 1 To $AddonsFiles[0]
$AddonsFiles[$i] = "'" & $AddonsDir & $AddonsFiles[$i] & "'"
Next
$appName = "[CLASS:MozillaWindowClass]"
$appHandle = WinGetHandle($appName, "")
If WinExists($appName) Then
;WinWait("Firefox", "")
If Not WinActive("Firefox", "") Then WinActivate("Firefox", "")
WinWaitActive("Firefox", "")
; WinSetState($appHandle,"",@SW_RESTORE)
WinActivate($appHandle)
MsgBox(48, "Firefox", "Is Active")
WinsetOntop ( $appName, "", 1 )

Else
MsgBox(48, "Firefox", "Is Not Active")
Run($FireFoxExe)
EndIf
WinActivate($appHandle)
WinsetOntop ( $appName, "", 1 )
MsgBox(48, "Firefox", "Should be Active")

For $i = 1 To $AddonsFiles[0]
Switch StringRight($AddonsFiles[$i], 3)
Case 'xpi'
;MsgBox(48, "File Number", $i)
Send("{CTRLDOWN}o{CTRLUP}")
WinWait("Open File", "Namespace Tree Contr")
If Not WinActive("Open File", "Namespace Tree Contr") Then WinActivate("Open File", "Namespace Tree Contr")
WinWaitActive("Open File", "Namespace Tree Contr")
MsgBox(48, "File Nname", $AddonsFiles[$i])
Send($AddonsFiles[$i], 1)
Send("{ALTDOWN}o{ALTUP}")
WinWait("Software Installation", "")
If Not WinActive("Software Installation", "") Then WinActivate("Software Installation", "")
WinWaitActive("Software Installation", "")
; Sleep(2500)
Case 'jar'
; This is not working
;RunWait($FireFoxExe & ' -install-global-theme "' & $AddonsFiles[$i] & '"', $FireFoxDir)
Case Else
Sleep(0)
EndSwitch
;close firefox
ProcessClose('FireFox.exe *32')
Next
Exit
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 haven't been successful in bringing firefox to the forground.

Any ideas how to make it active?

Thanks,

Docfxit

Edited by docfxit

Share this post


Link to post
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
Sign in to follow this  
Followers 0