Search the Community
Showing results for tags 'Events'.
-
Greetings! I was exploring as I saw the below URL which reads the event logs from specific type (Application, Security, System, etc.) So, I was in need to read a specific event id instead of the type of event, i.e. I need to read event id 1074 which lands under Security type. Any assistance will be grateful. Happy new year in advance!!
- 5 replies
-
- eventlog
- event viewer
-
(and 3 more)
Tagged with:
-
👋 Hey I want to call a function when something changes on an element in my GUI. That should work for a combo box (with $CBS_DROPDOWNLIST) when I select an item and for a text input when I type.
-
Version 2.x.x and 3.x.x has been moved to branch 3.x About Autoit-Socket-IO Autoit-Socket-IO is a event driven TCP/IP wrapper heavily inspired from Socket.IO with focus on user friendliness and long term sustainability. I constantly want to make this UDF faster and better, so if you have any suggestions or questions (beginner and advanced) Do not hesitate to ask them, I will gladly help! Key features Simple API 99% data-type serialization thanks to Autoit-Serialize Can easily be extended with your own functionality thanks to Autoit-Events "Educational" examples Data encryption thanks to _<Crypt.au3> Limitations Speed. This UDF will sacrifice some speed for convenience Getting started Download the script from AutoIt or pull it from the official github repo git@github.com:tarreislam/Autoit-Socket-IO.git and checkout the tag 4.0.0-beta Check out the documentaion Take a look in the examples/ folder Changelog To see changes from 3.x.x and 2.x.x please checkout the 3.x branch Version 4.0.0-beta (This update break scripts.) Code base fully rewritten with Autoit-Events and decoupled to improve code quality and reduce bloat. The new UDF is very different from 3.x.x so please checkout the UPGRADE guide to fully understand all changes Added new documentation documentaion Success stories Since December 2017-now I have used version 1.5.0 in an production environment for 150+ clients with great success, the only downtime is planned windows updates and power outages. Newest version (2020-09-15!) Older versions (Not supported anymore) Autoit-Socket-IO-1.0.0.zip Autoit-Socket-IO-1.1.0.zip Autoit-Socket-IO-1.3.0.zip Autoit-Socket-IO-1.4.0.zip Autoit-Socket-IO-1.5.0.zip Autoit-Socket-IO-2.0.0.zip
-
About AutoIt-Events AutoIt-Events is an event Observer and is a core dependency for Autoit-Socket-IO but can be used for any Autoit project. Example #include "Event.au3" ; Subscribe listeners _Event_Listen(UserCreatedEvent, SendWelcomeMail) _Event_Listen(UserCreatedEvent, RegisterNewsLetter) ; Fire event _Event(UserCreatedEvent, @UserName, "tarre.islam@gmail.com") Func UserCreatedEvent(Const ByRef $oEvent, $name, $email) ; via $oEvent you can pass data to its listeners $oEvent.add("name", $name) $oEvent.add("email", $email) $oEvent.add("id", 1) EndFunc Func SendWelcomeMail(Const $oEvent) MsgBox(64, "Welcome mail sent", "Welcome mail sent to " & $oEvent.item("name") & " with email " & $oEvent.item("email")) EndFunc Func RegisterNewsLetter(Const $oEvent) MsgBox(64, "News letter registred", "News letter bound to user id " & $oEvent.item("id")) EndFunc The code is also available at Github Autoit-Events-1.0.0.zip
- 3 replies
-
- observer
- observerpattern
-
(and 2 more)
Tagged with:
-
This is a little experiment that makes use of a "Browser Control" embedded in a GUI in order to be able to use AutoIt, HTML, JavaScript and CSS all together. This little toy will only work on systems with IE11. The purpose is to drag all the names of the scientists & drop on the right ones. (among scientists it has also infiltrated an intruder). I hope you find it entertaining. I've posted it here in the hope to have some suggestions on how to improve it all (I mean the interaction between Autoit Javascript html and css). Thanks ; this works on systems with IE11 ; ------------------------------- #include <GUIConstantsEx.au3> #include <array.au3> Global $oIE, $oDocument, $ohJS, $sDroping Global $iCorrect = 0, $iGoal = 11 Example() Exit Func Example() Local $aScientists[12][2] = _ [["Schrodinger", "Schrodinger"],["Planck", "Planck"],["Pauli", "Pauli"],["Einstein", "Einstein"], _ ["Chimp", "Chimp"],["Dirac", "Dirac"],["Heisenberg", "Heisenberg"],["Born", "Born"], _ ["De Broglie", "De_Broglie"],["Bohr", "Bohr"],["Sommerfeld", "Sommerfeld"],["", "empty"]] Local $oIE = ObjCreate("Shell.Explorer.2") ; Create a BrowserControl Local $hGUI = GUICreate("", 660, 600, 30, 30) GUICtrlCreateObj($oIE, 0, 0, 660, 600) ; Place BrowserControl on the GUI GUISetState() ;Show GUI $oIE.navigate('about:blank') ; file:///' & @ScriptDir & '\WhoIsWho.html') While Not String($oIE.readyState) = 'complete' ; wait for about:blank Sleep(100) WEnd ; this waits till the document is ready to be used (portion of code from IE.au3) While Not (String($oIE.readyState) = "complete" Or $oIE.readyState = 4) Sleep(100) WEnd While Not (String($oIE.document.readyState) = "complete" Or $oIE.document.readyState = 4) Sleep(100) WEnd $oIE.document.Write(_GetHTML()) ; inject lising directly to the HTML document: $oIE.document.close() ; close the write stream $oIE.document.execCommand("Refresh") While Not String($oIE.readyState) = 'complete' ; wait for readyState after a refresh Sleep(100) WEnd ; https://msdn.microsoft.com/en-us/library/52f50e9t(v=vs.94).aspx ; $ohJS is a reference to the javascript Global Obj ; ------------------------------------------------- $ohJS = $oIE.document.parentwindow.JSglobal $oDocument = $oIE.document Local $oTable1 = $ohJS.table1 Local $oTable2 = $ohJS.table2 _Randomize($aScientists, $oTable1) ; --- Setup events ------------ ; https://msdn.microsoft.com/en-us/library/hh801967(v=vs.85).aspx Local $aoEventObject[2] $aoEventObject[0] = ObjEvent($oTable1, "IEEvent_", "HTMLTableEvents2") $aoEventObject[1] = ObjEvent($oTable2, "IEEvent_", "HTMLTableEvents2") ; ----------------------------- ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch If $iCorrect = $iGoal Then _Goal() _Randomize($aScientists, $oTable1) $iCorrect = 0 EndIf WEnd ; the end For $i = 0 To UBound($aoEventObject) - 1 $aoEventObject[$i] .stop Next $aoEventObject = 0 ; Kill the Event Object $oIE = 0 ; Remove IE from memory (not really necessary). GUIDelete($hGUI) ; Remove GUI EndFunc ;==>Example ; --- event management zone --- ; following functions are fired by events occurred in the browser control Volatile Func IEEvent_onDragstart($oEvent) ; we save the ID of the dragged obj into the $sDroping variable ; for a later use in the drop function $sDroping = $oEvent.srcElement.ID EndFunc ;==>IEEvent_onDragstart Volatile Func IEEvent_onDragOver($oEvent) $ohJS.event.preventDefault() EndFunc ;==>IEEvent_onDragOver Volatile Func IEEvent_onDrop($oEvent) $ohJS.event.preventDefault() If $sDroping <> "" Then If $oDocument.getElementById($sDroping).innerText <> $oEvent.srcElement.innerText Then If $oEvent.srcElement.ClassName = $oDocument.getElementById($sDroping).ClassName Then $oEvent.srcElement.innerText = $oDocument.getElementById($sDroping).innerText $oDocument.getElementById($sDroping).innerText = "" $oDocument.getElementById($sDroping).draggable = False $oDocument.getElementById($sDroping).setAttribute("style") = "background-color: #80ff80;" $iCorrect += 1 Else For $i = 1 To 3 $oDocument.getElementById($sDroping).setAttribute("style") = "background-color: #ff0000;" Sleep(125) $oDocument.getElementById($sDroping).setAttribute("style") = "background-color: #ffffff;" Sleep(125) Next EndIf EndIf $sDroping = "" EndIf EndFunc ;==>IEEvent_onDrop Func _Randomize(ByRef $aScientists, ByRef $oTable) Local $iRows = ($oTable.rows.length) - 1 Local $iCols = ($oTable.rows.item(0).cells.length) - 1 Local $index _ArrayShuffle($aScientists) For $y = 0 To $iRows For $x = 0 To $iCols $index = ($y * ($iCols + 1)) + $x $oTable.rows.item($y).cells.item($x).innerText = $aScientists[$index][0] ; text $oTable.rows.item($y).cells.item($x).className = $aScientists[$index][1] ; class $oTable.rows.item($y).cells.item($x).draggable = $aScientists[$index][0] <> "" Next Next EndFunc ;==>_Randomize Func _Goal() Local $oTable1 = $ohJS.table1 ; names Local $oTable2 = $ohJS.table2 ; photos Local $iRows = ($oTable1.rows.length) Sleep(250) Local $iCols = 6 ; ($oTable1.rows.item(0).cells.length) Local $aIndex[$iRows * $iCols], $sTemp For $i = 0 To UBound($aIndex) - 1 $aIndex[$i] = $i ; + 1 Next _ArrayShuffle($aIndex) For $i = 0 To UBound($aIndex) - 1 $oTable2.rows.item(Int($aIndex[$i] / $iCols)).cells.item(Mod($aIndex[$i], $iCols)).innerText = "" $oTemp0 = $oTable2.rows $oTemp1 = $oTemp0.item(Int($aIndex[$i] / $iCols)).cells $oTemp2 = $oTemp1.item(Mod($aIndex[$i], $iCols)).getAttribute("style") $oTable2.rows.item(Int($aIndex[$i] / $iCols)).cells.item(Mod($aIndex[$i], $iCols)).setAttribute("style") = "background-color: " & _rndColor() Sleep(100); MsgBox(0,"Debug",$sTemp) $oTable2.rows.item(Int($aIndex[$i] / $iCols)).cells.item(Mod($aIndex[$i], $iCols)).setAttribute("style") = $oTemp2 Next For $x = 1 To 2 For $i = 0 To UBound($aIndex) - 1 $oTable1.rows.item(Int($aIndex[$i] / $iCols)).cells.item(Mod($aIndex[$i], $iCols)).setAttribute("style") = "background-color: " & _rndColor() Sleep(100) $oTable1.rows.item(Int($aIndex[$i] / $iCols)).cells.item(Mod($aIndex[$i], $iCols)).setAttribute("style") = "background-color: #ffffff;" Next Next EndFunc ;==>_Goal Func _rndColor() Return String("#" & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2) & ";") EndFunc ;==>_rndColor Func _GetHTML() Local $sHTML = _ "<!DOCTYPE HTML>" & @CRLF & _ "<html>" & @CRLF & _ "<head>" & @CRLF & _ "<meta http-equiv=""X-UA-Compatible"" content=""IE=edge"" />" & @CRLF & _ " <script type=""text/javascript"">" & @CRLF & _ " var JSglobal = (1,eval)(""this"");" & @CRLF & _ " </script>" & @CRLF & _ "</head>" & @CRLF & _ "<body>" & @CRLF & _ "<h2>Who is who?</h2>" & @CRLF & _ "<p>Drag&Drop names on the right scientist</p>" & @CRLF & _ "<img src=""https://i.imgur.com/STWql7w.jpg""" & @CRLF & _ "height=""394"" width=""640""" & @CRLF & _ "style=""position: absolute; left: 10px; top: 100px;"">" & @CRLF & _ "" & @CRLF & _ "<style>" & @CRLF & _ ".target td {width: 100px; height: 160px; text-align: center; color: white; font-weight: bold; vertical-align: bottom; border: 0px solid grey;}" & @CRLF & _ ".source td {width: 100px; height: 30px; text-align: center; border: 1px solid red;}" & @CRLF & _ "</style>" & @CRLF & _ "" & @CRLF & _ "<table class=""target"" style=""position: absolute; left: 25px; top: 100px;"" id=""table2"">" & @CRLF & _ " <tr><td class=""Schrodinger""></td><td class=""Planck""></td><td class=""Pauli""></td><td class=""Einstein""></td><td class=""Chimp""></td><td class=""Dirac""></td></tr>" & @CRLF & _ " <tr><td class=""Heisenberg""></td><td class=""Born""></td><td class=""De_Broglie""></td><td class=""Bohr""></td><td class=""Sommerfeld""></td><td class=""empty""></td></tr>" & @CRLF & _ "</table>" & @CRLF & _ "" & @CRLF & _ "<table class=""source"" style=""position: absolute; left: 10px; top: 504px;"" id=""table1"">" & @CRLF & _ " <tr><td ID=""td1""></td><td ID=""td2""></td><td ID=""td3""></td><td ID=""td4"" ></td><td ID=""td5"" ></td><td ID=""td6"" ></td></tr>" & @CRLF & _ " <tr><td ID=""td7""></td><td ID=""td8""></td><td ID=""td9""></td><td ID=""td10""></td><td ID=""td11""></td><td ID=""td12""></td></tr>" & @CRLF & _ "</table>" & @CRLF & _ "</body>" & @CRLF & _ "</html>" Return $sHTML EndFunc ;==>_GetHTML
- 3 replies
-
- browser control
- javascript
-
(and 1 more)
Tagged with:
-
Hello and happy new Year to everybody! I'm trying to catch some events occuring within a browser control by simply using the ObjEvent() function. I think I'm not using that function in a proper way since some events are captured, while other are not. more precisely, events like those listed in this page are working: https://msdn.microsoft.com/en-us/library/aa769764(v=vs.85).aspx while other events listed in other "interfaces", as in the following links, does not works. https://msdn.microsoft.com/en-us/library/hh801967(v=vs.85).aspx For exemple, Here I would like to catch events like "DragOver" and/or "Drop" fired while dragging the image on the web control, but I'm not been able to obtain a result. Those events are listed in the HTMLDocumentEvents4 interface or also in the HTMLImgEvents interface, but I failed to use them. Any hint that can help to see what I'm doing wrong, or even better that can show how to achieve the result by using the ObjEvent() function (if it's possible?) is welcome. Thanks a lot. Here is the simple script that I'm using for my tests: #include <GUIConstantsEx.au3> #include <string.au3> ; read html page from bottom of this script ; and write it to a file on disk for later ; usage by the $oIE.navigate CreateHtmlPage() Example() Exit Func Example() Local $hGUIMain = GUICreate("Event Test", 540, 400) ; We generate the Browser Control... Global $oIE = ObjCreate("Shell.Explorer.2") ; and we embed it into the AutoIt GUI $hIE = GUICtrlCreateObj($oIE, 5, 5, 530, 390) GUISetState() ;Show GUI ; load in the browser our previously created web page $oIE.navigate('file:///' & @ScriptDir & '\Page.html') Do ; wait for document Sleep(250) $oDocument = $oIE.document Until IsObj($oDocument) $oDocument.execCommand("Refresh") ; --- Setup catch of events --- Local $oEventObjects[2] $oImage = $oDocument.getElementById('drag1') ; Object reference to The image on the page ; https://msdn.microsoft.com/en-us/library/aa769764(v=vs.85).aspx ; HTMLDocumentEvents2 interface (catch OnClick, OnMouseOver, .... etc ; ObjEvent() "Handles incoming events from the given Object." ; ObjEvent($oParam1, $sParam2 [,$sParam3]) ; Parameters ; $oParam1 A variable containing an Object from which you want to receive events ; ; $sParam2 The prefix of the functions you define to handle receiving events. ; The prefix is appended by the Objects method name. ; ; $sParam3 "interface name" [optional] name of an Event interface to use. ; Note: It must be a supported as outgoing for the Object AND it must be of type DISPATCH. ; Using third parameter as "HTMLDocumentEvents2" as event interface, or even leaving it blank, ; is the only way by which I've been able to catch some events from the browser control ; OK, events listed here are catched --> https://msdn.microsoft.com/en-us/library/aa769764(v=vs.85).aspx $oEventObjects[0] = ObjEvent($oDocument, "IEEvent2_") ;, "HTMLDocumentEvents2") ; when I try to catch events fired by the Image dragged on the web page ; following attempts do not work (no event is captured and passed to AutoIt) ; $oEventObjects[1] = ObjEvent($oDocument, "IEEvent2_", "HTMLDocumentEvents2") ; $oEventObjects[1] = ObjEvent($oDocument, "IEEvent2_", "HTMLDocumentEvents4") ; $oEventObjects[1] = ObjEvent($oImage, "IEEvent2_", "HTMLDocumentEvents2") ; $oEventObjects[1] = ObjEvent($oImage, "IEEvent2_") $oEventObjects[1] = ObjEvent($oImage, "IEEvent2_", "HTMLImgEvents2") ; ----------------------------- ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; the end For $i = 0 To UBound($oEventObjects) - 1 $oEventObjects[$i].Stop ; Tell IE we don't want to receive events. $oEventObjects[$i] = 0 Next $oEventObject = 0 ; Kill the Event Object $oIE = 0 ; Remove IE from memory (not really necessary). GUIDelete($hGUIMain) ; Remove GUI EndFunc ;==>Example ; below function should be fired by events ; occurred in the browser's objects ; --- events management zone --- Volatile Func IEEvent2_onClick($oEvent) ConsolePrint("mouse click:") EndFunc ;==>IEEvent2_onClick Volatile Func IEEvent2_onDblClick($oEvent) ConsolePrint("mouse DoubleClick:") EndFunc ;==>IEEvent2_onDblClick ; Drag related events Volatile Func IEEvent2_onDragstart($oEvent) ConsolePrint("Drag action started") EndFunc ;==>IEEvent2_onDragstart ; --- following events are not catched --- ??? Volatile Func IEEvent2_onDragOver($oEvent) ConsolePrint("DragOver event") EndFunc ;==>IEEvent2_onDragOver Volatile Func IEEvent2_onDrop($oEvent) ConsolePrint("Drop action performed ") EndFunc ;==>IEEvent2_onDrop ; ------------------------------ Func ConsolePrint($sMsg) ConsoleWrite($sMsg & @CRLF) EndFunc ;==>ConsolePrint Func CreateHtmlPage() Local $sStart = @LF & "#cs;HTML" Local $sEnd = "#ce;HTML" & @CR Local $aArray = _StringBetween(FileRead(@ScriptFullPath), $sStart, $sEnd) Local $sPage = @ScriptDir & '\Page.html' Local $hFile = FileOpen($sPage, 2) ; $FO_OVERWRITE (2) = Write mode (erase previous contents) FileWrite($hFile, $aArray[0]) FileFlush($hFile) FileClose($hFile) EndFunc ;==>CreateHtmlPage ; example got from here: http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_draganddrop2 #cs;HTML <!DOCTYPE HTML> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <style> #div1, #div2 { float: left; width: 214px; height: 214px; margin: 5px; padding: 10px; border: 1px solid black; } </style> <script> function allowDrop(ev) {ev.preventDefault();} function drag(ev) {ev.dataTransfer.setData("text", ev.target.id);} function drop(ev) { ev.preventDefault(); var data = ev.dataTransfer.getData("text"); ev.target.appendChild(document.getElementById(data));} </script> </head> <body> <h2>Drag and Drop</h2> <p>Drag the image back and forth between the two div elements.</p> <div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)"> <img src="https://www.autoitscript.com/forum/uploads/monthly_2016_01/Chimp.jpg.688f81fa865450e2913b5dc2cb56215f.thumb.jpg.96a6bfa47c0fb8476f39aaf55ad68ed0.jpg" draggable="true" ondragstart="drag(event)" id="drag1" width="214" height="214"> </div> <div id="div2" ondrop="drop(event)" ondragover="allowDrop(event)"></div> </body> </html> #ce;HTML ;
-
Hi to all, in this script I'm using a Javascript library called VIS to display data on a timeline. All is performed within a browser control embedded in the AutoIt GUI, and the AutoIt script should interact with what is going on in the browser control. what I'm stuck on is on finding a way to get notified in the AutoIt script on some events fired from that javascript library. When I use the ObjEvent() to get notified about events fired by html elements from the html page, all works ok... I'm stuck instead on how to receive notifications from events fired by a javascript (custom?) object. The DataSet object. in very short: To add, edit or remove Items on the Timeline, first a DataSet is created and bound to the Timeline, then all variations performed on the DataSet will be automatically visualized in the form of Items located on the Timeline. All variations on the DataSet will also fire events. (use the button to create new items from autoit, or doubbleclick on the timeline to also create new items by the javascript library) now my problem is: since the DataSet is setted to fire events anytime some data in the DatSet is added and/or changed and/or deleted, i would like to be notified about such events in my AutoIt program, but I've not achieved the goal so far. In this example the events generated by the DataSet are notified within the HTML page and displayed within the browser control, but not forwarded to AutoIt. Any help to achieve this goal is higly appreciated. Thanks #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <string.au3> #include <array.au3> Global $g_idGUIEdit ; read html page from bottom of this script ; and write it to a file on disk CreateHtmlPage() Example() Exit Func Example() Local $hGUIMain = GUICreate("Event Test", 1000, 600) $g_idGUIEdit = GUICtrlCreateEdit("", 500, 405, 490, 175) GUICtrlSetFont(-1, 9, 400, -1, 'Courier New') GUICtrlCreateLabel("Below are some Browser events 'captured' from the above web page by AutoIt", 500, 385, 990, 20) Local $idGUIExit = GUICtrlCreateButton(" Close and exit", 5, 580, 990, 15) Local $hButton1 = GUICtrlCreateButton("Add an Item to timeline", 10, 400, 150, 40) GUISetState() ;Show GUI ; We prepare the Internet Explorer as our test subject Global $oIE = ObjCreate("Shell.Explorer.2") $hIE = GUICtrlCreateObj($oIE, 5, 5, 990, 380) ; <- embedd $oIE in the AutoIt GUI ; load our web page, javascript and css in the browser ToolTip("...downloading javascript, please wait") $oIE.navigate('file:///' & @ScriptDir & '\Page.html') Sleep(1000) ; Give it some time to load the web page ToolTip("") Do ; wait for document Sleep(250) $oDocument = $oIE.document Until IsObj($oDocument) ; https://msdn.microsoft.com/en-us/library/52f50e9t(v=vs.94).aspx ; $ohJS is a reference to the javascript Global Obj ; ------------------------------------------------- Global $ohJS = $oIE.document.parentwindow.JSglobal ; --- Setup catch of events --- ; https://msdn.microsoft.com/en-us/library/aa769764(v=vs.85).aspx ; HTMLDocumentEvents2 interface (catch OnClick, OnMouseOver, .... etc Global $oEventObject = ObjEvent($oDocument, "IEEvent2_", "HTMLDocumentEvents2") ; OK, this events are catched ; Attempt to catch events fired by the DataSet. ; items is the DataSet obj created in the Browser ; Global $oEventObject = ObjEvent($ohJS.items, "OnDataSet_") ; ???? how to catch events from the DataSet <---- ????? ; ----------------------------- ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idGUIExit ExitLoop Case $hButton1 ; add a job to the timeline (a simple example just to test) ; to generate a unique ID I use the following: @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & @MSEC Local $result = $ohJS.eval("items.add([{id: " & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & @MSEC & ", content: '<b>item 4</b> Added at " & @HOUR & ":" & @MIN & ":" & @SEC & " ', start: '2014-01-19'}]);") ConsoleWrite("DataSet now contains " & $ohJS.items.length & " Items" & @CRLF) EndSwitch WEnd ; the end $oEventObject.Stop ; Tell IE we don't want to receive events. $oEventObject = 0 ; Kill the Event Object $oIE = 0 ; Remove IE from memory (not really necessary). GUIDelete($hGUIMain) ; Remove GUI EndFunc ;==>Example ; --- event management zone --- ; A few Internet Explorer Event Functions ; below function are fired by events occurred in the browser Volatile Func IEEvent2_onClick($oEvent) ConsolePrint("mouse click: " & $oEvent.clientX & ',' & $oEvent.clientY & ' on ' & $oEvent.srcElement.NodeName & ' - ' & $oEvent.srcElement.ID) EndFunc ;==>IEEvent2_onClick Volatile Func IEEvent2_onDblClick($oEvent) ConsolePrint("mouse DoubleClick: @" & $oEvent.clientX & ',' & $oEvent.clientY) EndFunc ;==>IEEvent2_onDblClick Volatile Func OnDataSet_add($oEvent) ConsolePrint("!!!! event from DataSet " & IsObj($oEvent)) ; type EndFunc ;==>OnDataSet_add Func ConsolePrint($sMsg) Local Const $iMaxLines = 9 ; keep last 12 lines only $sMsg = @HOUR & ':' & @MIN & ':' & @SEC & ':' & @MSEC & @TAB & $sMsg & @CRLF $sMsg = StringReplace(GUICtrlRead($g_idGUIEdit) & $sMsg, @CR, @CR) If @extended > $iMaxLines Then ; more than $iMaxLines $sMsg = StringMid($sMsg, StringInStr($sMsg, @CR, 0, -1 * $iMaxLines) + 2) EndIf GUICtrlSetData($g_idGUIEdit, $sMsg) EndFunc ;==>ConsolePrint Func CreateHtmlPage() Local $sStart = @LF & "#cs;HTML" Local $sEnd = "#ce;HTML" & @CR Local $aArray = _StringBetween(FileRead(@ScriptFullPath), $sStart, $sEnd) Local $sPage = @ScriptDir & '\Page.html' Local $hFile = FileOpen($sPage, 2) ; $FO_OVERWRITE (2) = Write mode (erase previous contents) FileWrite($hFile, $aArray[0]) FileFlush($hFile) FileClose($hFile) EndFunc ;==>CreateHtmlPage #cs;HTML <!DOCTYPE HTML> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <script type="text/javascript"> var JSglobal = (1,eval)("this"); </script> <style type="text/css"> body, html { font-family: arial, sans-serif; font-size: 11pt; } </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.16.1/vis.min.js"></script> <link href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.16.1/vis.min.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="visualization" style="border-width:3px; border-color:yellow; border-style:double;"></div> <p></p> <div id="log"></div> <script type="text/javascript"> // DOM element where the Timeline will be attached var container = document.getElementById('visualization'); // Create an empty DataSet (allows two way data-binding) var items = new vis.DataSet({type: { start: 'ISODate', end: 'ISODate', notes: '' }}); // items.addEventListener('click',resetElements,true); // add items to the DataSet items.add([ {id: 1, content: 'item 1 <b>start</b>', start: '2014-01-23'}, {id: 2, content: 'item 2', start: '2014-01-18 00:00', end: '2014-01-18 23:59'}, {id: 3, content: 'item 3', start: '2014-01-21'}, {id: 5, content: 'item 5', start: '2014-01-28', type:'point'}, {id: 6, content: 'item 6', start: '2014-01-26'} ]); // Configuration for the Timeline var options = {orientation: 'top', editable: { add: true, remove: true, updateTime: true, updateGroup: true } }; // Create a Timeline var timeline = new vis.Timeline(container, items, options); // turn events on timeline.on('rangechange', function (properties) { logEvent('rangechange', properties); }); timeline.on('rangechanged', function (properties) { logEvent('rangechanged', properties); }); timeline.on('select', function (properties) { logEvent('select', properties); }); items.on('*', function (event, properties) { logEvent(event, properties); }); function logEvent(event, properties) { var log = document.getElementById('log'); var msg = document.createElement('div'); msg.innerHTML = 'event=' + JSON.stringify(event) + ', ' + 'properties=' + JSON.stringify(properties); log.firstChild ? log.insertBefore(msg, log.firstChild) : log.appendChild(msg); } </script> </body> </html> #ce;HTML ;
-
I want to listen for certain windows events like window open/closed. After reading the help I think I need to use ObjCreate('shell.application') and ObjEvent with that object to create/register a listener. The problem is I don't know what interface or events (i.e. the specific event names) are available for the listener. I tried searching MSDN but it is a labyrinth and I'm not that familiar with the programming frameworks/models used by Windows, and all the examples seem to refer to compiled code using .NET or some other api. Can any1 point me in the right direction? Also is using COM objects considered the 'modern' way to do this, or should I be using some other framework/resources?
-
Hi all, This code is from an IronPython project. self._button1.Click += self.Button1_Click self._button1.MouseHover += self.Button1_MouseHover def Button1_Click(self, sender, e): System.Windows.Forms.MessageBox.Show("Hi you clicked me ?") pass def Button1_MouseHover(self, sender, e): sender.Text = "Mouse Entered" pass How easy to connect any event function to any control. I know AutoIt can do this with GUICtrlSetOnEvent function. But this function only takes control ID and function name as parameters. We can't tell AutoIt to act on which event. And for some events, we needs to use GUIRegisterMsg in order to respond some specific messages. My question is --- Is it possible to do this IronPython way in AutoIt ?
-
Hi, so basically I'm filling in a form using the _IEFormElementSetValue command, which can trigger OnChange and OnClick event if the parameters are set right. But for my form to update i need to somehow trigger the keyup or keypress function. I'm aware that _IEAction("focus") in combination with Send would be an option, but I'm trying to avoid that Thank you very much in advance!
- 3 replies
-
- autoit ie
- javascript
-
(and 1 more)
Tagged with:
-
Hey, Im trying to fake google's mousedown event to get link but I dont have luck Here is my code #include <IE.au3> #include <MsgBoxConstants.au3> local $s_q = "autoit" local $i_resultnum = 100 local $lng = "tr" local $url = 'http://www.google.com/search?hl='&$lng&'&q=' & StringReplace(StringReplace($s_q, "+", "%2B"), " ", "+") & '&num=' & $i_resultnum ; $s_Source = _INetGetSource('http://www.google.com/search?hl='&$lng&'&q=' & StringReplace(StringReplace($s_q, "+", "%2B"), " ", "+") & '&num=' & $i_resultnum) $oIE = _IECreate($url, 0, 1) Local $oLinks = _IELinkGetCollection($oIE) Local $iNumLinks = @extended Local $sTxt = $iNumLinks & " links found" & @CRLF & @CRLF For $oLink In $oLinks if $oLink.href == "http://www.autoitscript.com/" Then MsgBox(0, default, "sadga") _IEAction($oLink, "focus") _IEAction($oLink, "blur") _IEAction($oLink, "click") EndIf Next
-
Hi all, I am trying to create a testing interface for some elearning work I am doing. I want to make a button called next to drive a captivate8 module interface via javascript. I can get the javscript to work fine but not via the button. I am using the onclick event but I have to physically click the browser screen to get it to work instead of doing this directly from the button. Can any one suggest a way to do this? This is what I am using: Func Button1Click() _IEHeadInsertEventScript($oIE, "document","onclick","cpAPIInterface.next();") EndFunc
-
Hi all, I am playing with an edit control. Koda form designer only gives me the text change event for this edit control. But i want to do some things when user clicks on this edit control. How can i set a mouse click event on this edit control. ?
-
Hi, I've been tinkering and tinkering and I really hope someone can give me some advice. I've used the IE.au3 UDF successfully with some different scripts, just I'm not even sure I'm going in the right direction on this one. A bunch of text input fields on a secure site are to be updated with data in the script (which the script gets from an excel file), and submitted. Not too hard, right? The input fields html looks like this: (in this case current value is 777.00) <input id="pt1:r1:1:pt1:ghostText:i10:0:lvl2:0:lvl3:0:lvl3PrcHdr:i15:0:lvl3Prc:ot21::content" name="pt1:r1:1:pt1:ghostText:i10:0:lvl2:0:lvl3:0:lvl3PrcHdr:i15:0:lvl3Prc:ot21" class="x25" type="text" value="777.00" title="777.00">I've tried _IEFormElementSetValue($oObj, $sInput, 0) _IEFormElementSetValue($oObj, $sInput, 1) $oObj.setAttribute("value", $sInput) $oObj.setAttribute("title", $sInput) _IEAction($oObj, "focus") $oObj.fireEvent("onfocus")in various combinations and orders, and the trouble is always that some fields are "skipped" or revert back to their previous value a few seconds later. Even though not actually submitting ie. clicking the "Save Changes" button on the page, some kind of processing is already going when anything is changed/focused etc., as far as I can see. What else I have tried: Using ControlSend($g_oIEHandle, "", "[CLASSNN:Internet Explorer_Server8]", $sInput) in combination with a lot of MouseGetCursor() I have a more simple script roughly "working" (doesn't use any IE objects). It works by waiting for a normal mousecursor for the page to be "ready" again in between inputfields... ...and this ends up being very slow and not much faster than human entry, and "only" fails sometimes (which is why there is a checking function as well, though this also adds to the time taken). So what can I do? From some research I've done, I understand there may be some way to cancel events (I know as much as that events have a propery "cancelable"). Maybe we can stop any javascript function from being called while filling all the input fields somehow, so that none of the input gets lost.Could this help? How to do this? One other idea is with POST and GET, so that the data that is usually submitted to the site on "Save Changes" can be sent without interface interaction... would this probably be very difficult to attempt? Where to start? (https...) Please, any thoughts, guidance on the above, or ideas/approaches I haven't thought of?
- 2 replies
-
- ie.au3
- javascript
-
(and 3 more)
Tagged with:
-
I wrote this power user tool a long while back and it originally had baked in commands and wasn't very extensible. I rewrote the tool and made use of the power and openeness of AutoIt. Some of you may find the concept and/or UI approach interesting (as well as useful) which is why I'm posting here. In all likely-hood, it could be rewritten entirely in AutoIt but that's not something I plan on doing. Good chance there are similar tools out there as well especially since I've sat on this for so long. In short, the tool provides a snazzy user interface (no two interfaces will look alike) which opens right over whatever your working on so you can quickly launch any number of chained AutoIt scripts. My all-time favorite being; normalize clipboard text. https://winclickpro.codeplex.com/ I haven't shared the tool or concept with anyone outside of publishing it so I'm curious to see what people think.
-
Is it possible to use WMI events, to monitor all the specific files of given filetype inside specific directory? I'd find it very usefull to use simple WMI events to check for how often graphic designers in my graphic department use different illustrator .AI files. Right now I am scanning folders using my own function and FileGetTime to check for any changes (last time accessed) and check for how usefull to us are files we have, but this is very limited. I have to run my scrypt every single minut to get more-less accurate data, missing some of the events that already accured or unnecesarilly over-loading CPU. Thanks in advance.
-
Harro, I am trying to poll Skype for events, I want something to happen when it is minimised. I have found some code on the forum that almost works, I have been tweaking it, but just can't get the minimise event to work. I would love some help on this. as I am not amamzing at DLL calling and such... the event handle for $EVENT_SYSTEM_MINIMIZEEND is never hit.. even when i minimise the window, i always get the same event codes. Here is what I have so far... #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Process.au3> #include <Misc.au3> Global $hDLL, $hWinEventProc, $hHook HotKeySet("{ESC}", "_HotKey") ; Exit ;Event Constants Global Const $EVENT_SYSTEM_SOUND = 0x0001 ;An MSAA event indicating that a sound was played. Global Const $EVENT_SYSTEM_ALERT = 0x0002 ;An MSAA event indicating that an alert was generated. Global Const $EVENT_SYSTEM_FOREGROUND = 0x0003 ;An MSAA event indicating that the foreground window changed. Global Const $EVENT_SYSTEM_MENUSTART = 0x0004 ;An MSAA event indicating that a menu item on the menu bar was selected. Global Const $EVENT_SYSTEM_MENUEND = 0x0005 ;An MSAA event indicating that a menu from the menu bar was closed. Global Const $EVENT_SYSTEM_MENUPOPUPSTART = 0x0006 ;An MSAA event indicating that a pop-up menu was displayed. Global Const $EVENT_SYSTEM_MENUPOPUPEND = 0x0007 ;An MSAA event indicating that a pop-up menu was closed. Global Const $EVENT_SYSTEM_CAPTURESTART = 0x0008 ;An MSAA event indicating that a window has received mouse capture. Global Const $EVENT_SYSTEM_CAPTUREEND = 0x0009 ;An MSAA event indicating that a window has lost mouse capture. Global Const $EVENT_SYSTEM_DIALOGSTART = 0x0010 ;An MSAA event indicating that a dialog box was displayed. Global Const $EVENT_SYSTEM_DIALOGEND = 0x0011 ;An MSAA event indicating that a dialog box was closed. Global Const $EVENT_SYSTEM_SCROLLINGSTART = 0x0012 ;An MSAA event indicating that scrolling has started on a scroll bar. Global Const $EVENT_SYSTEM_SCROLLINGEND = 0x0013 ;An MSAA event indicating that scrolling has ended on a scroll bar. Global Const $EVENT_SYSTEM_SWITCHSTART = 0x0014 ;An MSAA event indicating that the user pressed ALT+TAB, which activates the switch window. Global Const $EVENT_SYSTEM_SWITCHEND = 0x0015 ;An MSAA event indicating that the user released ALT+TAB. Global Const $EVENT_SYSTEM_MINIMIZESTART = 0x0016 ;An MSAA event indicating that a window object is about to be minimized or maximized. Global Const $EVENT_SYSTEM_MINIMIZEEND = 0x0017 ;An MSAA event indicating that a window object was minimized or maximized. Global Const $EVENT_SYSTEM_MOVESIZESTART = 0x000A ;An MSAA event indicating that a window is being moved or resized. Global Const $EVENT_SYSTEM_MOVESIZEEND = 0x000B ;An MSAA event indicating that the movement or resizing of a window is finished. Global Const $EVENT_SYSTEM_CONTEXTHELPSTART = 0x000C ;An MSAA event indicating that a window entered context-sensitive Help mode. Global Const $EVENT_SYSTEM_CONTEXTHELPEND = 0x000D ;An MSAA event indicating that a window exited context-sensitive Help mode. Global Const $EVENT_SYSTEM_DRAGDROPSTART = 0x000E ;An MSAA event indicating that an application is about to enter drag-and-drop mode. Global Const $EVENT_SYSTEM_DRAGDROPEND = 0x000F ;An MSAA event indicating that an application is about to exit drag-and-drop mode. Global Const $EVENT_OBJECT_CREATE = 0x8000 ;An MSAA event indicating that an object was created. Global Const $EVENT_OBJECT_DESTROY = 0x8001 ;An MSAA event indicating that an object was destroyed. Global Const $EVENT_OBJECT_SHOW = 0x8002 ;An MSAA event indicating that a hidden object is being shown. Global Const $EVENT_OBJECT_HIDE = 0x8003 ;An MSAA event indicating that an object is being hidden. Global Const $EVENT_OBJECT_REORDER = 0x8004 ;An MSAA event indicating that a container object has added, removed, or reordered its children. Global Const $EVENT_OBJECT_FOCUS = 0x8005 ;An MSAA event indicating that an object has received the keyboard focus. Global Const $EVENT_OBJECT_SELECTION = 0x8006 ;An MSAA event indicating that the selection within a container object changed. Global Const $EVENT_OBJECT_SELECTIONADD = 0x8007 ;An MSAA event indicating that an item within a container object was added to the selection. Global Const $EVENT_OBJECT_SELECTIONREMOVE = 0x8008 ;An MSAA event indicating that an item within a container object was removed from the selection. Global Const $EVENT_OBJECT_SELECTIONWITHIN = 0x8009 ;An MSAA event indicating that numerous selection changes occurred within a container object. Global Const $EVENT_OBJECT_HELPCHANGE = 0x8010 ;An MSAA event indicating that an object's MSAA Help property changed. Global Const $EVENT_OBJECT_DEFACTIonchange = 0x8011 ;An MSAA event indicating that an object's MSAA DefaultAction property changed. Global Const $EVENT_OBJECT_ACCELERATORCHANGE = 0x8012 ;An MSAA event indicating that an object's MSAA KeyboardShortcut property changed. Global Const $EVENT_OBJECT_INVOKED = 0x8013 ;An MSAA event indicating that an object has been invoked; for example, the user has clicked a button. Global Const $EVENT_OBJECT_TEXTSELECTIonchangeD = 0x8014 ;An MSAA event indicating that an object's text selection has changed. Global Const $EVENT_OBJECT_CONTENTSCROLLED = 0x8015 ;An MSAA event indicating that the scrolling of a window object has ended. Global Const $EVENT_OBJECT_STATECHANGE = 0x800A ;An MSAA event indicating that an object's state has changed. Global Const $EVENT_OBJECT_LOCATIonchange = 0x800B ;An MSAA event indicating that an object has changed location, shape, or size. Global Const $EVENT_OBJECT_NAMECHANGE = 0x800C ;An MSAA event indicating that an object's MSAA Name property changed. Global Const $EVENT_OBJECT_DESCRIPTIonchange = 0x800D ;An MSAA event indicating that an object's MSAA Description property changed. Global Const $EVENT_OBJECT_VALUECHANGE = 0x800E ;An MSAA event indicating that an object's MSAA Value property changed. Global Const $EVENT_OBJECT_PARENTCHANGE = 0x800F ;An MSAA event indicating that an object has a new parent object. ;minimum and maximum events ;to monitor one event type only use same event for min/max Global $EVENT_Min = $EVENT_SYSTEM_SOUND Global $EVENT_Max = $EVENT_SYSTEM_DRAGDROPEND $hDLL = DllOpen("User32.dll") $hWinEventProc = DllCallbackRegister("_WinEventProc", "none", "hwnd;int;hwnd;long;long;int;int") If Not @error Then OnAutoItExitRegister("OnAutoItExit") Else MsgBox(16 + 262144, "Error", "DllCallbackRegister(_WinEventProc) did not succeed.") Exit EndIf $hHook = _SetWinEventHook($EVENT_Min, $EVENT_Max, $hDLL) If @error Then MsgBox(16 + 262144, "Error", "_SetWinEventHook() did not succeed.") Exit EndIf While 1 Sleep(10) WEnd Func _WinEventProc($hHook, $iEvent, $hWnd, $idObject, $idChild, $iEventThread, $iEventTime) Local $PID = WinGetProcess($hWnd), $sEventProcName = _ProcessGetName($PID) ConsoleWrite("PID: " & $PID & @TAB & "WinTitle: " & StringLeft(WinGetTitle($hWnd), 30) & @TAB & "EventTime: " & $iEventTime & @TAB & @TAB & "Event: " & $iEvent & @CRLF) ConsoleWrite($idObject) if((StringInStr(WinGetTitle($hWnd),"Skype"))>=1) Then if($iEvent = $EVENT_SYSTEM_MINIMIZEEND) Then ConsoleWrite("Skype has been minimised!!") EndIf EndIf EndFunc ;==>_WinEventProc Func _SetWinEventHook($iEventMin, $iEventMax, $hDLLUser32) Local $aRet Local Const $WINEVENT_OUTOFCONTEXT = 0x0 Local Const $WINEVENT_SKIPOWNPROCESS = 0x2 If Not $hDLLUser32 Or $hDLLUser32 = -1 Then $hDLLUser32 = "User32.dll" $aRet = DllCall($hDLLUser32, "hwnd", "SetWinEventHook", _ "uint", $iEventMin, _ "uint", $iEventMax, _ "hwnd", 0, _ "ptr", DllCallbackGetPtr($hWinEventProc), _ "int", 0, _ "int", 0, _ "uint", BitOR($WINEVENT_OUTOFCONTEXT, $WINEVENT_SKIPOWNPROCESS)) If @error Then Return SetError(@error, 0, 0) Return $aRet[0] EndFunc ;==>_SetWinEventHook Func _HotKey() Switch @HotKeyPressed Case "{ESC}" Exit EndSwitch EndFunc ;==>_HotKey Func OnAutoItExit() If $hWinEventProc Then Beep(3000, 5) DllCallbackFree($hWinEventProc) EndIf If $hHook Then DllCall("User32.dll", "int", "UnhookWinEvent", "hwnd", $hHook) If $hDLL Then DllClose($hDLL) EndFunc ;==>OnAutoItExit