Jump to content

How can I GUIGetMsg from a GUICtrlCreateObj?


 Share

Recommended Posts

Hi everybody,

The following code is just a part of a bigger GUI but works on itself. For now I use the button 'N0NBH' to launch the coders website. If the designers html-code for the banner is put on a 'normal' website, a click on the picture launches the site.  In my GUI the picture is just that..a picture.
I want to remove the button and make the picture  the 'clickable' link. Is this possible with an Object and how would I get the GUICtrlSetTip working?

#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <WindowsConstants.au3>

$HTML = "http://www.hamqsl.com/solar101pic.php"

$SD = GUICreate("Solar data",600, 180)
$hamqsl = GUICtrlCreateButton("N0NBH", 465, 30, 100)
GUICtrlSetTip($hamqsl, "Click to add Solar-Terrestrial Data to your website!")
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetCursor (-1, 0)
$futurebutton1 = GUICtrlCreateLabel("Visit N0NBH's", 460, 70, 150)
GUICtrlSetFont(-1, 14, 200, 0, "Arial")
$futurebutton2 = GUICtrlCreateLabel("site for more", 460, 90, 100)
GUICtrlSetFont(-1, 14, 200, 0, "Arial")
$futurebutton3 = GUICtrlCreateLabel("Banners..", 460, 110, 100)
GUICtrlSetFont(-1, 14, 200, 0, "Arial")

$oIE = ObjCreate("Shell.Explorer.2")
GUICtrlCreateObj($oIE, 10, 10, 435, 158)
;GUICtrlSetTip($banner, "Click to add Solar-Terrestrial Data to your website!") ;not working with Obj
$oIE.navigate($HTML)
$oIE.document.body.scroll = "no"

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Switch $msg
   case $GUI_Event_Close
      ExitLoop
   Case $hamqsl
   ShellExecute("http://www.hamqsl.com/solar.html")
EndSwitch
WEnd

GUIDelete($SD)

As always thanks for taking a peek at it and advice.
Have a great day.

KF5WGB

Edited by KF5WGB
updated code
Link to comment
Share on other sites

It looks like the $HTML you're navigating to isn't what you're looking for... when I navigate to the address you're using, I get a picture and clicking on it does nothing. Try it 

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

14 minutes ago, seadoggie01 said:

It looks like the $HTML you're navigating to isn't what you're looking for... when I navigate to the address you're using, I get a picture and clicking on it does nothing. Try it 

Hi seadoggie01,

That is correct. The $HTML points to the picture which is displayed in the Obj. The 'real' link is in the Switch loop

   ShellExecute("http://www.hamqsl.com/solar.html")

This command is called when you click on the N0NBH button. Now I want to remove the button and make the picture 'activ'. In other words, when you click the picture, the Shellexecute function should be called. I have not figured out (yet) how to make an Obj behave like a button for the Switch .. Case.. function

New problem:
The Obj creates a 'frame' around the picture and I can not get it without that frame. No matter how small I make the

GUICtrlCreateObj($oIE, 10, 10, 435, 158)

Even if I make the Obj the same size as the picture or smaller, I still get some 'frame' around it. Can that be removed?

Thanks

Link to comment
Share on other sites

Seems there a bug using ToolTip over embedded :

#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <WindowsConstants.au3>
#include <GUIToolTip.au3>

$HTML = "http://www.hamqsl.com/solar101pic.php"

$SD = GUICreate("Solar data", 600, 180)
$futurebutton1 = GUICtrlCreateLabel("Visit N0NBH's site for more Banners..", 460, 50, 120, 100)
GUICtrlSetFont(-1, 14, 200, 0, "Arial")

Global $oIE = _IECreateEmbedded()
$hIE = GUICtrlCreateObj($oIE, 10, 10, 435, 160)
_IENavigate($oIE, 'about:blank', 1)
_IENavigate($oIE, $HTML, 1)
$oDocument = $oIE.document
$oDocument.body.scroll = "no"
Local $hToolTip = _GUIToolTip_Create(0)
_GUIToolTip_AddTool($hToolTip, 0, "Click Image to add Solar-Terrestrial Data to your website!", $SD)
_GUIToolTip_AddTool($hToolTip, 0, "Click Image to add Solar-Terrestrial Data to your website!", ControlGetHandle ($SD, "", $futurebutton1))

GUISetState(@SW_SHOW)

Global $oEventObject = ObjEvent($oDocument, "IEEvent2_", "HTMLDocumentEvents2")
If @error Then Exit MsgBox($MB_OK, "AutoIt COM Test", "ObjEvent: Can't use event interface. Error code: " & Hex(@error,8))

While 1
  $msg = GUIGetMsg()
  Switch $msg
    Case $GUI_Event_Close
      ExitLoop
  EndSwitch
WEnd

_GUIToolTip_Destroy($hToolTip)

Volatile Func IEEvent2_onClick($oEvent)
  If $oEvent.srcElement.NodeName = "IMG" Then ShellExecute("http://www.hamqsl.com/solar.html")
EndFunc   ;==>IEEvent2_onClick
#cs
Volatile Func IEEvent2_onMouseOver($oEvent) ; makes AutoIt crash
  Local Static $ToolTip = False
  If $oEvent.srcElement.NodeName = "IMG" Then
    If Not $ToolTip Then ToolTip("Click to add Solar-Terrestrial Data to your website!")
    $ToolTip = True
  Else
    $ToolTip = False
    ToolTip("")
  EndIf
EndFunc   ;==>IEEvent2_onMouseMove
#ce

 

Link to comment
Share on other sites

Here the way I found (without using the event handler) to show the tool tip over the image :

#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <WindowsConstants.au3>
#include <GUIToolTip.au3>

$HTML = "http://www.hamqsl.com/solar101pic.php"

$SD = GUICreate("Solar data", 600, 180)
$futurebutton1 = GUICtrlCreateLabel("Visit N0NBH's site for more Banners..", 460, 50, 120, 100)
GUICtrlSetFont(-1, 14, 200, 0, "Arial")

Global $oIE = _IECreateEmbedded()
$hIE = GUICtrlCreateObj($oIE, 10, 10, 435, 160)
_IENavigate($oIE, 'about:blank', 1)
_IENavigate($oIE, $HTML, 1)
$oDocument = $oIE.document
$oDocument.body.scroll = "no"
GUISetState(@SW_SHOW)

Global $oEventObject = ObjEvent($oDocument, "IEEvent2_", "HTMLDocumentEvents2")
If @error Then Exit MsgBox($MB_OK, "AutoIt COM Test", "ObjEvent: Can't use event interface. Error code: " & Hex(@error,8))
Local $aPos, $aPosPrec = [0,0]
While 1
  $aPos = GUIGetCursorInfo ($SD)
  If Not @error Then
    If $aPos[0] >= 15 And $aPos[0] <= 430 And $aPos[1] >= 15 And $aPos[1] <= 155 Then
      If $aPos[0] <> $aPosPrec[0] Or $aPos[1] <> $aPosPrec[1] And WinActive ($SD) Then
        ToolTip ("Click Image to add Solar-Terrestrial Data to your website!")
        $aPosPrec[0] = $aPos[0]
        $aPosPrec[1] = $aPos[1]
      EndIf
    Else
      ToolTip ("")
    EndIf
  EndIf
  Switch GUIGetMsg()
    Case $GUI_Event_Close
      ExitLoop
  EndSwitch
WEnd

Volatile Func IEEvent2_onClick($oEvent)
  If $oEvent.srcElement.NodeName = "IMG" Then
    ToolTip ("")
    ShellExecute("http://www.hamqsl.com/solar.html")
  EndIf
EndFunc   ;==>IEEvent2_onClick

 

Link to comment
Share on other sites

9 hours ago, KF5WGB said:

Even if I make the Obj the same size as the picture or smaller, I still get some 'frame' around it. Can that be removed?

Yes and No.  It is the HTML source code of the image that causing the frame not AutoIt.  If you insist on using this code, the response is No.

But if you create your own HTML source code (and reading the site Image), the response is Yes. 

Link to comment
Share on other sites

5 hours ago, Nine said:

Yes and No.  It is the HTML source code of the image that causing the frame not AutoIt.  If you insist on using this code, the response is No.

But if you create your own HTML source code (and reading the site Image), the response is Yes. 

Hi Nine,

Many thanks for your code. Works just great. I added _IEAction($oIE, "refresh") after
 _IENavigate($oIE, 'about:blank', 1)
_IENavigate($oIE, $HTML, 1)

For some reason I got an old IMG displayed when running the script. The refresh got the 'newer' one from the server.
I sure have to learn a lot  more about the ObjEvent, what events are there, what names, how to set them up and what comes back etc. Guess I find those at Micro$ofts website. 

To get rid of the frame around the image, maybe download the image and use GUICtrlCreatePic to create a clickable IMG.
What do you think. Possible?

Thanks again and have a great day
KF5WGB

Link to comment
Share on other sites

Yep, totally possible. I would prefer personally make my own HTML code since it is very easy to do, and you would get the newest image without having to download it.

Take a look at this :

#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <WindowsConstants.au3>

$HTML = "http://www.hamqsl.com/solar101pic.php"

$SD = GUICreate("Solar data", 600, 180)
$futurebutton1 = GUICtrlCreateLabel("Visit N0NBH's site for more Banners..", 460, 50, 120, 100)
GUICtrlSetFont(-1, 14, 200, 0, "Arial")

GUISetState(@SW_SHOW)

Global $oIE = _IECreateEmbedded()
$hIE = GUICtrlCreateObj($oIE, 10, 10, 435, 160)
_IENavigate($oIE, 'about:blank', 1)
_IEDocWriteHTML($oIE, _GetHTML2())
_IEAction($oIE, "refresh")
_IELoadWait($oIE)

;_IENavigate($oIE, $HTML, 1)
$oDocument = $oIE.document
$oDocument.body.scroll = "no"

Global $oEventObject = ObjEvent($oDocument, "IEEvent2_", "HTMLDocumentEvents2")
If @error Then Exit MsgBox($MB_OK, "AutoIt COM Test", "ObjEvent: Can't use event interface. Error code: " & Hex(@error, 8))

Local $aPos, $aPosPrec = [0, 0]
While True
  Switch GUIGetMsg()
    Case $GUI_Event_Close
      ExitLoop
  EndSwitch
  $aPos = GUIGetCursorInfo($SD)
  If @error Then ContinueLoop
  If $aPos[0] >= 10 And $aPos[0] <= 435 And $aPos[1] >= 10 And $aPos[1] <= 160 Then
    If ($aPos[0] <> $aPosPrec[0] Or $aPos[1] <> $aPosPrec[1]) And WinActive($SD) Then
      ToolTip("Click Image to add Solar-Terrestrial Data to your website!")
      $aPosPrec[0] = $aPos[0]
      $aPosPrec[1] = $aPos[1]
    EndIf
  Else
    ToolTip("")
  EndIf
WEnd

Volatile Func IEEvent2_onClick($oEvent)
  If $oEvent.srcElement.NodeName = "IMG" And $oEvent.srcElement.id = "IMG1" Then
    ToolTip("")
    ShellExecute("http://www.hamqsl.com/solar.html")
  EndIf
EndFunc   ;==>IEEvent2_onClick

Func _GetHTML2()
  Local $sHTML = _
      "<!DOCTYPE HTML>" & @CRLF & _
      "<html>" & @CRLF & _
      "<head>" & @CRLF & _
      '<meta http-equiv="X-UA-Compatible" content="IE=edge" />' & @CRLF & _
      "<title>solar101pic.php (410×125)</title>" & @CRLF & _
      '</head>' & @CRLF & _
      '<body style="margin: 12px; background: #0e0e0e;">' & @CRLF & _
      '<img id="IMG1" style="-webkit-user-select: none;margin: auto;" src="http://www.hamqsl.com/solar101pic.php">' & @CRLF & _
      "</body>" & @CRLF & _
      "</html>"
  Return $sHTML
EndFunc   ;==>_GetHTML2

Edit : maybe the old image comes from your local IE cache.  Clearing it may solve your problem...

Edit2 : corrected a small bug in the code :)

Edited by Nine
Link to comment
Share on other sites

Hi Nine,

Fantastic. This is even better. Thank you so much. Like I said before.. so much to learn about COM, Objects etc. Got a tip where to start?

I looked up Volatile in the AutoIt help and see it is experimental. Not really sure what it does and why it is needed to be a part of the function. I know the function does not work without it. I removed it just for the heck of it to see what happens. 

Again, thank you very much.
Have a great rest of the weekend.
KF5WGB

Edited by KF5WGB
forgot something
Link to comment
Share on other sites

1 hour ago, KF5WGB said:

Have a great rest of the weekend.

You too. 

1 hour ago, KF5WGB said:

Got a tip where to start?

MSDN will be soon your best friend.  Just google it with MSDN as the first word. 

Link to comment
Share on other sites

Instead of monitoring events fired by the "document" and then check if that event is bubbled up from the image, you could also catch events fired directly from the image instead.
To do this I've seen that a "workaround" function is to be used, that I've posted in an udf you can find here: https://www.autoitscript.com/forum/topic/200338-browsercontrol-companion/
I've just copied only that specific function at the bottom of this script, but you could include that whole udf if you need some other of the included functions.
In this way you can simplify the management of the ToolTip() by setting some global variables in the onMouseMove and onMouseleave event functions of the IMG control.
Also, you can fit the image in the whole space of the WebBrowser control by using the Style parameter within the IMG tag with for example this values:
style="position: absolute; left:0; top:0; width: 435px; height: 160px
I've modified a bit the nice script posted by @Nine just to show what I'm talking about.

#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <WindowsConstants.au3>

$SD = GUICreate("Solar data", 600, 180)
$futurebutton1 = GUICtrlCreateLabel("Visit N0NBH's site for more Banners..", 460, 50, 120, 100)
GUICtrlSetFont(-1, 14, 200, 0, "Arial")

GUISetState(@SW_SHOW)

Global $oIE = _IECreateEmbedded()
Global $bUpdateTip, $bTurnOff

$hIE = GUICtrlCreateObj($oIE, 10, 10, 435, 160)
_IENavigate($oIE, 'about:blank', 1)
_IEDocWriteHTML($oIE, _GetHTML2())
_IEAction($oIE, "refresh")
_IELoadWait($oIE)

$oDocument = $oIE.document
$oDocument.body.scroll = "no"
; ---
$oMyIMG = $oDocument.getElementById('IMG1') ; <-- this reference doesn't works in ObjEvent()

$oMyIMG = _WebBrowser_JS_ElementGetRef($oIE, $oMyIMG) ; <-- the reference returned by this function will work in ObjEvent()
;                                                           You can find this and some other utility functions related to
;                                                           the BrowserControl here: https://www.autoitscript.com/forum/topic/200338-browsercontrol-companion/

; set ObjEvent to catch events from the IMG element
; https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa742802%28v%3dvs.85%29
Global $oEventObject2 = ObjEvent($oMyIMG, "IMGevent_", "HTMLImgEvents2") ; <-- catch directly events fired by the image

; see here for more references:
; https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/hh801968(v=vs.85)

If @error Then Exit MsgBox($MB_OK, "AutoIt COM Test", "ObjEvent: Can't use event interface. Error code: " & Hex(@error, 8))

Local $aPos, $aPosPrec = [0, 0]
While True
    Switch GUIGetMsg()
        Case $GUI_Event_Close
            ExitLoop
    EndSwitch
    If $bUpdateTip Then
        ToolTip("Click Image to add Solar-Terrestrial Data to your website!")
        $bUpdateTip = False
    ElseIf $bTurnOff Then
        ToolTip("")
        $bTurnOff = False
    EndIf
WEnd

Volatile Func IMGevent_onClick($oEvent)
    ShellExecute("http://www.hamqsl.com/solar.html")
EndFunc   ;==>IMGevent_onClick

Volatile Func IMGevent_onMouseMove($oEvent)
    $bUpdateTip = True
EndFunc   ;==>IMGevent_onMouseMove

Volatile Func IMGevent_onMouseleave($oEvent)
    $bTurnOff = True
EndFunc   ;==>IMGevent_onMouseleave

Func _GetHTML2()
    Local $sHTML = _
            "<!DOCTYPE HTML>" & @CRLF & _
            "<html>" & @CRLF & _
            "<head>" & @CRLF & _
            '<meta http-equiv="X-UA-Compatible" content="IE=edge" />' & @CRLF & _
            "<title>solar101pic.php (410×125)</title>" & @CRLF & _
            '</head>' & @CRLF & _
            '<body>' & @CRLF & _
            '' & @CRLF & _ ; '<body style="margin: 12px; background: #0e0e0e;">' & @CRLF & _
            '' & @CRLF & _ ; '<img id="IMG1" style="-webkit-user-select: none;margin: auto;" src="http://www.hamqsl.com/solar101pic.php">' & @CRLF & _
            '<img id="IMG1" src="http://www.hamqsl.com/solar101pic.php", style="position: absolute; left:0; top:0; width: 435px; height: 160px">' & @CRLF & _
            "</body>" & @CRLF & _
            "</html>"
    Return $sHTML
EndFunc   ;==>_GetHTML2

; #FUNCTION# ====================================================================================================================
; Name ..........: _WebBrowser_JS_ElementGetRef
; Description ...: retrieves a reference of an object by it's ID suitable to be used from AutoIt
; Syntax ........: _WebBrowser_JS_ElementGetRef(Byref $oIE_Server, $oElement)
; Parameters ....: $oIE_Server          - a Webbrowser object reference.
;                  $oElement            - a reference to an object element of the web page.
; Return values .: an Object reference to the passed element (retrieved by means of ID)
; Author ........: Gianni Addiego (Chimp)
; Modified ......:
; Notes .......: the reference to the object retrieved by this function can be successfully passed to the AutoIt function ObjEvent().
;                If you simply use a reference to a javascript object retrieved by any other means, but not by it's ID, it may not work
;                in the AutoIt function ObjEvent() (strange but true), so the need to write this function that will force a reference by ID
;                to the passed object. There is no need to pass the ID of that object since it's retrieved automatically by the function.
;                If the passed object does not have an ID, we create one on the fly for the sole purpose of referring to it and release it
;                immediately afterwards in order to leave things as they were.
; Related .......:
; Link ..........: https://www.autoitscript.com/forum/topic/200338-browsercontrol-companion/
; Example .......:
; ===============================================================================================================================
Func _WebBrowser_JS_ElementGetRef(ByRef $oIE_Server, $oElement)

    Local $oWindow = $oIE_Server.document.parentwindow ; .JSglobal
    Local $oElementByIdReference

    If $oElement.Id = '' Then
        $oElement.setAttribute('Id', 'DummyId') ; we need an ID (a temporary ID)
        $oElementByIdReference = Execute('$oWindow.' & $oElement.getAttribute('Id')) ; get element's reference by Id
        $oElement.setAttribute('Id', '') ; remove the temporary ID (we leave things as we found them)
    Else
        $oElementByIdReference = Execute('$oWindow.' & $oElement.getAttribute('Id'))
    EndIf

    Return $oElementByIdReference
EndFunc   ;==>_WebBrowser_JS_ElementGetRef

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Hi Chimp,

Thanks for your input/code and links to MS. Lots of info and reading for me to do. 
I got one more question. Hey Nine, in case you continue to read this thread. I added this into the $sHTML

'<meta http-equiv="refresh" content="600; url=http://www.hamqsl.com/solar101pic.php">' & @CRLF & _

before the <Title> tag.  When the time is up, the page reloads but the formatting is gone. Horizontal/ scrollbars and Frame is back.
Why is that? Shouldn't 

'<img id="IMG1" src="http://www.hamqsl.com/solar101pic.php", style="position: absolute; left:0; top:0; width: 410px; height: 125px">' & @CRLF & _

take care of that?

Anyway thanks to both of you and happy coding.
KF5WGB

P.S.: I bet you know that changing content to 10 refreshes faster for testing 😉 The final refresh is more like content="3600",

Edited by KF5WGB
added P.S.
Link to comment
Share on other sites

  • 3 weeks later...

Tested some variations on @Chimp approach, seems to be working without companion, under this situation :

#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <WindowsConstants.au3>

$SD = GUICreate("Solar data", 600, 180)
$futurebutton1 = GUICtrlCreateLabel("Visit N0NBH's site for more Banners..", 460, 50, 120, 100)
GUICtrlSetFont(-1, 14, 200, 0, "Arial")

GUISetState(@SW_SHOW)

Global $oIE = _IECreateEmbedded()
$hIE = GUICtrlCreateObj($oIE, 10, 10, 435, 160)
_IENavigate($oIE, 'about:blank', 1)
_IEDocWriteHTML($oIE, _GetHTML2())
_IEAction($oIE, "refresh")
_IELoadWait($oIE)

$oDocument = $oIE.document
$oDocument.body.scroll = "no"

$oImage = _IEGetObjById($oIE, 'IMG1')
Global $oEventObject2 = ObjEvent($oImage, "IMGevent_", "HTMLImgEvents2") ; <-- catch directly events fired by the image
If @error Then Exit MsgBox($MB_OK, "AutoIt COM Test", "ObjEvent: Can't use event interface. Error code: " & Hex(@error, 8))

Global $bUpdateTip, $bTurnOff

While True
  Switch GUIGetMsg()
    Case $GUI_Event_Close
      ExitLoop
  EndSwitch
   If $bUpdateTip Then
        ToolTip("Click Image to add Solar-Terrestrial Data to your website!")
        $bUpdateTip = False
    ElseIf $bTurnOff Then
        ToolTip("")
        $bTurnOff = False
   EndIf
WEnd

Func _GetHTML2()
  Local $sHTML = _
      "<!DOCTYPE HTML>" & @CRLF & _
      "<html>" & @CRLF & _
      "<head>" & @CRLF & _
      '<meta http-equiv="X-UA-Compatible" content="IE=8">' & @CRLF & _
      '</head>' & @CRLF & _
      '<body style="margin: 12px; background: #0e0e0e;">' & @CRLF & _
      '<img id="IMG1" src="http://www.hamqsl.com/solar101pic.php">' & @CRLF & _
      "</body>" & @CRLF & _
      "</html>"
  Return $sHTML
EndFunc   ;==>_GetHTML2

Volatile Func IMGevent_onClick($oEvent)
    ShellExecute("http://www.hamqsl.com/solar.html")
EndFunc   ;==>IMGevent_onClick

Volatile Func IMGevent_onMouseMove($oEvent)
    $bUpdateTip = True
EndFunc   ;==>IMGevent_onMouseMove

Volatile Func IMGevent_onMouseleave($oEvent)
    $bTurnOff = True
EndFunc   ;==>IMGevent_onMouseleave

Works on win7 and win10...

Link to comment
Share on other sites

23 hours ago, Nine said:

Tested some variations on @Chimp approach, seems to be working without companion, under this situation :

#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <WindowsConstants.au3>

$SD = GUICreate("Solar data", 600, 180)
$futurebutton1 = GUICtrlCreateLabel("Visit N0NBH's site for more Banners..", 460, 50, 120, 100)
GUICtrlSetFont(-1, 14, 200, 0, "Arial")

GUISetState(@SW_SHOW)

Global $oIE = _IECreateEmbedded()
$hIE = GUICtrlCreateObj($oIE, 10, 10, 435, 160)
_IENavigate($oIE, 'about:blank', 1)
_IEDocWriteHTML($oIE, _GetHTML2())
_IEAction($oIE, "refresh")
_IELoadWait($oIE)

$oDocument = $oIE.document
$oDocument.body.scroll = "no"

$oImage = _IEGetObjById($oIE, 'IMG1')
Global $oEventObject2 = ObjEvent($oImage, "IMGevent_", "HTMLImgEvents2") ; <-- catch directly events fired by the image
If @error Then Exit MsgBox($MB_OK, "AutoIt COM Test", "ObjEvent: Can't use event interface. Error code: " & Hex(@error, 8))

Global $bUpdateTip, $bTurnOff

While True
  Switch GUIGetMsg()
    Case $GUI_Event_Close
      ExitLoop
  EndSwitch
   If $bUpdateTip Then
        ToolTip("Click Image to add Solar-Terrestrial Data to your website!")
        $bUpdateTip = False
    ElseIf $bTurnOff Then
        ToolTip("")
        $bTurnOff = False
   EndIf
WEnd

Func _GetHTML2()
  Local $sHTML = _
      "<!DOCTYPE HTML>" & @CRLF & _
      "<html>" & @CRLF & _
      "<head>" & @CRLF & _
      '<meta http-equiv="X-UA-Compatible" content="IE=8">' & @CRLF & _
      '</head>' & @CRLF & _
      '<body style="margin: 12px; background: #0e0e0e;">' & @CRLF & _
      '<img id="IMG1" src="http://www.hamqsl.com/solar101pic.php">' & @CRLF & _
      "</body>" & @CRLF & _
      "</html>"
  Return $sHTML
EndFunc   ;==>_GetHTML2

Volatile Func IMGevent_onClick($oEvent)
    ShellExecute("http://www.hamqsl.com/solar.html")
EndFunc   ;==>IMGevent_onClick

Volatile Func IMGevent_onMouseMove($oEvent)
    $bUpdateTip = True
EndFunc   ;==>IMGevent_onMouseMove

Volatile Func IMGevent_onMouseleave($oEvent)
    $bTurnOff = True
EndFunc   ;==>IMGevent_onMouseleave

Works on win7 and win10...

.... it doesn't works here

r8stgZD.png

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

I've already noticed strange IE behaviors at other times, that's why I used that "companion function" with which the script seems to work in a more stable way.
P.S.
Is there anyone else please that could test both scripts to see which one work? (or if do both works?)
Thanks.

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Windows 10 Version 1903 Build 18362.10024 (IE 11 with matching build)

Both scripts work for me. Both take 10+ seconds to get the picture, but Chimp's will flash the picture for a second before going white. Nine's picture shows up as not stretched, however.
 

Edited with requested changes below: (at work now)

Windows 10 Version 1709 Build 16299.1451 (IE 11 with matching build)

Nine's script errors out with COM error like @Chimp mentioned. Both scripts fail to show the picture (behind a proxy server, though, so expected).

Edited by seadoggie01

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

Thanks @seadoggie01 :)

could You also please try to change the string: content = "IE = 8" with content = "IE = edge" to line 46 of  @Nine's script and report what happens ?. Thanks a lot again.

.... somebody else?

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

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