Sign in to follow this  
Followers 0
LionH

Cant catch link click on local webpage

12 posts in this topic

#1 ·  Posted (edited)

I am running a webserver, with a user interface,

I got this button on the webpage:

<button name='_shutdown'>SHUTDOWN</button>

 

This is what i got in my .au3 script: (running the latest AutoIt v3)

#include <IE.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <String.au3>
#include <Array.au3>
#include <Misc.au3>
#include-once
    
$hGui = GUICreate("userInterface",500,500,0,0,$WS_POPUP)
$Obj = ObjCreate("Shell.Explorer.2")
$CtrlObj = GUICtrlCreateObj($Obj,-1,-1,500,500)
GUISetState (@SW_SHOW)
_IENavigate($Obj, "http://192.168.1.50/userInterface/")
_IELoadWait($Obj)

$oButton1 = _IEGetObjByName($Obj, '_shutdown');
$oEvtButton1 = ObjEvent($Obj, "shutdown_")

 Func shutdown_onclick()
    MsgBox(0, "Click on Shutdown", ".")
EndFunc
    
    
While 1
    Sleep(1000)
Wend

But it doesnt work! I've been searching for a solution for a few days already.

I had it working before, but that was a local .html page. Now a webserver is required because of the dynamic content.

Can you help me? I hope you can, Thank You in Advance

 

Kind regards.

Lion

Edited by LionH

Share this post


Link to post
Share on other sites



Thank you for your reply Universalist, but as far as i know is the _onclick the event that gets detected thanks to:

$oEvtButton1 = ObjEvent($Obj, "shutdown_")
ObjEvent adds onclick(), am i wrong>?

Share this post


Link to post
Share on other sites

@LionH - I think you are correct that it is the prefix to the function being called (sorry - I did not see that the first time).  However, the help file has two formats for ObjEvent.  The second format should show you information about your error:

ObjEvent ( "AutoIt.Error" [, "function"] )
The second format is used for COM Error Handling.
If any COM error occurs, the given function is being called. First parameter for the function will be error object.
You can use it to access different properties of this object.
If the second parameter is omitted, it will return the name of the current Error handler function or function, depending what was used when registering.

Properties of the AutoIt Error Object:

.number The Windows HRESULT value from a COM call 
.windescription The FormatWinError() text derived from .number 
.source Name of the Object generating the error (contents from ExcepInfo.source) 
.description Source Object's description of the error (contents from ExcepInfo.description) 
.helpfile Source Object's helpfile for the error (contents from ExcepInfo.helpfile) 
.helpcontext Source Object's helpfile context id number (contents from ExcepInfo.helpcontext) 
.lastdllerror The number returned from GetLastError() 
.scriptline The script line on which the error was generated

Try that and see what it tells you.


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

Sorry, but i dont understand how to use the AutoIt.Error object in my current script.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Strangest thing....

When i remove:

<meta http-equiv="X-UA-Compatible" content="IE=9,chrome=1">

from the index.php file, it works how it should!?

Which gets me on the point for saying i am sorry for not giving the full HTML source, here it is, including some updates, it still dont work:

.au3:

#include <IE.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <String.au3>
#include <Array.au3>
#include <Misc.au3>
    

$hGui = GUICreate("userInterface",500,500,0,0,$WS_POPUP)
$Obj = ObjCreate("Shell.Explorer.2")
$CtrlObj = GUICtrlCreateObj($Obj,-1,-1,500,500)
GUISetState (@SW_SHOW)
_IENavigate($Obj, "http://192.168.1.50/userInterface/index.php")
_IELoadWait($Obj)

$oButton1 = _IEGetObjByName($Obj, '_shutdown');
$oEvtButton1 = ObjEvent($oButton1, "shutdown_");

Func shutdown_onclick()
    MsgBox(0, "Yo", "Clicked on Shutdown.")
EndFunc
    
While 1
    Sleep(100)
WEnd

.php:

<!doctype html>
<!--[if IE 7 ]>         <html class="no-js ie ie7 lte7 lte8 lte9" lang="en-US"> <![endif]-->
<!--[if IE 8 ]>         <html class="no-js ie ie8 lte8 lte9" lang="en-US"> <![endif]-->
<!--[if IE 9 ]>         <html class="no-js ie ie9 lte9>" lang="en-US"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class="no-js" lang="en-US"> <!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=9,chrome=1">

    <title>WINDOW</title>

    <meta name="viewport" content="width=device-width">

    <link rel="stylesheet" href="css/buttons.css">
    
    <script src="jquery.js"></script>
    <script>window.jQuery || document.write(unescape('%3Cscript src="jquery.js"%3E%3C/script%3E'))</script>
    
    <script type="text/javascript" src="js/buttons.js"></script>
    
<style>
body
    {
        color:#000;
        background:#e6e7e8;
        font-size:22px;
        font-weight:bold;
        font-family:Arial, Helvetica, Sans-serif;
        width:100%;
        margin:0;
        padding:0;
    }
</style>
</head>
<body><button name='_shutdown'>SHUTDOWN</button>
</body>
</html>

When i remove

<meta http-equiv="X-UA-Compatible" content="IE=9,chrome=1">

from the php file, the click gets detected, but i it removes some javascript and css styling, so i hope to get it working including the META tag, i hope to find out why its not working with that meta in the html source..

Anyone? Thank You in Advance

 

Kind regards.

Lion

Edited by LionH

Share this post


Link to post
Share on other sites

When i remove

<meta http-equiv="X-UA-Compatible" content="IE=9,chrome=1">

CSS style seems okay, but javascript stops working... But the button click gets detected...

Share this post


Link to post
Share on other sites

It would be great if anyone could help me... is it my code, is it the webpage? Where is the problem and why is it there?

Share this post


Link to post
Share on other sites

Yes i am creating a button style using buttons.js/buttons.css

Share this post


Link to post
Share on other sites

Take a look at >this approach - it may help since it is not a pure HTML button.

I dont want to click on a button. I want to listen for button clicks and responds with a function. Example:

"You clicked on the NotePad button, we now open notepad for you."

and the function opens notepad... But when i click on the button, nothing happens because AutoIt doesnt listen at IE8+ events?

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