Jump to content
Sign in to follow this  
linc

Newbie needs help! Script paused by Website?

Recommended Posts

linc

Hope I didn't overlook anything in the FAQ's. Perhaps I did not search properly...

I'm trying to interact with a website that allows posting of free adds for sale. The example should run on any computer.

After click on the Browse Button, my script is paused.

CODE
#include <IE.au3>

_IEErrorHandlerRegister()

#AutoIt3Wrapper_run_debug_mode=Y

$oIE = _IECreate("http://dallas.kijiji.com/c-PostAd?AddressCity=&AddressCounty=&AddressRegion=&AddressSelectedByUser=false&AddressStreet=&AddressZip=&CatId=100107&ChangeCategory=&ChangePhoto=&ContactInfo=&Description=&Email=&EpsErrorCode=&EventEndDay=26&EventEndHour=23&EventEndMinute=59&EventEndMonth=3&EventEndSecond=3&EventEndYear=2009&EventStartDay=26&EventStartHour=0&EventStartMinute=0&EventStartMonth=3&EventStartSecond=3&EventStartYear=2009&GetNeighborhood=&Guid=&JavascriptNotEnabled=false&Photo=&PreviewAd=&PreviewToEdit=&Price=&RequestRefererUrl=&SelectedLeafCat=SelectedLeafCat&ShowTerms=&Thumbnail=&Title=&TransDescription=&TransTitle=&action_cancel=&action_publish=")

$oField = _IEGetObjByName($oIE, "u")

_IEAction($oField, "focus")

$hIE = _IEPropertyGet($oIE, "hwnd")

ControlSend($hIE, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "Path_to_image_on_my_disk.img")

_IEAction($oField, "click")

;Website has my script paused and I don't want the user to have to select anything!

$oQuery = _IEGetObjById($oIE, "AddressZip")

_IEFormElementSetValue($oQuery, "12345-1234")

User can do nothing, except interact with the "Choose file" pop up window. I would like to interact with the pop up programmatically.

Is there a way around this? Debug bar shows:

<INPUT type=file onchange=EPSObj.changed(1) size=55 value=Path_to_image_on_my_disk.img name=u>


It is usually easier to make something better, than to invent it.

Share this post


Link to post
Share on other sites
linc

Thank you for the fast response. I still seem to be hung up on the "Choose file" window. Was the filename and extension sent to the "Pick Box" of the "Choose file" window when you tested this? I just get the filename, without the extension, and a message that the file was not found.

Please advise.

Thanks again


It is usually easier to make something better, than to invent it.

Share this post


Link to post
Share on other sites
linc

Valuater,

I am using an absolute path and filename eg. c:\work\imagefiles\image001.jpg

I am not installing anything, just executing the au3 sript. "<alt>F5" from inside Scite

I am only testing this on my computer. IE 7 and Win xp pro

What am I missing?


It is usually easier to make something better, than to invent it.

Share this post


Link to post
Share on other sites
linc

#include <IE.au3>
_IEErrorHandlerRegister()
#AutoIt3Wrapper_run_debug_mode=Y
$oIE = _IECreate("http://dallas.kijiji.com/c-PostAd?AddressCity=&AddressCounty=&AddressRegion=&AddressSelectedByUser=false&AddressStreet=&AddressZip=&CatId=100107&ChangeCategory=&ChangePhoto=&ContactInfo=&Description=&Email=&EpsErrorCode=&EventEndDay=26&EventEndHour=23&EventEndMinute=59&EventEndMonth=3&EventEndSecond=3&EventEndYear=2009&EventStartDay=26&EventStartHour=0&EventStartMinute=0&EventStartMonth=3&EventStartSecond=3&EventStartYear=2009&GetNeighborhood=&Guid=&JavascriptNotEnabled=false&Photo=&PreviewAd=&PreviewToEdit=&Price=&RequestRefererUrl=&SelectedLeafCat=SelectedLeafCat&ShowTerms=&Thumbnail=&Title=&TransDescription=&TransTitle=&action_cancel=&action_publish=")
$oField = _IEGetObjByName($oIE, "u")
_IEAction($oField, "focus")
$hIE = _IEPropertyGet($oIE, "hwnd")
Sleep(1000)
ControlSend($hIE, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "C:\clwork\447668_files\image001.jpg")
Sleep(1000)
KillWindow("Choose file")
Sleep(1000)
_IEAction($oField, "click")
Sleep(1000)
MsgBox(0,"","this is a test")



Func KillWindow($title)
    Local $Script = 'WinWait("' & $title & '", "")' & @CRLF & 'Send("{ENTER}")'
    Local $file_loc = @ScriptDir & "\Killer.au3"
    FileDelete($file_loc)
    FileWrite($file_loc, $Script)
    If @Compiled = 1 Then
        $file_exe = FileGetShortName(@AutoItExe & ' /AutoIt3ExecuteScript "' & $file_loc & '"')
        Run($file_exe)
    Else
        $file_au3 = FileGetShortName($file_loc)
        Run(@AutoItExe & " " & $file_au3, "", @SW_HIDE)
    EndIf

Hi again, The above is verbatim what i ran. I tried to get a screen shot of the results, but couldn't get it down to 64k in size.

The ControlSend appears to be working perfectly. It shows the full path and filename in the Input Field.

Regards,

linc


It is usually easier to make something better, than to invent it.

Share this post


Link to post
Share on other sites
linc

Here is the screenshot 8)

post-47409-1240690329_thumb.jpg


It is usually easier to make something better, than to invent it.

Share this post


Link to post
Share on other sites
linc

Here is the screenshot 8)

It works! Thank you very much, Valuater!

Regards,

linc


It is usually easier to make something better, than to invent it.

Share this post


Link to post
Share on other sites
linc

Here is a version that allows a variable to be passed. Note the use of "$cmdline[1]" in the Killer.au3 script. 8)

#include <IE.au3>
Global $photopath
_IEErrorHandlerRegister()
#AutoIt3Wrapper_run_debug_mode=Y
$photopath = "Place fully qualified path to image file here"   ;eg. "C:\work\image_files\my_image.jpg
$oIE = _IECreate("http://dallas.kijiji.com/c-PostAd?AddressCity=&AddressCounty=&AddressRegion=&AddressSelectedByUser=false&AddressStreet=&AddressZip=&CatId=100107&ChangeCategory=&ChangePhoto=&ContactInfo=&Description=&Email=&EpsErrorCode=&EventEndDay=26&EventEndHour=23&EventEndMinute=59&EventEndMonth=3&EventEndSecond=3&EventEndYear=2009&EventStartDay=26&EventStartHour=0&EventStartMinute=0&EventStartMonth=3&EventStartSecond=3&EventStartYear=2009&GetNeighborhood=&Guid=&JavascriptNotEnabled=false&Photo=&PreviewAd=&PreviewToEdit=&Price=&RequestRefererUrl=&SelectedLeafCat=SelectedLeafCat&ShowTerms=&Thumbnail=&Title=&TransDescription=&TransTitle=&action_cancel=&action_publish=")
$oField = _IEGetObjByName($oIE, "u")
_IEAction($oField, "focus")
$hIE = _IEPropertyGet($oIE, "hwnd")

ControlSend($hIE, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $photopath)

KillWindow("Choose file",$photopath)
_IEAction($oField, "click")


Func KillWindow($title, $photopath)
    Local $Script = 'WinWait("' & $title & '", "")' & @CRLF & 'Send( $cmdline[1] & "{ENTER}")'
    Local $file_loc = @DesktopDir & "\Killer.au3"
    FileDelete($file_loc)
    FileWrite($file_loc, $Script )
    If @Compiled = 1 Then
        $file_exe = FileGetShortName(@AutoItExe & ' /AutoIt3ExecuteScript "' & $file_loc & '"')
        Run($file_exe & " " & $photopath )
    Else
        $file_au3 = FileGetShortName($file_loc)
        Run(@AutoItExe & " " & $file_au3 & " " & $photopath )
    EndIf
EndFunc  ;==>KillWindow

It is usually easier to make something better, than to invent it.

Share this post


Link to post
Share on other sites
linc

Interesting, but, I can't see why you would use a command-line when you have the info to send as the sub-program is being written...???

8)

Because the Run command passes $photopath to the newly created script as a parameter, and it works.

8)


It is usually easier to make something better, than to invent it.

Share this post


Link to post
Share on other sites
linc

That's what I mean, It is interesting and can work... But, you are over-complicating the whole idea.

Why not just use....

Local $Script = 'WinWait("' & $title & '", "")' & @CRLF & 'Send("' & $photopath & '"{ENTER}")'

8)

Ah.. Yes.... $photopath is passed to the function that fires off the killer script, but the killer script knows nothing about the variable $photopath.

So.. the value of $photopath must be passed to the killer script, and the only way I saw to do so was using the default paramter array $cmdline[].

$cmdline[1] references the first parameter passed by the Run command. ie. $photopath.

Run(@AutoItExe & " " & $file_au3 & " " & $photopath ) ;fires off the killer script and passes $photopath's value in parameter 1

Please let me know if you can get it to work the other way.

8)

Edited by linc

It is usually easier to make something better, than to invent it.

Share this post


Link to post
Share on other sites
linc

That's what I mean, It is interesting and can work... But, you are over-complicating the whole idea.

Why not just use....

Local $Script = 'WinWait("' & $title & '", "")' & @CRLF & 'Send("' & $photopath & '"{ENTER}")'

8)

Newbie bows to Valuater's superior knowlege and experience 8)

Thanks again.


It is usually easier to make something better, than to invent it.

Share this post


Link to post
Share on other sites
lordicast

Hey linc you can shorten a variable length by using

$oIE = _IECreate("http://dallas.kijiji.com/c-PostAd?AddressCity"&@CRLF&_
"=&AddressCounty=&AddressRegion=&AddressSelectedByUser=false&AddressStreet&"&@CRLF&_
"=&AddressZip=&CatId=100107&ChangeCategory=&ChangePhoto=&ContactInfo="&@CRLF&_
"&Description=&Email=&EpsErrorCode=&EventEndDay=26&EventEndHour=23&EventEndMinute"&@CRLF&_
"=59&EventEndMonth=3&EventEndSecond=3&EventEndYear=2009&EventStartDay=26&EventStartHour"&@CRLF&_
"=0&EventStartMinute=0&EventStartMonth=3&EventStartSecond=3&EventStartYear=2009&GetNeighborhood"&@CRLF&_
"=&Guid=&JavascriptNotEnabled=false&Photo=&PreviewAd=&PreviewToEdit=&Price=&RequestRefererUrl"&@CRLF&_
"=&SelectedLeafCat=SelectedLeafCat&ShowTerms=&Thumbnail=&Title=&TransDescription=&TransTitle"&@CRLF&_
"=&action_cancel=&action_publish=")

I just think its easier to read ^_^


[Cheeky]Comment[/Cheeky]

Share this post


Link to post
Share on other sites
Jos

Hey linc you can shorten a variable length by using

$oIE = _IECreate("http://dallas.kijiji.com/c-PostAd?AddressCity"&@CRLF&_
"=&AddressCounty=&AddressRegion=&AddressSelectedByUser=false&AddressStreet&"&@CRLF&_
"=&AddressZip=&CatId=100107&ChangeCategory=&ChangePhoto=&ContactInfo="&@CRLF&_
"&Description=&Email=&EpsErrorCode=&EventEndDay=26&EventEndHour=23&EventEndMinute"&@CRLF&_
"=59&EventEndMonth=3&EventEndSecond=3&EventEndYear=2009&EventStartDay=26&EventStartHour"&@CRLF&_
"=0&EventStartMinute=0&EventStartMonth=3&EventStartSecond=3&EventStartYear=2009&GetNeighborhood"&@CRLF&_
"=&Guid=&JavascriptNotEnabled=false&Photo=&PreviewAd=&PreviewToEdit=&Price=&RequestRefererUrl"&@CRLF&_
"=&SelectedLeafCat=SelectedLeafCat&ShowTerms=&Thumbnail=&Title=&TransDescription=&TransTitle"&@CRLF&_
"=&action_cancel=&action_publish=")

I just think its easier to read ^_^

You are sure this will work too? (including those carriage returns & Linefeeds)

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
lordicast

well this works just fine Jos ^_^

$oIE = "http://dallas.kijiji.com/c-PostAd?AddressCity"&@CRLF&_
"=&AddressCounty=&AddressRegion=&AddressSelectedByUser=false&AddressStreet&"&@CRLF&_
"=&AddressZip=&CatId=100107&ChangeCategory=&ChangePhoto=&ContactInfo="&@CRLF&_
"&Description=&Email=&EpsErrorCode=&EventEndDay=26&EventEndHour=23&EventEndMinute"&@CRLF&_
"=59&EventEndMonth=3&EventEndSecond=3&EventEndYear=2009&EventStartDay=26&EventStartHour"&@CRLF&_
"=0&EventStartMinute=0&EventStartMonth=3&EventStartSecond=3&EventStartYear=2009&GetNeighborhood"&@CRLF&_
"=&Guid=&JavascriptNotEnabled=false&Photo=&PreviewAd=&PreviewToEdit=&Price=&RequestRefererUrl"&@CRLF&_
"=&SelectedLeafCat=SelectedLeafCat&ShowTerms=&Thumbnail=&Title=&TransDescription=&TransTitle"&@CRLF&_
"=&action_cancel=&action_publish="

edit: for a variable anyway

Edited by lordicast

[Cheeky]Comment[/Cheeky]

Share this post


Link to post
Share on other sites
linc

I believe Jos was saying that this pattern is correct for a $Variable without "@CRLF". That does not mean yours is wrong as a $Variable, it's just that a $URL should not have "@CRLF" in it.

$oIE = "http://dallas.kijiji.com/c-PostAd?AddressCity"& _
"=&AddressCounty=&AddressRegion=&AddressSelectedByUser=false&AddressStreet&"& _
"=&AddressZip=&CatId=100107&ChangeCategory=&ChangePhoto=&ContactInfo="& _
"&Description=&Email=&EpsErrorCode=&EventEndDay=26&EventEndHour=23&EventEndMinute"& _
"=59&EventEndMonth=3&EventEndSecond=3&EventEndYear=2009&EventStartDay=26&EventStartHour"& _
"=0&EventStartMinute=0&EventStartMonth=3&EventStartSecond=3&EventStartYear=2009&GetNeighborhood"& _
"=&Guid=&JavascriptNotEnabled=false&Photo=&PreviewAd=&PreviewToEdit=&Price=&RequestRefererUrl"& _
"=&SelectedLeafCat=SelectedLeafCat&ShowTerms=&Thumbnail=&Title=&TransDescription=&TransTitle"& _
"=&action_cancel=&action_publish="

8)

This is all very nice, but my more pressing questions are:

1. How does the process created by the "Run" Command know anything about the variable $photopath? and

2. Does a child script inherit the environment and variables from it's parent? and

3. How do I make the lines in a code section, in this forum, have the colors like SciTe shows while editing? and

4. Why did Valuater YELL at me, sob, I'm just trying to get a handle on this new ground. 8)

Thanks to all

Edited by linc

It is usually easier to make something better, than to invent it.

Share this post


Link to post
Share on other sites
lordicast

This is all very nice, but my more pressing questions are:

1. How does the process created by the "Run" Command know anything about the variable $photopath? and

2. Does a child script inherit the environment and variables from it's parent? and

3. How do I make the lines in a code section, in this forum, have the colors like SciTe shows while editing? and

4. Why did Valuater YELL at me, sob, I'm just trying to get a handle on this new ground. 8)

Thanks to all

1. Because it is local within the function

2. They are if you use the Global Line in front of the Variable ex;

Global $Help = 'You'

3. Using the [ then autoit then ] with out the Then's & [ then /autoit then] to close it, or simply click the drop down Insert Special Item from the reply menu and select Insert: Auto It and put your code in the box.

4.Valuater is pretty damn helpful buddy I wouldnt call him a SOB!

Edit: Spell Check

PS. Val & jos <- My bad i forgot i had been using @CRLF for somthing else ^_^

Edited by lordicast

[Cheeky]Comment[/Cheeky]

Share this post


Link to post
Share on other sites
linc

1. Because it is local within the function

2. They are if you use the Global Line in front of the Variable ex;

Global $Help = 'You'

3. Using the [ then autoit then ] with out the Then's & [ then /autoit then] to close it, or simply click the drop down Insert Special Item from the reply menu and select Insert: Auto It and put your code in the box.

4.Valuater is pretty damn helpful buddy I wouldnt call him a SOB!

Edit: Spell Check

PS. Val & jos <- My bad i forgot i had been using @CRLF for somthing else ^_^

Thanks to all for the help. This scripting language is somewhat addictive.

Funny! I was shedding a tear, not talking bad about Valuater's Mom. 8)


It is usually easier to make something better, than to invent it.

Share this post


Link to post
Share on other sites
Valuater

Funny! I was shedding a tear, not talking bad about Valuater's Mom. 8)

Better that, than the alternatives.... Ass-Bite!

8)

Edited by Valuater

NEWHeader1.png

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.