Jump to content

onclick events leads to message box, which is not clicked.


Recommended Posts

My script is intended to open a web page, and run a backup. The way the page works is that it first clicks on a onclick event text:

<span id="spn_start" onclick='vb script:startAudit()' style="cursor:hand"><b><u>Get Activity Status</u></b></span>

then another link shows up:

<span id='exe_all' style='cursor:hand' onclick='vb script:backupAll'><u>Execute All</u></span>

this is clicked, and a message box pops up to confirm. That message box is every clicked on. I put an exit right before the message box, and the exit is never triggered either. So it gets caught up at the second _IEAction line.

here is the code:

#include <IE.au3>
$oIE = _IECreate("http://server/imageBackup.asp")

$oSubmit = _IEGetObjById($oIE, "spn_start")
_IEAction ($oSubmit, "click")


$oSubmit = _IEGetObjById($oIE, "exe_all")
_IEAction ($oSubmit, "click")   ;AT this point, a confirmation Message box pops up.  GETS LOCKED UP HERE


WinWait("Confirm", "Perform suggested action on all folders?")
Send("{ENTER}")
_IELoadWait ($oIE)
exit

I've looked at _IEAction example 2, and could not figure it out.

Edited by cvn
Link to comment
Share on other sites

My script is intended to open a web page, and run a backup. The way the page works is that it first clicks on a onclick event text:

<span id="spn_start" onclick='vb script:startAudit()' style="cursor:hand"><b><u>Get Activity Status</u></b></span>

then another link shows up:

<span id='exe_all' style='cursor:hand' onclick='vb script:backupAll'><u>Execute All</u></span>

this is clicked, and a message box pops up to confirm. That message box is every clicked on. I put an exit right before the message box, and the exit is never triggered either. So it gets caught up at the second _IEAction line.

here is the code:

#include <IE.au3>
$oIE = _IECreate("http://server/imageBackup.asp")

$oSubmit = _IEGetObjById($oIE, "spn_start")
_IEAction ($oSubmit, "click")


$oSubmit = _IEGetObjById($oIE, "exe_all")
_IEAction ($oSubmit, "click");AT this point, a confirmation Message box pops up.  GETS LOCKED UP HERE


WinWait("Confirm", "Perform suggested action on all folders?")
Send("{ENTER}")
_IELoadWait ($oIE)
exit

I've looked at _IEAction example 2, and could not figure it out.

The Example #2 you referenced was the right answer, what didn't you understand about that? Use "focus" instead of "click" and then ControlSend() an "{ENTER}" to the browser. Post how you tried to do that.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I tried:

#include <IE.au3>
$oIE = _IECreate("http://radiologya3/aspcomponents/diagnostics/Acquisition/imageBackup.asp")
$oSubmit = _IEGetObjById($oIE, "spn_start")
$hwnd = _IEPropertyGet($oIE, "hwnd")
_IEAction ($oSubmit, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

$oSubmit = _IEGetObjById($oIE, "exe_all")
_IEAction ($oSubmit, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

WinWait("Confirm", "Perform suggested action on all folders?")
Send("{ENTER}")
_IELoadWait ($oIE)
exit

I cannot focus on the "Get Activity Status" link because it is a span awaiting a click, not the typical <a> type link. I tried using Tabs, but it skips this field every time, so I cant send an "Enter" to the field.

Link to comment
Share on other sites

Try sth like this:

_IENavigate($oIE,"vb script:backupAll",0)

instead of click

IE dies not block then :)

#include <IE.au3>
$oIE = _IECreate("google.de")
_IENavigate($oIE,"vb script:alert",0)
Sleep(500)
Send("{ENTER}")

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

I cannot focus on the "Get Activity Status" link because it is a span awaiting a click, not the typical <a> type link. I tried using Tabs, but it skips this field every time, so I cant send an "Enter" to the field.

There's the thing, I don't think it being a span should make any difference if can have an "on click" property attached to it. Don't have a test page to prove it on right now, though, so I could be mistaken. All I've found so far is the Google home page, which has <a> tags inside the <span> tags. I don't have time to look for examples of what you quoted in your first post.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I've hosted a sample of the problem I'm having.

http://www.diaglabs.com/test/autoit.asp (span clicks only work on IE, and not on mozilla)

the code for the site is very simple:

<html>
<script language="VBScript">
sub startAudit
    s = "<br><p><span id='exe_all' style='cursor:hand' onclick='vb script:backupAll'><b><u>Execute All</u></b></span></p>"
    document.all("results").innerhtml = s
end sub
sub backupAll
    msgbox "Do you want to run backup?", vbyesno, "Confirm"
end sub
</script>
<body>

<FORM>
<span id="spn_start" onclick='vb script:startAudit()' style="cursor:hand"><b><u>Get Activity Status</u></b></span>
<div id="results"></div>
</FORM>

</body>
</html>

here is the failing autoit code:

#include <IE.au3>
$oIE = _IECreate("http://www.diaglabs.com/test/autoit.asp")
$oSubmit = _IEGetObjById($oIE, "spn_start")
$hwnd = _IEPropertyGet($oIE, "hwnd")
_IEAction ($oSubmit, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

$oSubmit = _IEGetObjById($oIE, "exe_all")
_IEAction ($oSubmit, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

WinWait("Confirm", "Perform suggested action on all folders?")
Send("{ENTER}")
_IELoadWait ($oIE)
exit
Edited by cvn
Link to comment
Share on other sites

I've hosted a sample of the problem I'm having.

http://www.diaglabs.com/test/autoit.asp (span clicks only work on IE, and not on mozilla)

the code for the site is very simple:

<html>
<script language="VBScript">
sub startAudit
    s = "<br><p><span id='exe_all' style='cursor:hand' onclick='vb script:backupAll'><b><u>Execute All</u></b></span></p>"
    document.all("results").innerhtml = s
end sub
sub backupAll
    msgbox "Do you want to run backup?", vbyesno, "Confirm"
end sub
</script>
<body>

<FORM>
<span id="spn_start" onclick='vb script:startAudit()' style="cursor:hand"><b><u>Get Activity Status</u></b></span>
<div id="results"></div>
</FORM>

</body>
</html>

here is the failing autoit code:

#include <IE.au3>
$oIE = _IECreate("http://www.diaglabs.com/test/autoit.asp")
$oSubmit = _IEGetObjById($oIE, "spn_start")
$hwnd = _IEPropertyGet($oIE, "hwnd")
_IEAction ($oSubmit, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

$oSubmit = _IEGetObjById($oIE, "exe_all")
_IEAction ($oSubmit, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

WinWait("Confirm", "Perform suggested action on all folders?")
Send("{ENTER}")
_IELoadWait ($oIE)
exit
Can't help you:

In a Firefox tab, it's not even clickable.

In a Firefox IE Tab, it's clickable but doesn't do anything.

In IE7, it's clickable but doesn't do anything.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Can't help you:

In a Firefox tab, it's not even clickable.

In a Firefox IE Tab, it's clickable but doesn't do anything.

In IE7, it's clickable but doesn't do anything.

:)

???

I have IE7, and it's a two step process. You click "get activity status", then "execute all" shows up, then you click that and a message box shows up.

_IEAction "click" works, but it gets hung up at the second click.

$oIE = _IECreate("http://www.diaglabs.com/test/autoit.asp")

$oTD = _IEGetObjById($oIE, "spn_start")
_IEAction($oTD, "click")
_IELoadWait($oIE)

$oTD = _IEGetObjById($oIE, "exe_all")
_IEAction($oTD, "click")
_IELoadWait($oIE)

WinWaitActive("Confirm")
WinSetState("Confirm", "", @SW_SHOW)
Send("{ENTER}")

^^ clicks work, but hangs at the message prompt

Link to comment
Share on other sites

???

I have IE7, and it's a two step process. You click "get activity status", then "execute all" shows up, then you click that and a message box shows up.

_IEAction "click" works, but it gets hung up at the second click.

$oIE = _IECreate("http://www.diaglabs.com/test/autoit.asp")

$oTD = _IEGetObjById($oIE, "spn_start")
_IEAction($oTD, "click")
_IELoadWait($oIE)

$oTD = _IEGetObjById($oIE, "exe_all")
_IEAction($oTD, "click")
_IELoadWait($oIE)

WinWaitActive("Confirm")
WinSetState("Confirm", "", @SW_SHOW)
Send("{ENTER}")

^^ clicks work, but hangs at the message prompt

You have a typo in your HTML posted. It's "onclick='vb script:" not "vb script".

After fixing that, it works in a Firefox IE tab and IE7.

So, that does give something to test with:

<html>
<script language="VBScript">
sub startAudit
    s = "<br><p><span id='exe_all' style='cursor:hand' onclick='vb script:backupAll'><b><u>Execute All</u></b></span></p>"
    document.all("results").innerhtml = s
end sub
sub backupAll
    msgbox "Do you want to run backup?", vbyesno, "Confirm"
end sub
</script>
<body>

<FORM>
<span id="spn_start" onclick='vb script:startAudit()' style="cursor:hand"><b><u>Get Activity Status</u></b></span>
<div id="results"></div>
</FORM>

</body>
</html>

:)

Whoa... deja vue all over again. I fixed that error - and the forum put it right back. The space between "vb" and "script" is being put there by the forum post editor. At any rate, the demo HTML works if that space is removed in two places.

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...