Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/16/2014 in all areas

  1. Open your SciTEUser.properties file, and add this line. The default for SciTE is style 1, which is word wrapping, style 2 is character wrapping, meaning it only brings down the characters that go past the visible screen.
    2 points
  2. Ascend4nt

    ObjEvent dont work

    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;">
    1 point
  3. Ascend4nt

    ObjEvent dont work

    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..
    1 point
  4. water

    Instant mouse moves

    First you have to remove the [] from your code. They denote optional parameters.
    1 point
  5. JLogan3o13

    Simple question

    You have two posts now, one in which you come right out and state it is for a game, and the other that looks a lot like game automation though you never state it. Please read the forum rules, especially the part about game automation before posting again. P.S. Too bad there is nothing in the rules about how pathetic it is to have to use scripts to cheat at games
    1 point
  6. The And relation in If statements is not & but And. Local $sTime = @HOUR & ":" & @MIN & ":" & @SEC While 1 If @HOUR = 14 And @MIN = 35 And @SEC = 00 Then MsgBox(0, "", @HOUR & "h " & @MIN & "m " & @SEC & "s", 10) Sleep(1500) ElseIf @HOUR = 14 And @MIN = 37 And @SEC = 00 Then MsgBox(0, "", @HOUR & "h " & @MIN & "m " & @SEC & "s", 10) Sleep(1500) ElseIf @HOUR = 14 And @MIN = 39 And @SEC = 00 Then MsgBox(0, "", @HOUR & "h " & @MIN & "m " & @SEC & "s", 10) Sleep(1500) EndIf Sleep(500) WEnd Jos
    1 point
×
×
  • Create New...