Sign in to follow this  
Followers 0
mem

_IENavigate issues

4 posts in this topic

Hi, Im writing a simple fax filer (mainly to teach myself some more autoit3). Its pretty basic but it does sorta work.

My problem is once I have viewed a PDF (triggered by pressing test) none of my buttons seem to work / respond. Sort of like the embedded IE object has stolen focus and stopped my while looping. Code below, comments & constructive criticism always welcome.

#include <GUIConstants.au3>
#include <GuiList.au3>
#Include <File.au3>
#Include <Array.au3>
#include <IE.au3>

_IEErrorHandlerRegister()
$oIE = _IECreateEmbedded()

Dim $cwd, $url, $oldurl, $ret, $dest_wd

$cwd = "c:\";
$dest_wd = "c:\";
$url = "http://www.google.com";

Global $MESSAGE = "The following buttons have been clicked"

GUICreate("Free Fax Filer", 800, 650)

$butt_browse = GUICtrlCreateButton("Browse", 10, 10, 100)
$butt_dest_browse = GUICtrlCreateButton("Dest Browse", 110, 10, 100)
$butt_copy = GUICtrlCreateButton("Copy", 210, 10, 100)
$butt_move = GUICtrlCreateButton("Move", 310, 10, 100)
$butt_ren = GUICtrlCreateButton("Rename", 410, 10, 100)

$butt_test = GUICtrlCreateButton("Test", 510, 10, 100)
$butt_refresh = GUICtrlCreateButton("Refresh", 610, 10, 100)

GUICtrlCreateLabel("Incomming", 10, 40, 280)
$edit_incomming = GUICtrlCreateInput("c:\", 10, 70)
$list_file = GUICtrlCreateList("text", 10, 90, 280, 200)

GUICtrlCreateLabel("Destination", 310, 40, 280)
$edit_dest = GUICtrlCreateInput("c:\", 310, 70)
$list_dest = GUICtrlCreateList("c:\", 310, 90, 280, 200)

$edit_url = GUICtrlCreateInput($url, 10, 290, 580, 20)
$gui_browser = GUICtrlCreateObj($oIE, 10, 320, 780, 300)

GUISetState()
list_update()
list_update_dest()
_IENavigate($oIE, "about:blank")

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()

    Select
        Case $msg = $butt_test
            _IENavigate($oIE, "about:blank")
            $url = getfile_1()
            GUICtrlSetData($edit_url, $url)
            _IENavigate($oIE, $url)

        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop

        Case $msg = $butt_browse
            $cwd = select_folder()
            GUICtrlSetData($edit_incomming, $cwd)
            list_update()
            list_update_dest()

        Case $msg = $butt_dest_browse
            $dest_wd = select_folder()
            GUICtrlSetData($edit_dest, $dest_wd)
            list_update_dest()

        Case $msg = $butt_ren
            $file1 = getfile_1()
            $file2 = getfile_ren()
            FileMove($file1, $file2, 1)
            list_update()
        ;list_update_dest()

        Case $msg = $butt_copy
            $file1 = getfile_1()
            $file2 = getfile_dest()
            FileCopy($file1, $file2, 1)
        ;list_update()
            list_update_dest()

        Case $msg = $butt_move
            $file1 = getfile_1()
            $file2 = getfile_dest()
            FileMove($file1, $file2, 1)
            list_update()
            list_update_dest()

        Case $msg = $butt_refresh
            list_update()
            list_update_dest()
            
    EndSelect
WEnd

Func select_folder()
    $dir = FileSelectFolder("Choose a folder.", "")
    Return $dir
EndFunc  ;==>select_folder

Func list_update()
    GUICtrlSetData($list_file, "", 1)
    $FileList = _FileListToArray($cwd)
    For $x = 1 To $FileList[0]; for loop to place the files in the list.
        GUICtrlSetData($list_file, $FileList[$x] & "|", 1)
    Next
EndFunc  ;==>list_update

Func list_update_dest()
    GUICtrlSetData($list_dest, "", 1)
    $FileList = _FileListToArray($dest_wd)
    For $x = 1 To $FileList[0]; for loop to place the files in the list.
        GUICtrlSetData($list_dest, $FileList[$x] & "|", 1)
    Next
EndFunc  ;==>list_update_dest

Func getfile_1()
    $ret = _GUICtrlListGetSelItemsText($list_file)
    $url = $ret[1]
    If StringRight($cwd, 1) = "\" Then
        $url = $cwd & "" & $url
    Else
        $url = $cwd & "\" & $url
    EndIf
    Return $url
EndFunc  ;==>getfile_1

Func getfile_2()
    $ret = _GUICtrlListGetSelItemsText($list_dest)
    _ArrayDisplay($ret)
    $url = $ret[1]
    If StringRight($dest_wd, 1) = "\" Then
        $url = $dest_wd & "" & $url
    Else
        $url = $dest_wd & "\" & $url
    EndIf
    Return $url
EndFunc  ;==>getfile_2

Func getfile_ren()
    $ret = _GUICtrlListGetSelItemsText($list_file)
    $url = $ret[1]
    $url = InputBox("rename", "enter new filename fucker", $url)
    If StringRight($dest_wd, 1) = "\" Then
        $url = $cwd & "" & $url
    Else
        $url = $cwd & "\" & $url
    EndIf
    Return $url
EndFunc  ;==>getfile_ren

Func getfile_dest()
    $ret = _GUICtrlListGetSelItemsText($list_file)
    _ArrayDisplay($ret)
    $url = $ret[1]
    If StringRight($dest_wd, 1) = "\" Then
        $url = $dest_wd & "" & $url
    Else
        $url = $dest_wd & "\" & $url
    EndIf
    Return $url
EndFunc  ;==>getfile_dest

My other option is to not use the IE object and find a pdf / tiff/ jpg viewer. though since the IE object works excellent when it wants to Im keen to try and find a resolution.

Share this post


Link to post
Share on other sites



I get an error when I run the code and press Test.

C:\tmp-sdfiii34.au3 (121) : ==> Subscript used with non-Array variable.: 
$url = $ret[1] 
$url = $ret^ ERROR
->22:59:15 AutoIT3.exe ended.rc:1

A smaller reproducer would make helping you easier. Also, I'm guessing I didn't run it the way you expected me to -- include more detailed instructions.

You may also be encountering a COM error that _IELoadWait thinks might clear itself... try using _IELoadWaitTimeOut() to set the wait time to a short time or use Global $__IEAU3Debug = True and watch the console for COM errors that IE.au3 would normally hide from you.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I get an error when I run the code and press Test.

C:\tmp-sdfiii34.au3 (121) : ==> Subscript used with non-Array variable.: 
$url = $ret[1] 
$url = $ret^ ERROR
->22:59:15 AutoIT3.exe ended.rc:1
Sorry, you must select a file to view in the list (will add check).

Thankyou for your suggestion it worked a treat, I set the timeout to 5 seconds and voila, onto my next problem :)

Edited by mem

Share this post


Link to post
Share on other sites

There are two lists. Please read everything I wrote.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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