Jump to content

IE problem -> File


Joke758
 Share

Recommended Posts

Func _Uploadpicture($path)
    $oIE = _IeCreate ( "www.imageshack.us", 0, 1 )
    $o_form = _IEFormGetCollection ($oIE, 0)
    $o_file = _IEFormElementGetObjByName ($o_form, "fileupload")
    
    _IEFormElementSetValue ($o_file, "test")
    _IeFormSubmit ( $o_form )
EndFunc

Why it doesn't work?

It doesn't write the file I want in the filebox..

Edited by Joke758

[u]My Programs:[/u]Word Search Creator - Make your own Word SearchShortHand - Hide a secret message in a jpg fileHex Editor - Edit your Binary fileIncrease file size - Increase the size of any filesArt Generator - A program that generate random picture[u]My Functions:[/u]16-Bits Hash - My Hash function similar to MD5Probabilities - My probabilities function (factorial, permuation, combination)_GetDate() - Convert a date to a day of the week_Base(), _Dec() - Convert a number in any base (bin, oct, hex, dec). Create your own!

Link to comment
Share on other sites

  • Moderators

It's a security thing with IE, but here is a workaround.

Func _Uploadpicture($sPath)
    $oIE = _IECreate("www.imageshack.us")
    $hwnd = _IEPropertyGet($oIE, "hwnd")
    $oForm = _IEFormGetCollection($oIE, 0)
    $oFile = _IEFormElementGetObjByName($oForm, "fileupload")
    $oFile.focus
    ControlSend($hwnd, "", "Internet Explorer_Server1", $sPath)
    _IEFormSubmit($oForm)
EndFunc   ;==>_Uploadpicture
Link to comment
Share on other sites

this seems to get hung in the loadwait after form submit... note debug tray icon

maybe i was using smaller files... but it continued to just sit in the sleep ( loadwait )

#include<IE.au3>

Dim $Find = "value=" ; my info shows after this line... or just find this line
Dim $Before = "> Direct link"    ; my info shows before this line... or set as ""

Opt("TrayIconDebug", 1)

$var = FileOpenDialog("Choose a Picture", "C:Temp", "Images (*.jpg;*.bmp)", 1 + 4)

If @error Then
    MsgBox(4096, "", "No File(s) chosen")
    Exit
EndIf

_Uploadpicture($var)

Func _Uploadpicture($sPath)
    $oIE = _IECreate ("www.imageshack.us")
    $hwnd = _IEPropertyGet ($oIE, "hwnd")
    $oForm = _IEFormGetCollection ($oIE, 0)
    $oFile = _IEFormElementGetObjByName ($oForm, "fileupload")
    $oFile.focus
    ControlSend($hwnd, "", "Internet Explorer_Server1", $sPath)
    _IEFormSubmit ($oForm)
    
    ; start my section
    $body = _IEBodyReadHTML ($oIE)
    $sloc = @TempDir & "stest.txt"
    FileDelete($sloc)
    FileWrite($sloc, $body)
    $sfile = FileOpen($sloc, 0)
    $num = 0
    While 2
        $num = $num + 1
        $sline = FileReadLine($sfile, $num)
        If @error Then
            MsgBox(262208, "Fail", "The string was NOT found   ")
            FileClose($sfile)
            _IEQuit ($oIE)
            Exit
        EndIf
        If StringInStr($sline, $Before) Then
            MsgBox(64, "Success", "The string " & $Find & " was found    " & @CRLF & " on line # " & $num, 3)
            If $Before = "" Then ExitLoop
            $Found = _StringBetween($sline, $Find, $Before)
            InputBox("Found", "The string is ", $Found)
            _IEQuit ($oIE)
            Return
        EndIf
    WEnd
    
EndFunc   ;==>_Uploadpicture

Func _StringBetween($s_String, $s_Start, $s_End = 0)
    $s_Start = StringInStr($s_String, $s_Start) + StringLen($s_Start)
    Return StringMid($s_String, $s_Start, StringInStr($s_String, $s_End) - $s_Start)
EndFunc   ;==>_StringBetween

8)

BTW

_IEBodyReadHTML Returns the HTML inside the tag of the document.

#include <IE.au3>

_IEBodyReadHTML ( ByRef $o_object )

Parameters

$o_object Object variable of an InternetExplorer.Application, Window or Frame object

Return Value

Success: Returns HTML included in the of the docuement

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

@Valuater - This should keep it from hanging. I also simplified your procedure for getting the image tags.

#include <IE.au3>

$var = FileOpenDialog("Choose a Picture", "C:Temp", "Images (*.jpg;*.bmp)", 1 + 4)

If @error Then
    MsgBox(4096, "", "No File(s) chosen")
    Exit
EndIf

_Uploadpicture($var)

Func _Uploadpicture($sPath)
    $oIE = _IECreate("http://imageshack.us/")
    $hwnd = _IEPropertyGet($oIE, "hwnd")
    $oForm = _IEFormGetCollection($oIE, 0)
    $oBotton = _IEGetObjByName($oForm, "butan")
    $oFile = _IEFormElementGetObjByName($oForm, "fileupload")
    $oFile.focus
    ControlSend($hwnd, "", "Internet Explorer_Server1", $sPath)
    _IEAction($oBotton, "click")
    _IELoadWait($oIE)
    
    $oInputs = _IETagNameGetCollection($oIE, "INPUT")
    For $oInput In $oInputs
        If $oInput.type = "text" Then
            ConsoleWrite($oInput.value & @CRLF)
        EndIf
    Next
EndFunc   ;==>_Uploadpicture

p.s. I'll submit the documentation changes for the next beta. Thanks!

Link to comment
Share on other sites

Wow thanks!

[u]My Programs:[/u]Word Search Creator - Make your own Word SearchShortHand - Hide a secret message in a jpg fileHex Editor - Edit your Binary fileIncrease file size - Increase the size of any filesArt Generator - A program that generate random picture[u]My Functions:[/u]16-Bits Hash - My Hash function similar to MD5Probabilities - My probabilities function (factorial, permuation, combination)_GetDate() - Convert a date to a day of the week_Base(), _Dec() - Convert a number in any base (bin, oct, hex, dec). Create your own!

Link to comment
Share on other sites

  • 10 months later...

Thanks again for updating this, Bob!

I was wondering if it would be real easy for you or someone to add the following...:

1) on the final page, have "Include details" unchecked

2) under it, select the field "Hotlink for forums (1)"

3) copy (I can probably manage that... :P)

and if easy:

4) strip from it (nice and clean :))

[URL=http://imageshack.us]  [/URL]

Thanks AGAIN for looking :) :)

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