Sign in to follow this  
Followers 0
mads3n

Little problem with my script

2 posts in this topic

I've made a script to upload files to imageshack. Im using some _ie functions but i ran into a problem..

heres the script.. problem comes under the script:

#cs ----------------------------------------------------------------------------



#ce ----------------------------------------------------------------------------
#include <GUIConstants.au3>
#include <Constants.au3>
#include <Array.au3>
#include <IE.au3>
#include <String.au3>

Opt("GUIOnEventMode",1)
Opt("GUIResizeMode", 802)

Global $uplmax = 6 ; max number of uploads (+ 1)
$i = 0 ; for expanding movement
$currentuplpos = 65
; max number of uploads into array


dim $upl[$uplmax], $browse[$uplmax]
$selected = 0
$currentitems = 1
$gui = GUICreate("IMAGE // UPLOAD", 220, 85, -1, -1,$WS_POPUP+$WS_BORDER)


$exit = GUICtrlCreateButton("X", 200, $currentuplpos-65, 20, 20)
$plusupl = GUICtrlCreateButton("+", 200, $currentuplpos, 20, 20) ; add upload button
GUICtrlSetTip($plusupl, "Add another upload.")
$upload = GUICtrlCreateButton("Upload images", 1, $currentuplpos, 200, 20) ; add upload
GUICtrlSetTip($upload, "Uploads images to imageshack.us")
$upl[$currentitems] = GuiCtrlCreateInput("", 2, $currentuplpos-30, 155, 20)
$browse[$currentitems] = GUICtrlCreateButton("Browse", 158, $currentuplpos-30, 62, 20)
GUICtrlSetOnEvent ($plusupl, "plusup")
GUICtrlSetOnEvent ($upload, "upload")
GUICtrlSetOnEvent ($exit, "_exit")
GUICtrlSetOnEvent ($browse[$currentitems], "browse"& $currentitems)
GUISetState(@SW_SHOW)


func plusup()
            GUICtrlSetState($plusupl, $GUI_DISABLE)
            GUICtrlSetState($upload, $GUI_DISABLE)
            $currentitems += 1
            while $i < 10
            $currentuplpos += 3
            $guiposition = WinGetPos($gui)
            WinMove($gui, "", $guiposition[0], $guiposition[1], $guiposition[2], $guiposition[3] + 3) ; Expand gui 3 pixels downward 10 times
            guictrlsetpos($plusupl,200, $currentuplpos) ; Moves the "+" button down with the window
            guictrlsetpos($upload,1, $currentuplpos) ; Moves the "Upload" button down with the window
            $i += 1
            sleep(50)
            wend
            $upl[$currentitems] = GuiCtrlCreateInput("", 2, $currentuplpos-30, 155, 20)
            $browse[$currentitems] = GUICtrlCreateButton("Browse", 158, $currentuplpos-30, 62, 20)
            GUICtrlSetOnEvent ($browse[$currentitems], "browse"& $currentitems)
            GUICtrlSetState($plusupl, $GUI_ENABLE)
            GUICtrlSetState($upload, $GUI_ENABLE)
            $i = 0
            if $currentitems = $uplmax-1 Then
            GUICtrlSetState($plusupl, $GUI_DISABLE)
            Else
            Endif
Endfunc

func _exit()
        exit
Endfunc

func browse1()
            
            $open = FileOpenDialog("Select image", @WindowsDir & "\", "Images (*.jpg;*.bmp;*.jpeg;*.gif;*.tif;*.tiff;*.png;*.swf)", 1 + 4 )
            GUICtrlSetData($upl[1], $open)
EndFunc
        
func browse2()
            $open = FileOpenDialog("Select image", @WindowsDir & "\", "Images (*.jpg;*.bmp;*.jpeg;*.gif;*.tif;*.tiff;*.png;*.swf)", 1 + 4 )
            GUICtrlSetData($upl[2], $open)
EndFunc     
        
func browse3()
            $open = FileOpenDialog("Select image", @WindowsDir & "\", "Images (*.jpg;*.bmp;*.jpeg;*.gif;*.tif;*.tiff;*.png;*.swf)", 1 + 4 )
            GUICtrlSetData($upl[3], $open)
EndFunc
        
func browse4()
            $open = FileOpenDialog("Select image", @WindowsDir & "\", "Images (*.jpg;*.bmp;*.jpeg;*.gif;*.tif;*.tiff;*.png;*.swf)", 1 + 4 )
            GUICtrlSetData($upl[4], $open)
EndFunc
        
func browse5()
            $open = FileOpenDialog("Select image", @WindowsDir & "\", "Images (*.jpg;*.bmp;*.jpeg;*.gif;*.tif;*.tiff;*.png;*.swf)", 1 + 4 )
            GUICtrlSetData($upl[5], $open)
EndFunc

func upload()
    GUICtrlSetState($plusupl, $GUI_DISABLE)
    GUICtrlSetState($upload, $GUI_DISABLE)  
    $i = $currentitems
    $progress = GUICtrlCreateLabel ( "Uploading "& $i & " / "& $selected, 10, 10, 100, 14)
    while $i > 0
    $selected += 1
    GUICtrlSetData($progress, "Uploading "& $i & " / "& $selected)
    GUICtrlSetState($upl[$i], $GUI_DISABLE)
    GUICtrlSetState($browse[$i], $GUI_DISABLE)
    $ie = _IECreate( "http://www.imageshack.us", 0, 0 )
    _IELoadWait($ie)
    $form = _IEFormGetObjByName( $ie, "upform" )
    $file = _IEFormElementGetObjByName( $form, "fileupload" )
    _IEFormElementSetValue( $file, $upl[$i] )
    _IEFormSubmit ($form)
    _IELoadWait($ie)
    $html = _IEDocReadHTML ($ie)
    $imageurl = _StringBetween($html, '<a href="', '"><b>Show</b></a> image to friends<br />')
    GUICtrlSetState($upl[$i], $GUI_ENABLE)
    GUICtrlSetData($upl[$i], $imageurl)
    Wend
    $selected = 0
Endfunc

while 1
    sleep(20)
wend

the problem is:

"--> IE.au3 V2.3-1 Error from function _IEFormElementSetValue, $_IEStatus_InvalidObjectType (Browser securuty prevents SetValue of TYPE=FILE) "

is there a possible work around, or do i need to use some other functions? :/


Mads3n.dk

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