Jump to content
Sign in to follow this  
mesale0077

ObjEvent dont work

Recommended Posts

mesale0077

sanaldosya.org_1392146002__a444dsz.jpg

ios: w8 64bit

worked before.

but

After it did not work

logos click dont work  why?

or why it does not work,? Do it need to completely remove autoıt,What is your suggestion to remove it completely.

source

http://www.mediafire.com/download/131v3jgnq73wgmm/deneme123456.rar

I am using autoit latest version

$data =""& @CR & @CR & _
@tab&@tab&"Made By mesale0077" & @CR & _
        @tab&" Thanks to the Authors of AutoIt v3 " & _
        "for their free"& @CR & "wonderfull scripting language" & @CR & @CR &@CR &@CR &@CR & _
            @tab&@tab&"Thank you ALL Autoit Team"
#include <IE.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <ProgressConstants.au3>
#include <EditConstants.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#include <IE.au3>

Const $SC_CLOSE = 0xF060
Const $MF_BYCOMMAND = 0x0
Const $MF_GRAYED = 0x1
_GDIPlus_Startup()
Global $iW = 329, $iH = 7
;Global  $STM_SETIMAG = 0x0172; $IMAGE_BITMAP = 0
Global $hHBmp_BG, $hB, $iPerc = 0, $iSleep = 30, $s = 0, $sFont = "Segoe Script"
If @OSBuild < 6000 Then $sFont = "Arial Black"
dim $Label1[100]
$Form1 = GUICreate("Autoit databank", 0, 0)
GUISetBkColor(0x000000)
GUISetState(@SW_SHOW)
grow($Form1, 380, 150, 1, 5)
$Edit1 = GUICtrlCreateEdit("", 24, 145, 329, 145)
GUICtrlSetData(-1, "Drop and Drag")
 GUICtrlSetState(-1,$GUI_HIDE)
$Button1 = GUICtrlCreateButton("Upload", 112, 295, 161, 41)
 GUICtrlSetState(-1,$GUI_HIDE)
;$Progress1 = GUICtrlCreateProgress(24, 125, 329, 17)
 ;GUICtrlSetState(-1,$GUI_HIDE)
$ListView1 = GUICtrlCreateListView("",  24, 145, 329, 145)
 GUICtrlSetState(-1,$GUI_HIDE)
$Button2 = GUICtrlCreateButton("Dowland", 112, 295, 161, 41)
 GUICtrlSetState(-1,$GUI_HIDE)
 $Intro = GUICtrlCreateLabel($data, 5, 136, 380, 380)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 11)
  GUICtrlSetState(-1,$GUI_HIDE)
 $iPic = GUICtrlCreatePic("", 24, 130, $iW, $iH)
GUICtrlSetState(-1,$GUI_SHOW)
$hHBmp_BG = _GDIPlus_LineProgressbar($iPerc, $iW, $iH, "Loading: ", 0xF02187E7, $sFont)
$hB = GUICtrlSendMsg($iPic, 0x0172, $IMAGE_BITMAP, $hHBmp_BG)
$hMenu = DllCall("user32.dll", "hwnd", "GetSystemMenu", "hwnd", $Form1, "int", 0)
DllCall("user32.dll","hwnd","EnableMenuItem", "hwnd", $hMenu[0], "int",$SC_CLOSE, "int", BitOr($MF_BYCOMMAND,$MF_GRAYED))
Local $oIE = _IECreateEmbedded()
GUICtrlCreateObj($oIE,-50,-40, 500, 160)
_IENavigate($oIE, @ScriptDir&"/images/index.html")
 $obj = _IEGetObjById($oIE, "1")
ObjEvent($obj, "UPLOAD_")
 $obj = _IEGetObjById($oIE, "2")
ObjEvent($obj, "DOWNLOAD_")
 $obj = _IEGetObjById($oIE, "3")
ObjEvent($obj, "ABOUT_")
 $obj = _IEGetObjById($oIE, "4")
ObjEvent($obj, "CLOSEMain_")

_HideScroll($oIE)
Func _HideScroll($Temp_Object)
Local $hText = 'var temp_h1 = document.body.clientHeight;'& _
         'var temp_h2 = document.documentElement.clientHeight;'& _
         'var isXhtml = (temp_h2<=temp_h1&&temp_h2!=0)?true:false;'& _
         'var htmlbody = isXhtml?document.documentElement:document.body;'& _
         'htmlbody.style.overflow = "hidden";'
$Temp_Object.document.parentwindow.execscript($hText,"javascript")
EndFunc


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        GUIRegisterMsg($WM_TIMER, "")
            _WinAPI_DeleteObject($hHBmp_BG)
            _GDIPlus_Shutdown()
            GUIDelete()
            Exit

            Case $Button1
            $s -= 0.1
$iPerc = 0

    $hHBmp_BG = _GDIPlus_LineProgressbar($iPerc, $iW, $iH, "Loading: ", 0xF02187E7, $sFont)
    $hB = GUICtrlSendMsg($iPic, 0x0172, $IMAGE_BITMAP, $hHBmp_BG)
        GUIRegisterMsg($WM_TIMER, "PlayAnim")
DllCall("user32.dll", "int", "SetTimer", "hwnd", $Form1 , "int", 0, "int", $iSleep, "int", 0)
Case $Button2
    $s -= 0.1
$iPerc = 0

    $hHBmp_BG = _GDIPlus_LineProgressbar($iPerc, $iW, $iH, "Loading: ", 0xF02187E7, $sFont)
    $hB = GUICtrlSendMsg($iPic, 0x0172, $IMAGE_BITMAP, $hHBmp_BG)
        GUIRegisterMsg($WM_TIMER, "PlayAnim")
DllCall("user32.dll", "int", "SetTimer", "hwnd", $Form1 , "int", 0, "int", $iSleep, "int", 0)
    EndSwitch

WEnd

func UPLOAD_onclick()
$s -= 0.1
$iPerc = 0
GUIRegisterMsg($WM_TIMER, "")
$hHBmp_BG = _GDIPlus_LineProgressbar($iPerc, $iW, $iH, "Loading: ", 0xF02187E7, $sFont)
    $hB = GUICtrlSendMsg($iPic, 0x0172, $IMAGE_BITMAP, $hHBmp_BG)
global $aPos = WinGetPos($Form1)
if $aPos[3]>155 then
WinMove($Form1, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3]-220)
sleep(200)
WinMove($Form1, "", $aPos[0], $aPos[1], $aPos[2], 155+220)
endif
if  $aPos[3]=155 then WinMove($Form1, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3]+220)
GUICtrlSetState($Intro,$GUI_HIDE)
 GUICtrlSetState($ListView1,$GUI_HIDE)
GUICtrlSetState( $Button2,$GUI_HIDE)
GUICtrlSetState( $Edit1,$GUI_SHOW)
GUICtrlSetState($Button1,$GUI_SHOW)
GUICtrlSetState($iPic,$GUI_SHOW)


endfunc
Func DOWNLOAD_onclick()
$s -= 0.1
$iPerc = 0
GUIRegisterMsg($WM_TIMER, "")
$hHBmp_BG = _GDIPlus_LineProgressbar($iPerc, $iW, $iH, "Loading: ", 0xF02187E7, $sFont)
    $hB = GUICtrlSendMsg($iPic, 0x0172, $IMAGE_BITMAP, $hHBmp_BG)
global $aPos = WinGetPos($Form1)
if $aPos[3]>155 then
WinMove($Form1, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3]-220)
sleep(200)
WinMove($Form1, "", $aPos[0], $aPos[1], $aPos[2], 155+220)
endif
if  $aPos[3]=155 then WinMove($Form1, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3]+220)
GUICtrlSetState($iPic,$GUI_SHOW)
GUICtrlSetState( $Edit1,$GUI_HIDE)
GUICtrlSetState($Button1,$GUI_HIDE)
GUICtrlSetState( $ListView1,$GUI_SHOW)
GUICtrlSetState($Button2,$GUI_SHOW)
GUICtrlSetState($Intro,$GUI_HIDE)


EndFunc
Func ABOUT_onclick()
global $aPos = WinGetPos($Form1)
if $aPos[3]>155 then
WinMove($Form1, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3]-220)
sleep(200)
WinMove($Form1, "", $aPos[0], $aPos[1], $aPos[2], 155+220)
endif
if  $aPos[3]=155 then WinMove($Form1, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3]+220)
 GUICtrlSetState($ListView1,$GUI_HIDE)
GUICtrlSetState( $Button2,$GUI_HIDE)
GUICtrlSetState( $iPic,$GUI_HIDE)
GUICtrlSetState( $Edit1,$GUI_HIDE)
GUICtrlSetState($Button1,$GUI_HIDE)
GUICtrlSetState($Intro,$GUI_SHOW)

EndFunc
Func CLOSEMain_onclick()
global $aPos = WinGetPos($Form1)
if $aPos[3]>155 then
WinMove($Form1, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3]-220)
sleep(200)
endif
grow($Form1, 0, 0, 3, 2)

    Exit
EndFunc
Func MyErrFunc()
    SetError(0,0,0)
    Return
EndFunc


Func grow($gui, $guix, $guiy, $type, $step)
$size = WinGetClientSize($gui)
If $type = 1 Then
For $x = $size[0] To $guix Step $step/3
$size = WinGetClientSize($gui)
$zx = (@DesktopWidth/2) - ($size[0]/2)
$zy = (@DesktopHeight/2) - ($size[1]/2)
WinMove($gui, '', $zx, $zy, $x + $step, 25)
Next
For $y = $size[1] To $guiy Step $step/2
$size = WinGetClientSize($gui)
$zx = (@DesktopWidth/2) - ($size[0]/2)
$zy = (@DesktopHeight/2) - ($size[1]/2)
WinMove($gui, '', $zx, $zy, $x, $y + $step)
Next
endif
If $type = 2 Then
For $w = 0 To 102 Step $step/4
$size = WinGetClientSize($gui)
$dw = (@DesktopWidth/2) - ($size[0]/2)
$dh = (@DesktopHeight/2) - ($size[1]/2)
WinMove($gui, '', $dw, $dh, ($guix/100)*$w, ($guiy/100)*$w)
Next
EndIf
If $type = 3 Then
local $aPos = WinGetClientSize($gui)
local $gPos = WinGetPos($gui)
for $aaa= 1 to $aPos[0]-28 step 2
WinMove($gui, "", $gPos[0], $gPos[1], $aPos[0], $aPos[1] - $aaa)
next
$Pos = WinGetPos($gui)
for $mm= 1 to $aPos[1]+200 step 2
WinMove($gui, "", $gPos[0], $gPos[1], $aPos[0] - $mm, 28)
next
endif
EndFunc


Func PlayAnim()
    $hHBmp_BG = _GDIPlus_LineProgressbar($iPerc, $iW, $iH, "Loading: ", 0xF02187E7, $sFont)
    $hB = GUICtrlSendMsg($iPic, 0x0172, $IMAGE_BITMAP, $hHBmp_BG)
    If $hB Then _WinAPI_DeleteObject($hB)
    _WinAPI_DeleteObject($hHBmp_BG)
    $iPerc += 0.025 + Abs(Cos($s / 4))
    $s -= 0.1
    If $iPerc > 100 Then
        $iPerc = 0
        $s *= Random(1, 4)
    EndIf
EndFunc   ;==>PlayAnim


Func _GDIPlus_LineProgressbar($fProgress, $iW, $iH, $sText = "Loading: ", $iColorLineProgressbar = 0xF02187E7, $sFont = "Segoe Script", $bHBitmap = True)
    Local $aColorPattern[4][4] = [[0xFF2A2A2A, 0xFF131313, 0xFF1A1A1A, 0xFF131313], _
                                  [0xFF1F1F1F, 0xFF1A1A1A, 0xFF131313, 0xFF1A1A1A], _
                                  [0xFF1A1A1A, 0xFF131313, 0xFF2A2A2A, 0xFF131313], _
                                  [0xFF131313, 0xFF1A1A1A, 0xFF1F1F1F, 0xFF1A1A1A]]
    Local Const $hBmp_texture = _GDIPlus_BitmapCreateFromScan0(4, 4)
    Local $iX, $iY
    For $iY = 0 To 3
        For $iX = 0 To 3
            _GDIPlus_BitmapSetPixel($hBmp_texture, $iX, $iY, $aColorPattern[$iY][$iX]) ;generate texture
        Next
    Next
    Local Const $hBrush_Texture = _GDIPlus_TextureCreate($hBmp_texture)
    _GDIPlus_BitmapDispose($hBmp_texture)
    Local Const $hBitmap  = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)
;~  _GDIPlus_GraphicsSetSmoothingMode($hGfx, 5) ;smoothing doesn't look good for light effect
    _GDIPlus_GraphicsFillRect($hGfx, 0, 0, $iW, $iH, $hBrush_Texture)
    Local Const $iW2 = $iW / 2, $iH2 = $iH / 2, $iDY = 7, $hBrush_Bg = _GDIPlus_BrushCreateSolid(0x80000000), _
                $hBrush_Line = _GDIPlus_BrushCreateSolid($iColorLineProgressbar), _
                $hBrush_Light = _GDIPlus_LineBrushCreate(($iW * $fProgress / 100 + 2) / 2, 0, ($iW * $fProgress / 100 + 2) / 2, 15.6, 0x78000000 + BitAND($iColorLineProgressbar, 0x00A0A0F0), 0x10000000, 3)
    _GDIPlus_LineBrushSetLinearBlend($hBrush_Light, 0.45, 1)
    _GDIPlus_LineBrushSetGammaCorrection($hBrush_Light)
    _GDIPlus_GraphicsFillRect($hGfx, 0, $iH2 - 1, $iW, 3, $hBrush_Bg)
    Local $aPoints[6][2]
    $aPoints[0][0] = 5
    $aPoints[1][0] = 0
    $aPoints[1][1] = $iH2 - $iDY
    $aPoints[2][0] = $iW * $fProgress / 100 - 2
    $aPoints[2][1] = $iH2 - $iDY
    $aPoints[3][0] = $iW * $fProgress / 100 + 2
    $aPoints[3][1] = $iH2
    $aPoints[4][0] = $iW * $fProgress / 100 - 2
    $aPoints[4][1] = $iH2 + $iDY
    $aPoints[5][0] = 0
    $aPoints[5][1] = $iH2 + $iDY
    _GDIPlus_GraphicsFillPolygon($hGfx, $aPoints, $hBrush_Light)
    _GDIPlus_GraphicsFillRect($hGfx, 0, $iH2, $iW * $fProgress / 100, 1, $hBrush_Line)

    Local Const $hBitmap_Text = _GDIPlus_BitmapCreateFromScan0($iW, $iH2)
    Local Const $hGfx_Text = _GDIPlus_ImageGetGraphicsContext($hBitmap_Text)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx_Text, 4)

    Local Const $hPath = _GDIPlus_PathCreate()
    Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont)
    Local Const $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local Const $tLayout = _GDIPlus_RectFCreate(0, $iH / 8, $iW)
    Local Const $hBrush_Text = _GDIPlus_BrushCreateSolid(0xE0FFFFFF), $hPen_Text = _GDIPlus_PenCreate(0x80000000, 4)

    ;_GDIPlus_PathAddString($hPath, StringFormat($sText & " %02d%", $fProgress), $tLayout, $hFamily, 0, $iH / 10, $hFormat)
    _GDIPlus_GraphicsDrawPath($hGfx_Text, $hPath, $hPen_Text)
    _GDIPlus_GraphicsFillPath($hGfx_Text, $hPath, $hBrush_Text)
    _GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap_Text, 0, $iH2, $iW, $iH2)

    _GDIPlus_GraphicsDispose($hGfx_Text)
    _GDIPlus_BitmapDispose($hBitmap_Text)

    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush_Text)
    _GDIPlus_BrushDispose($hBrush_Line)
    _GDIPlus_BrushDispose($hBrush_Bg)
    _GDIPlus_BrushDispose($hBrush_Texture)
    _GDIPlus_BrushDispose($hBrush_Light)
    _GDIPlus_PenDispose($hPen_Text)
    _GDIPlus_GraphicsDispose($hGfx)
    If $bHBitmap Then
        Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hHBITMAP
    EndIf
    Return $hBitmap
EndFunc

Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    If BitAND($wParam, 0xFFF0) = $SC_CLOSE Then Return
EndFunc

Share this post


Link to post
Share on other sites
mesale0077

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

#include <IE.au3>


Opt("GUIOnEventMode", 1)
Opt("GUICloseOnESC",1)


Global $MainWindow  = GUICreate("Main Window", 833, 822, 335, 214)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEMain", $MainWindow)


$oIE = _IECreateEmbedded ()
 GUICtrlCreateObj($oIE, 10, 10, 500, 400)
 _IENavigate($oIE, @ScriptDir&"/images/index.html")

 ;_IEDocWriteHTML($oIE,fileread(@ScriptDir&"/images/index.html")); "<html><body><button id=""BTN"">Press This</button><br><br><button id=""BTk"">Press This</button></body></html>")
 _IELoadWait($oIE)

Local $oEventsDoc = ObjEvent($oIE.document, "Event_", "HTMLDocumentEvents2")
    #forceref $oEventsDoc

; _IEErrorHandlerRegister("MyErrFunc")


GUISetState(@SW_SHOW, $MainWindow) ; will display an empty dialog box

While 1
  Sleep(1000)  ; Idle around
WEnd

Exit

;-- Open new window when button in 'IE' pressed

volatile Func Event_onclick($oEvtObj)
    If IsObj($oEvtObj) Then

        Switch $oEvtObj.srcElement.id
            Case "1"
                
             Case "2" 
            exit    
               
EndSwitch
EndIf
EndFunc
Func CLOSEMain_onclick()


    Exit

    endfunc

$oEvtObj.srcElement.id

 ı want id =2  click or event , exit 

but id click dont work

sorry more before worked

now dont work why?

event disable ?

@ScriptDir&"/images/index.html"

id click ,dont work ,why?

Edited by mesale0077

Share this post


Link to post
Share on other sites
JLogan3o13

Again, worked before what? Before you switched from Win7 to Win8, before you rebooted, before you started drinking?! You can't say "it worked before" without giving any context.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
careca

The source you posted in the first link works here, here is win7 x64

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
mesale0077

'?do=embed' frameborder='0' data-embedContent>>

nice code

and

when ,del registy key

[HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMainFeatureControlFEATURE_BROWSER_EMULATION]

code worked

Edited by mesale0077

Share this post


Link to post
Share on other sites
Ascend4nt

mesale0077, I responded to your (now deleted) post on my IE Embedded Control Versioning thread in Example Scripts. See >this post.  Basically, you don't need to delete the registry key (and actually, by doing so you may have deleted any other executable values there). 

You can just use my UDF to set it to IE 10 or lower, or learn how to use the changes in the HTMLDocumentEvents2 interface which has changed since IE 11. (click, dblclick, and contextmenu now give different objects to event functions)

Edit: Actually, ignore the IE11 changes - I just modified your index.html file so that either the <span> or the <img> elements have the id="#" attribute attached to them, rather than the <a> anchor elements, and it now works perfectly fine. For example::

<span id="1">Upload</span>
..
<img src="google-chrome-trans.png" alt="EXÝT" title="EXÝT" id="4" />

_

This gives successful results for me.  I'm not sure why the <a> anchor doesn't trigger, nor does it trigger if the id attribute is applied to the <li> element.  Perhaps its because of the CSS resizing that it doesn't acknowledge anchor clicks.  I also tried using HTMLAnchorEvents2 interface but that too was registering as 0 for the id. (0 indicates no item id was under the mouse)

Edited by Ascend4nt

Share this post


Link to post
Share on other sites
mesale0077

mesale0077, I responded to your (now deleted) post on my IE Embedded Control Versioning thread in Example Scripts. See >this post.  Basically, you don't need to delete the registry key (and actually, by doing so you may have deleted any other executable values there). 

You can just use my UDF to set it to IE 10 or lower, or learn how to use the changes in the HTMLDocumentEvents2 interface which has changed since IE 11. (click, dblclick, and contextmenu now give different objects to event functions)

 

Edit: Actually, ignore the IE11 changes - I just modified your index.html file so that either the <span> or the <img> elements have the id="#" attribute attached to them, rather than the <a> anchor elements, and it now works perfectly fine. For example::

<span id="1">Upload</span>
..
<img src="google-chrome-trans.png" alt="EXÝT" title="EXÝT" id="4" />
_

This gives successful results for me.  I'm not sure why the <a> anchor doesn't trigger, nor does it trigger if the id attribute is applied to the <li> element.  Perhaps its because of the CSS resizing that it doesn't acknowledge anchor clicks.  I also tried using HTMLAnchorEvents2 interface but that too was registering as 0 for the id. (0 indicates no item id was under the mouse)

 

 

 

more example can you make

this code  convert IE Embedded Control

My ie version : ie 10

Switch $oEvtObj.srcElement.id alternative ?

type ,name ..... dont work

href="#" id =1 alternative ?

href="#" name ="1"dont work

volatile Func Event_onclick($oEvtObj)
    If IsObj($oEvtObj) Then

        Switch $oEvtObj.srcElement.id
            Case "1"
                
             Case "2" 
            exit    
               
EndSwitch
EndIf
EndFunc

html source

<span id="1">Upload</span> dont work

..

<img src="google-chrome-trans.png" alt="EXÝT" title="EXÝT" id="4" />  worked

href="#" id=3  dont worked

<div class="expand-up"><ul><li>
    <a href="#" id=1 title="Upload" rel="nofollow" >
      <span>Upload</span>
      <img src="opera-trans.png" alt="Upload" title="Upload"id="1" />    </a>  </li>
  <li>
    <a href="#" id=2 title="Download" rel="nofollow">
      <span>Download</span>
      <img src="safari-trans.png" alt="Download" title="Download" id="2" />    </a>  </li>
  <li>
    <a href="#" id=3 title="About" rel="nofollow" >
      <span>About </span>
      <img src="firefox-trans.png" alt="About" title="About"  />    </a>  </li>
  <li>
    <a href="#" id=4 title="EXİT" rel="nofollow" >
      <span id=4">EXİT</span>
      <img src="google-chrome-trans.png" alt="EXİT" title="EXİT" />    </a>  </li>

</ul>
</div>
Edited by mesale0077

Share this post


Link to post
Share on other sites
Ascend4nt

 

html source

<span id="1">Upload</span> dont work

..

<img src="google-chrome-trans.png" alt="EXÝT" title="EXÝT" id="4" />  worked

href="#" id=3  dont worked

<div class="expand-up"><ul><li>
    <a href="#" id=1 title="Upload" rel="nofollow" >
      <span>Upload</span>
      <img src="opera-trans.png" alt="Upload" title="Upload"id="1" />    </a>  </li>
  <li>
    <a href="#" id=2 title="Download" rel="nofollow">
      <span>Download</span>
      <img src="safari-trans.png" alt="Download" title="Download" id="2" />    </a>  </li>
  <li>
    <a href="#" id=3 title="About" rel="nofollow" >
      <span>About </span>
      <img src="firefox-trans.png" alt="About" title="About"  />    </a>  </li>
  <li>
    <a href="#" id=4 title="EXİT" rel="nofollow" >
      <span id=4">EXİT</span>
      <img src="google-chrome-trans.png" alt="EXİT" title="EXİT" />    </a>  </li>

</ul>
</div>

 

I gave 2 examples of how to change the code so the clicks were registered. With <span> set to the attribute, the text within the span needs to be clicked. Otherwise, clicking the image wouldn't do anything.  So one option would be to set all the <img> elements to id=#.  However, that would leave out the <span> text. We could set them both programmatically, without touching the html source file:

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

#include <IE.au3>


Opt("GUIOnEventMode", 1)
Opt("GUICloseOnESC",1)


Global $MainWindow  = GUICreate("Main Window", 833, 822, 335, 214)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEMain", $MainWindow)


$oIE = _IECreateEmbedded ()
 GUICtrlCreateObj($oIE, 10, 10, 500, 400)
 _IENavigate($oIE, @ScriptDir&"/images/index.html")

 ;_IEDocWriteHTML($oIE,fileread(@ScriptDir&"/images/index.html")); "<html><body><button id=""BTN"">Press This</button><br><br><button id=""BTk"">Press This</button></body></html>")
 _IELoadWait($oIE)


; Loop through and set IMG and SPAN elements to have the id attribute of their parent Anchor element
 Local $oDOMElem
 ; Loop through the elements with attributes id=1 to id=4
 For $i = 1 to 4
    $oDOMElem = $oIE.document.getElementById($i)
    If IsObj($oDOMElem) Then
        $oDOMElem = $oDOMElem.firstChild
        If IsObj($oDOMElem) Then
            While 1
                ConsoleWrite("Child node of id '" & $i & "': type = " & $oDOMElem.nodeType & ", name = " & $oDOMElem.nodeName & @LF)
                ; Node type of 1 = element
                If $oDOMElem.nodeType = 1 Then
                    ; If child is <IMG> or <SPAN> element, set the id attribute in each
                    ; (note, in general, this is bad practice - usually only set one element to have an id attribute!)
                    Switch $oDOMElem.nodeName
                        Case "IMG", "SPAN"
                            $oDOMElem.setAttribute("id", $i)
                    EndSwitch
                EndIf
                $oDOMElem = $oDOMElem.nextSibling
                If $oDOMElem = Null Then ExitLoop
                ;If Not IsObj($oDOMElem) Then ExitLoop    ; alternate
            WEnd
        EndIf
    EndIf
Next


Local $oEventsDoc = ObjEvent($oIE.document, "Event_", "HTMLDocumentEvents2")
    #forceref $oEventsDoc

; _IEErrorHandlerRegister("MyErrFunc")


GUISetState(@SW_SHOW, $MainWindow) ; will display an empty dialog box

While 1
  Sleep(1000)  ; Idle around
WEnd

Exit

;-- Open new window when button in 'IE' pressed

volatile Func Event_onclick($oEvtObj)
    If IsObj($oEvtObj) Then
        Switch $oEvtObj.srcElement.id
            Case 0
                ConsoleWrite("Click not associated with any DOM element with an id attribute" & @LF)
            Case "1"
                ConsoleWrite("UPLOAD"&@LF)
            Case "2"
                ConsoleWrite("DOWNLOAD"&@LF)
            Case "3"
                ConsoleWrite("ABOUT"&@LF)
            Case "4"
                Exit
            Case Else
                ConsoleWrite("Click of element id '" & $oEvtObj.srcElement.id & "' received" & @LF)
        EndSwitch
    EndIf
EndFunc

Func CLOSEMain()
    Exit
endfunc

 

However, I'm wondering now if there's an event we aren't capturing properly, as replacing the 'href' attribute with an actual website will cause the page to change without actually registering a specific DOM element being clicked.  Perhaps we need to revisit HTMLAnchorEvents..

  • Like 1

Share this post


Link to post
Share on other sites
mesale0077

thanks

I gave 2 examples of how to change the code so the clicks were registered. With <span> set to the attribute, the text within the span needs to be clicked. Otherwise, clicking the image wouldn't do anything.  So one option would be to set all the <img> elements to id=#.  However, that would leave out the <span> text. We could set them both programmatically, without touching the html source file:

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

#include <IE.au3>


Opt("GUIOnEventMode", 1)
Opt("GUICloseOnESC",1)


Global $MainWindow  = GUICreate("Main Window", 833, 822, 335, 214)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEMain", $MainWindow)


$oIE = _IECreateEmbedded ()
 GUICtrlCreateObj($oIE, 10, 10, 500, 400)
 _IENavigate($oIE, @ScriptDir&"/images/index.html")

 ;_IEDocWriteHTML($oIE,fileread(@ScriptDir&"/images/index.html")); "<html><body><button id=""BTN"">Press This</button><br><br><button id=""BTk"">Press This</button></body></html>")
 _IELoadWait($oIE)


; Loop through and set IMG and SPAN elements to have the id attribute of their parent Anchor element
 Local $oDOMElem
 ; Loop through the elements with attributes id=1 to id=4
 For $i = 1 to 4
    $oDOMElem = $oIE.document.getElementById($i)
    If IsObj($oDOMElem) Then
        $oDOMElem = $oDOMElem.firstChild
        If IsObj($oDOMElem) Then
            While 1
                ConsoleWrite("Child node of id '" & $i & "': type = " & $oDOMElem.nodeType & ", name = " & $oDOMElem.nodeName & @LF)
                ; Node type of 1 = element
                If $oDOMElem.nodeType = 1 Then
                    ; If child is <IMG> or <SPAN> element, set the id attribute in each
                    ; (note, in general, this is bad practice - usually only set one element to have an id attribute!)
                    Switch $oDOMElem.nodeName
                        Case "IMG", "SPAN"
                            $oDOMElem.setAttribute("id", $i)
                    EndSwitch
                EndIf
                $oDOMElem = $oDOMElem.nextSibling
                If $oDOMElem = Null Then ExitLoop
                ;If Not IsObj($oDOMElem) Then ExitLoop    ; alternate
            WEnd
        EndIf
    EndIf
Next


Local $oEventsDoc = ObjEvent($oIE.document, "Event_", "HTMLDocumentEvents2")
    #forceref $oEventsDoc

; _IEErrorHandlerRegister("MyErrFunc")


GUISetState(@SW_SHOW, $MainWindow) ; will display an empty dialog box

While 1
  Sleep(1000)  ; Idle around
WEnd

Exit

;-- Open new window when button in 'IE' pressed

volatile Func Event_onclick($oEvtObj)
    If IsObj($oEvtObj) Then
        Switch $oEvtObj.srcElement.id
            Case 0
                ConsoleWrite("Click not associated with any DOM element with an id attribute" & @LF)
            Case "1"
                ConsoleWrite("UPLOAD"&@LF)
            Case "2"
                ConsoleWrite("DOWNLOAD"&@LF)
            Case "3"
                ConsoleWrite("ABOUT"&@LF)
            Case "4"
                Exit
            Case Else
                ConsoleWrite("Click of element id '" & $oEvtObj.srcElement.id & "' received" & @LF)
        EndSwitch
    EndIf
EndFunc

Func CLOSEMain()
    Exit
endfunc

However, I'm wondering now if there's an event we aren't capturing properly, as replacing the 'href' attribute with an actual website will cause the page to change without actually registering a specific DOM element being clicked.  Perhaps we need to revisit HTMLAnchorEvents..

nice example worked

first

ı added

#include <Process.au3>
RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', _ProcessGetName(@AutoItPID),"REG_DWORD",0x00002af9)

and

Case "4"
   RegDelete('HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', _ProcessGetName(@AutoItPID))

   Exit

but

this code

 autoit beta version worked (3.3.3.16)

stabil version dont work( 3.3.12.0)

Share this post


Link to post
Share on other sites
Ascend4nt

thanks

nice example worked

first

ı added

#include <Process.au3>
RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', _ProcessGetName(@AutoItPID),"REG_DWORD",0x00002af9)

and

Case "4"
   RegDelete('HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', _ProcessGetName(@AutoItPID))

   Exit

but

this code

 autoit beta version worked (3.3.3.16)

stabil version dont work( 3.3.12.0)

 

I don't understand why you are setting FEATURE_BROWSER_EMULATION to 11001 when you have IE 10?  And what doesn't work exactly? RegDelete()?

Oh, also I decided why not check the parentNode in the 'onclick' function.  It's a better solution, although you'll probably add extra code to prevent EVERY click from checking the parent (say, only looking it up for img and span elements):

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

#include <IE.au3>


Opt("GUIOnEventMode", 1)
Opt("GUICloseOnESC",1)


Global $MainWindow  = GUICreate("Main Window", 833, 822, 335, 214)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEMain", $MainWindow)


$oIE = _IECreateEmbedded ()
 GUICtrlCreateObj($oIE, 10, 10, 500, 400)
 _IENavigate($oIE, @ScriptDir&"/images/index.html")

 ;_IEDocWriteHTML($oIE,fileread(@ScriptDir&"/images/index.html")); "<html><body><button id=""BTN"">Press This</button><br><br><button id=""BTk"">Press This</button></body></html>")
 _IELoadWait($oIE)

#cs
Local $oDOMElem

; Optionally Loop through the elements with attributes id=1 to id=4, abort all navigation
For $i = 1 to 4
    $oDOMElem = $oIE.document.getElementById($i)
    ; Anchor element?
    If $oDOMElem.nodeType = 1 And $oDOMElem.nodeName = "A" Then
        ConsoleWrite("node of id '" & $i & "': type = " & $oDOMElem.nodeType & ", name = " & $oDOMElem.nodeName & @LF)
        $oDOMElem.setAttribute("onclick","return false;")
    EndIf
Next
#ce

Local $oDocEvents = ObjEvent($oIE.document, "Event_", "HTMLDocumentEvents2")
#forceref $oDocEvents
;Local $oAEvents = ObjEvent($oIE.document, "Event_", "HTMLAnchorEvents2")
;#forceref $oAEvents

; _IEErrorHandlerRegister("MyErrFunc")

GUISetState(@SW_SHOW, $MainWindow) ; will display an empty dialog box

While 1
  Sleep(1000)  ; Idle around
WEnd

Exit

;-- Open new window when button in 'IE' pressed

volatile Func Event_onclick($oEvtObj)
    If IsObj($oEvtObj) Then
        Local $oElem = $oEvtObj.srcElement
        If Not IsObj($oElem) Then Return

        Local $nId = $oElem.id

        ;ConsoleWrite("ID of srcElement = " & $nId & @LF)
        If $nId = 0 Then
            $oElem = $oElem.parentNode
            If Not IsObj($oElem) Or $oElem.id = 0 Or $oElem.nodeName <> 'A' Then
                ConsoleWrite("Click not associated with any DOM element, and parent is not <a>nchor or has no id attribute" & @LF)
                Return
            EndIf
            $nId = $oElem.id
        EndIf
        ; Now we have an ID

        Switch $nId
            Case 0
                ; prevent 0 = 'anystring' matching
            Case "1"
                ConsoleWrite("UPLOAD"&@LF)
            Case "2"
                ConsoleWrite("DOWNLOAD"&@LF)
            Case "3"
                ConsoleWrite("ABOUT"&@LF)
            Case "4"
                Exit
            Case Else
                ConsoleWrite("Click of element id '" & $oEvtObj.srcElement.id & "' received" & @LF)
        EndSwitch
        ; Optionally Prevent click from going through
        ;$oEvtObj.returnValue = False
    EndIf
EndFunc


Volatile Func Event_oncontextmenu($oEvtObj)
    If IsObj($oEvtObj) Then $oEvtObj.returnValue = False
EndFunc

Func CLOSEMain()
    Exit
EndFunc

*Edit: Now it looks specifically for <a> anchor parent elements.  Also added 'oncontextmenu' function as an example how you can disable right-clicking (the html file has a script function for this, but its not called.  Alternatively, modify this line in the html file:

<body oncontextmenu="return false;">
Edited by Ascend4nt
  • Like 1

Share this post


Link to post
Share on other sites
mesale0077

 

I don't understand why you are setting FEATURE_BROWSER_EMULATION to 11001 when you have IE 10?  And what doesn't work exactly? RegDelete()?

Oh, also I decided why not check the parentNode in the 'onclick' function.  It's a better solution, although you'll probably add extra code to prevent EVERY click from checking the parent (say, only looking it up for img and span elements):

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

#include <IE.au3>


Opt("GUIOnEventMode", 1)
Opt("GUICloseOnESC",1)


Global $MainWindow  = GUICreate("Main Window", 833, 822, 335, 214)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEMain", $MainWindow)


$oIE = _IECreateEmbedded ()
 GUICtrlCreateObj($oIE, 10, 10, 500, 400)
 _IENavigate($oIE, @ScriptDir&"/images/index.html")

 ;_IEDocWriteHTML($oIE,fileread(@ScriptDir&"/images/index.html")); "<html><body><button id=""BTN"">Press This</button><br><br><button id=""BTk"">Press This</button></body></html>")
 _IELoadWait($oIE)

#cs
Local $oDOMElem

; Optionally Loop through the elements with attributes id=1 to id=4, abort all navigation
For $i = 1 to 4
    $oDOMElem = $oIE.document.getElementById($i)
    ; Anchor element?
    If $oDOMElem.nodeType = 1 And $oDOMElem.nodeName = "A" Then
        ConsoleWrite("node of id '" & $i & "': type = " & $oDOMElem.nodeType & ", name = " & $oDOMElem.nodeName & @LF)
        $oDOMElem.setAttribute("onclick","return false;")
    EndIf
Next
#ce

Local $oDocEvents = ObjEvent($oIE.document, "Event_", "HTMLDocumentEvents2")
#forceref $oDocEvents
;Local $oAEvents = ObjEvent($oIE.document, "Event_", "HTMLAnchorEvents2")
;#forceref $oAEvents

; _IEErrorHandlerRegister("MyErrFunc")

GUISetState(@SW_SHOW, $MainWindow) ; will display an empty dialog box

While 1
  Sleep(1000)  ; Idle around
WEnd

Exit

;-- Open new window when button in 'IE' pressed

volatile Func Event_onclick($oEvtObj)
    If IsObj($oEvtObj) Then
        Local $oElem = $oEvtObj.srcElement
        If Not IsObj($oElem) Then Return

        Local $nId = $oElem.id

        ;ConsoleWrite("ID of srcElement = " & $nId & @LF)
        If $nId = 0 Then
            $oElem = $oElem.parentNode
            If Not IsObj($oElem) Or $oElem.id = 0 Then
                ConsoleWrite("Click not associated with any DOM element, and parent has no id attribute" & @LF)
                Return
            EndIf
            $nId = $oElem.id
        EndIf
        ; Now we have an ID

        Switch $nId
            Case 0
                ; prevent 0 = 'anystring' matching
            Case "1"
                ConsoleWrite("UPLOAD"&@LF)
            Case "2"
                ConsoleWrite("DOWNLOAD"&@LF)
            Case "3"
                ConsoleWrite("ABOUT"&@LF)
            Case "4"
                Exit
            Case Else
                ConsoleWrite("Click of element id '" & $oEvtObj.srcElement.id & "' received" & @LF)
        EndSwitch
    EndIf
EndFunc


Func CLOSEMain()
    Exit
EndFunc

 

 

your this code

thank you

stabil and beta autoit version worked

Share this post


Link to post
Share on other sites
jchd

Can you please guys stop quoting previous posts without good reason.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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  

×