Leaderboard
Popular Content
Showing content with the highest reputation on 03/01/2019 in all areas
-
Spotify Grab Now Playing and Track Elapsed/Duration
argumentum and 3 others reacted to Bilgus for a topic
Thanks to LarsJ's excellent UIASpy application I was able to grab the now playing and track elapsed / duration from Spotify in about 15 minutes https://www.autoitscript.com/forum/topic/196833-uiaspy-ui-automation-spy-tool/ You will need junkew's CUIAutomation2.au3 from the above UDF4 points -
I've made this HTTP lib to simplify HTTP requests, mainly when dealing about POST data or file uploads. Three functions are available: string _HTTP_Get ( string $sURL ) string _HTTP_Post ( string $sURL , string $sPostData ) string _HTTP_Upload ( string $sURL , string $sFilePath , string $sFileField , string $sPostData = '' , string $sFilename = Default) Additionaly, two helper functions are also available: URLEncode($sStr) URLDecode($sStr) Full documentation: https://github.com/jesobreira/HTTP.au3/blob/master/README.md Fork me on Github: https://github.com/jesobreira/HTTP.au3 Download lib + docs: https://github.com/jesobreira/HTTP.au3/archive/master.zip1 point
-
Automate all windows and browser applications with one UDF function library. Based on the microsoft automation API this library high level supports Recognition of conttrols from EDGE, Chrome, FF, Opera, Safari and Windows native apps Small testing framework to split object repository from coding away Introduction Quickstart - Getting started quickly Simple scripts With this module you can automate all applications/programs that support ui automation and/or accesibility api from microsoft you can recognize more controls than AutoIT can recognize "out of the box" you can use concepts from other testing frameworks like http://download.freedesktop.org/ldtp/doc/ldtp-tutorial.pdf http://safsdev.sourceforge.net/Default.htm coded ui testing from microsoft Some of those controls / applications are chrome browser (partly mainwindow has to be done with MSAA for navigating) chrome://accessibility in the adress bar of chrome or start with "--force-renderer-accessibility" silverlight controls Ribbon control controlbars of Excel/Word IE and FF browsers Windows Media Player Windows clock AFX .. controls (partly) .... Based on the initial AIO Object I now have made the interface file to work with objCreateInterface function which is in the latest beta's automate clicking and querying basic information It gives you a lot of basic information to be able to automate clicking, querying basic information where it goes further in certain situations than AutoIt is identifying Starting threads for background on the ui automation api of microsoft (not for starters) http://en.wikipedia.org/wiki/Microsoft_UI_Automation http://msdn.microsoft.com/en-us/library/ms747327.aspx Previous threads in general help/support Interface AutoItObject IUIAutomation ObjCreateInterface and struct tagPoint in method ElementFromPoint Be aware that API is not allways installed under XP/Vista see http://support.microsoft.com/kb/971513 Within Windows 7 and Windows 8 it should be preinstalled by default. Be aware on 32 and 64 bits way of running your script #AutoIt3Wrapper_UseX64=Y or N Basic example of usage / showing and retrieving the default information, will post multiple examples later Hover your mouse to an area of interest and press ctrl+w and information will be shown in the edit box of the form Simple spy demo (see simplespy.au3 or use latest ZIP attachment for latest version) Main features Recognize windows and html controls for the major browsers Logical and physical description for controls (UI mapping, Application map) Simple repository logic to abstract logical and physical descriptions Store Runtime Type Information in RTI. variables Rubberbanding/highlighting of objects Simple spy to help in making / identifying the physical description Support of regular expression(s) in identifying objects recognize objects on multiple properties supported properties: name ,title, automationid, classname, class, iaccessiblevalue, iaccessiblechildId, controltype, processid, acceleratorkey The actions provided so far "leftclick", "left", "click", "leftdoubleclick", "leftdouble", "doubleclick", _ "rightclick", "right", "rightdoubleclick", "rightdouble", _ "middleclick", "middle", "middledoubleclick", "middledouble", "mousemove", "movemouse" "setvalue","settextvalue" "setvalue using keys" "setValue using clipboard" "getvalue" "sendkeys", "enterstring", "type", "typetext" "invoke" "focus", "setfocus", "activate" "close" "move","setposition" "resize" "minimize", "maximize", "normal", "close", "exist", "exists" "searchcontext", "context" "highlight" "getobject","object" "attach" "capture","screenshot", "takescreenshot" "dump", "dumpthemall" "propertyvalue", "property" match on multiple properties like: name:=((Zoeken.*)|(Find.*)); ControlType:=Button; acceleratorkey:=Ctrl+F Support for 117 different properties see $UIA_propertiesSupportedArray in uiawrappers like for example title, regexptitle, class, regexpclass, iaccessiblevalue, iaccessiblechildid, name, accesskey, automationid, classname IAccessible, IAccessible2, ISimpleDom interfaces debuglogging to a file log.txt (no output in scitewindow) Examples Example 1 Iterating thru the different ways of representing the objects in the tree (#comment-1105548) Example 2 Finding the taskbar and clicking on the start menu button (#comment-1105680) Example 3 Clicking a litlle more and in the end displaying all items from the clock (thats not directly possible with AU3Info) (#comment-1108849) Example 4 that demonstrates the calculator Example 5 Automating chrome Example 6 Demonstrates all stuff within chrome to navigate html pages, find hyperlink, click hyperlink, find picture, click picture, enter data in inputbox Example 7 The chrome example modified to a firefox example Example 8 The other major browser Internet Explorer automated (made on Example 6 and 7) Example 9 Windows media player Example 10 Automating mach 3 (AFX windows and other hard to get recognized by AutoIT) Lot of links are broken due to forum upgrade just search for the text like "Example 11 Demonstrate Word, Notepad and Calculator actions" Example 11 Demonstrate Word, Notepad and Calculator actions ... Example 13 Details 1 about the right pane of the windows explorer Example 14 Details 2 about the right pane of the windows explorer Example 15 Details 3 about the right pane of the windows explorer Example 16 Details 4 about the right pane of the windows explorer Example 17 Details 5 about the right pane of the windows explorer WITH CACHING Example 18 Details 6 about the right pane of the windows explorer WITH VIRTUAL ITEMS Example 19 Eventhandling examples Example 20 Eventhandling examples Example 21a Eventhandling examples Internet Explorer Example 21b Eventhandling examples Internet Explorer Example 22 Eventhandling examples Follow focus Example 23 Eventhandling examples structure changed Example 24 Eventhandling examples IUIAutomationEventHandler Example 25 SAFEARRAYS Example 26 IACCESSIBLE / MSAA Example 27 IACCESSIBLE2 / MSAA Example 28 IACCESSIBLE / MSAA events Example 29 IACCESSIBLE2 events Example 30 ISimpleDOM Example 31 Notepad window move, maximize, minimize Example 32 Three browsers doing the same stuff with small differences in scripting only .. TODO Build recorder Enhance the spy with a nicer UI UI for the repository (now in the script with dot notation) Enhance mapping / identifying on multiple properties instead of 1 combined with index If speed becomes an issue use the caching logic of the MS UIA framework Add the other patterns later Generalize the concept of System Under Test of starting the SUT (for testing framework purposes) Remote running of scripts Fix issue on finding within dynamic context ... edit august 18th 2013 initial post Only zip files are needed to download , just unzip in 1 directory edit july 2016 Made V0_63 and examples works with AutoIt v3.3.14 Windows 10 tested Simple spy gives some basic code as a present Chrome latest versions seems to be having issues with IUIAutomation on tabs/buttons of mainwindow use MSAA for accessing tabsheets / buttons more cleanup to be in UDF style More comments in the source see changelog.txt for previous changes edit september 2017 All examples fixed for the IE, Firefox and Chrome browser Some small but essential fixes in UIAWrappers edit april 2018 Enhanced logic on fallback / dynamic search, still not perfect, to slow Retested with latest Chrome, FF, Edge and IE11 and some extensions to show how to get text from the webpage (examples 5,6,7) Some small bugfixes Some comments as given in forum incorporated edit may 2019 Speed enhancements on especially fallback searching UIA.CFG works now in a better way to turn on/off debug, highlighting, debug2file More stable and consistent behavior Internal cleanup and refactoring of bigger functions Checked with W10 (not tested on W7) Added some W10 properties Run with 3.3.14.5 on W10 UIA_V0_51.zip EXAMPLES_V0_5.zip UIA_V0_63.zip EXAMPLES_V0_63.zip UIA_V0_64.zip EXAMPLES_V0_64.zip EXAMPLES_V0_66.zip UIA_V0_66.zip EXAMPLES_V0_70.zip UIA_V0_70.zip1 point
-
ChakraCore UDF - executing JavaScript in AutoIt
dariel reacted to scintilla4evr for a topic
Hello! Microsoft Edge, the new browser released with Windows 10, uses Chakra as its JavaScript engine. In January, Microsoft released ChakraCore - the open source version of the engine that can be used in other apps. So, how about using it in AutoIt? I tried 2 times to create ChakraCore UDF, and I succeeded. So here it is - the ChakraCore UDF. Features: Executing JavaScript from AutoIt (obviously) Passing data from AutoIt to JavaScript Calling AutoIt functions from JavaScript ChakraCore UDF Have fun!1 point -
This is a continuation of Custom drawn TreeViews and ListViews. However, only with respect to listviews. The crucial difference between the new and the old code is that the new code is a complete UDF and therefore much easier to use. Because the UDF is about colors and fonts in listview items and subitems, it's only for listviews in Details or Report view. Main features The UDF supports the following main features. Colors and fonts: 1 Single items/subitems Back colors Fore colors Fonts and styles 2 Colors/fonts for entire columns 3 Alternating colors (entire listview) Alternating colors for rows, columns or both Both default and alternating color can be set Number of rows/columns between color change can be set 4 Custom default colors/font instead of standard default colors/font Custom default back and fore colors can be set for Normal listview items (instead of white and black) Selected listview items (instead of dark blue and white) Unfocused selected items (instead of button face and black) 5 Colors for selected listview items Back and fore colors for selected items when listview has focus Back and fore colors for selected items when listview has not focus Features 1, 2 and 3 cannot be mixed together. 4 and 5 can be mixed with the previous features. 5 extends the functionality of the previous features by adding colors to selected items. 5 cannot be used alone. Listviews: Multiple listviews Native and non-native listviews Native and non-native listview items The UDF can be used with existing listviews WM_NOTIFY message handlers: WM_NOTIFY message handlers can be used completely as usual The UDF can be used with existing WM_NOTIFY message handlers Colors and fonts for single listview items/subitems are stored in an array. The index in this array for a given listview item is stored in ItemParam. Except for this usage of ItemParam nothing in the UDF assumes that listviews or items/subitems are created in a certain way, or that any WM_NOTIFY handlers exists or are designed in a certain way. It should be easy to use the UDF with existing listviews with or without a WM_NOTIFY message handler or other message handlers. WM_NOTIFY message handlers Colors and fonts in listviews are implemented through custom draw notifications in the form of WM_NOTIFY messages. A WM_NOTIFY message handler is needed to implement colors/fonts. If a listview is included in a GUI and a little more than just very basic functionality is wanted, another WM_NOTIFY handler is soon needed to implement this functionality. To register a WM_NOTIFY handler you use the function GUIRegisterMsg. This function can register only one message handler at a time for the same message type. The result of code like this is that only WM_NOTIFY2 message handler is working: GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY1" ) ; Register WM_NOTIFY1 GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY2" ) ; Register WM_NOTIFY2 (unregisters WM_NOTIFY1) This makes it difficult to implement colors/fonts in a UDF, if you at the same time want to implement advanced functionality in your own code. A solution is to register the WM_NOTIFY message handler, that takes care of custom draw notifications, in a different way. This can be done by a technique called subclassing, which is implemented through the four functions SetWindowSubclass, GetWindowSubclass, RemoveWindowSubclass and DefSubclassProc (coded in WinAPIShellEx.au3). Subclassing Subclassing a window (or control) means to create a message handler for the window, that will receive messages to the window before the original message handler for the window. This section is information on the implementation of a WM_NOTIFY message handler through subclassing: The UDF The UDF is implemented in UDFs\ListViewColorsFonts.au3. This is a list of the most important functions copied from the UDF (around line 200): ; Initiating and exiting ; ---------------------- ; ListViewColorsFonts_Init ; ListViewColorsFonts_Exit ; ; Set colors/fonts for items/subitems ; ----------------------------------- ; ListViewColorsFonts_SetItemColors ; ListViewColorsFonts_SetItemFonts ; ListViewColorsFonts_SetItemColorsFonts ; ; Set colors/fonts for entire listview ; ------------------------------------ ; ListViewColorsFonts_SetColumnColorsFonts ; ListViewColorsFonts_SetAlternatingColors ; ListViewColorsFonts_SetDefaultColorsFonts ; ; Maintenance functions ; --------------------- ; ListViewColorsFonts_Redraw Some of the functions in the complete list in the file are not coded in this version. To use the UDF you first calls ListViewColorsFonts_Init which stores information about the listview and the parent window, and creates the subclass that takes care of the actual drawing of the colors and fonts. Then you call one or more of the ListViewColorsFonts_Set-functions to define the colors and fonts. Depending on the functions you might also need to call ListViewColorsFonts_Redraw. And that's all. Finally you can call ListViewColorsFonts_Exit to remove the subclass before the script exits. If you don't call ListViewColorsFonts_Exit it's called automatically by the UDF. This is the syntax for ListViewColorsFonts_Init and the information about $fColorsFonts flag also copied from ListViewColorsFonts.au3: ; ListViewColorsFonts_Init( $idListView, $fColorsFonts = 7, $iAddRows = 100, $bNative = False ) ; $idListView - Listview control ID or handle ; $fColorsFonts - Specifies options for usage of colors and fonts in the listview. Add required options together. ; 1: Back colors for items/subitems ; Can not be specified separately in this version ; 2: Fore colors for items/subitems ; Can not be specified separately in this version ; 4: Fonts and styles for items/subitems ; Can not be specified separately in this version ; 7: Back and fore colors, fonts and styles ; Flags 1/2/4 are combined in flag 7 in this version ; ; 8: Colors/fonts for entire columns ; ; 16: Alternating row colors (for entire listview) ; 32: Alternating column colors (for entire listview) ; ; 64: Custom default colors and font (for entire listview) ; Custom default back and fore colors can be set for ; - Normal listview items (instead of white and black) ; - Selected listview items (instead of dark blue and white) ; - Unfocused selected listview items (instead of button face and black) ; ; 128: Colors for selected items when listview has focus ; 256: Colors for selected items when listview has not focus The limitations with respect to flags 1, 2 and 4 in this version is only a matter of optimizations. It has nothing to do with features. Drawing of selected items is largely controlled by Windows. A lot of extra code is needed to implement custom colors for selected items through flags 128 and 256. For $fColorsFonts flag is further noted that: ; - Flags 1/2/4 can be combined in a total of seven different ways ; - Flags 1/2/4 (items/subitems), flag 8 (columns) and flags 16/32 (listview) cannot be combined ; - Flag 64 is used to replace the standard default colors/font by custom default colors/font ; Flag 64 can be used alone or in combination with flags 1-32 ; Custom default colors/font must be set before all other colors/fonts ; Flag 64 leads to some restrictions on the features for items/subitems (flags 1/2/4) ; - Flags 128/256 extends the functionality of flags 1-64 by adding colors to selected items ; Flags 128/256 cannot be used alone An array $aListViewColorsFontsInfo is used to store information about the listview, the parent window and the usage of colors/fonts in the listview. For flags 1/2/4 about single items/subitems another array $aListViewColorsFonts is used to store the colors and fonts for the items and subitems. The number of columns in this array depends on whether the flags 128/256 are set or not. The first 160 lines in the UDF contains information about these arrays. For flags 1/2/4 ItemParam field in the listview is used to store the zero based row index in $aListViewColorsFonts for a given listview item. For native listview items created with GUICtrlCreateListViewItem the existing value of ItemParam (control ID) is used as index in an intermediate array $aListViewColorsFonts_Index, and $aListViewColorsFonts_Index holds the index in $aListViewColorsFonts stored as index+1. For non-native listview items the index in $aListViewColorsFonts is stored in ItemParam as -index-20. For non-native listview items an existing value of ItemParam is overwritten. The best way to add colors and fonts to listviews is to put each listview in its own child window. The child window should not contain any other controls, and it should have the same size as the listview. However, this is not a requirement. See the UDF for documentation of the other functions. The implementation of the functions starts in line 230 and onwards. The UDF also contains a group of internal functions. Among other the subclass callback functions to draw the colors and fonts in response to NM_CUSTOMDRAW notifications from the listview. So far the UDF contains seven callback functions which starts around line 2100 and runs over the next 1300 lines nearly to the bottom of the file. The code This section is about some code details related partly to the subclass callback functions and partly to drawing of selected items. Subclass callback functions: Drawing of selected items: In the current version of the UDF the callback function that is implemented to draw single items/subitems ($fColorsFonts = 1/2/4) is the function that can handle all features ($fColorsFonts = 1+2+4 = 7). If only a part of the features is needed, it's possible to create smaller and faster functions, which only implements this part of the features. These functions (six functions in total) are postponed to next version. Features A few comments on the features. The main features in terms of colors and fonts are (a repeat of the list in top of post): 1 Single items/subitems 2 Colors/fonts for entire columns 3 Alternating colors (entire listview) 4 Custom default colors/font instead of standard default colors/font 5 Colors for selected listview items 1, 2 and 3 are features for different kind of elements in the listview and cannot be mixed together. 4 can be used either as an independent feature or mixed with 1, 2 or 3. 5 cannot be used as an independent feature but can only be used together with 1, 2, 3 or 4. 5 extends the functionality of these features by adding colors to selected items. When features 1, 4 and 5 are mixed together, it may look as shown in the following illustrations (screen dumps of examples 3.1 and 4.1 in folder \Examples\5) Selected items\). The first illustration shows how it looks when colors for single items/subitems are mixed with colors for selected items: In the upper picture rows 3-6 are provided with back and fore colors. All subitems in row 3 and 4. Only a few subitems in row 5 and 6. The rows are normal (unselected) rows. In the middle picture rows 2-7 are selected and the listview has focus. Rows 3-6 are also provided with back and fore colors for selected items. In the lower picture rows 2-7 are selected but the listview has not focus. Rows 3-6 are also provided with back and fore colors for selected but unfocused items. In the second illustration the standard default colors are replace with custom default colors. The standard default back and fore colors are: Normal (unselected) items: White and black Selected items in focused listview: Dark blue and white Selected items in unfocused listview: Button face and black These custom default colors are used in the illustration: Normal (unselected) items: Light green and brown Selected items in focused listview: Shiny green (chartreuse) and black Selected items in unfocused listview: Dark green and black Examples Two folders with examples is included in the zip below. The first folder is named Examples and contains examples about the usage of the functions in the UDF. The second folder is named UDF topics and contains examples related to the implementation of the UDF. It's about the use of the subclassing technique as a substitute for a WM_NOTIFY message handler. Particularly about the message flow and performance issues. These examples are addressed in next section. The Examples folder contains these subfolders and files: 0) UDF examples\ - The small examples from the documentation of the functions in the UDF 1) Items-subitems\ - Colors and fonts for single items/subitems 2) Entire columns\ - Colors and fonts for entire columns 3) Alternating colors\ - Alternating row/column colors in an entire listview 4) Custom defaults\ - Replace standard default colors/font with custom defaults 5) Selected items\ - Colors for selected items when listview has focus and has not focus 6) Help file examples\ - Shows how to add colors to a few examples from AutoIt Help file 7) Original examples\ - An implementation of the examples in the old thread with this UDF Listview templates\ - A collection of listview templates ready to add colors/fonts Features demo.au3 - A brief demonstration of all features No colors or fonts.au3 - Reference example All examples runs on Windows XP and later without any performance issues. Folder 1 - 5 demonstrates the five main color/font features listed in top of post. In most of the subfolders you can find a _Readme.txt file with a brief description of the examples. Multiple selections is enabled in most listviews. A few examples will not pass an Au3Check. In particular the examples in subfolder 1 and 2 and the examples in UDF topics folder (see next section) were used to test the subclassing technique as a substitute for a WM_NOTIFY message handler. More information about some of the examples: Examples\0) UDF examples\0) ListViewColorsFonts_Init\Example 1.au3: #include <GUIConstantsEx.au3> #include "..\..\..\UDFs\ListViewColorsFonts.au3" #include "..\..\..\UDFs\GuiListViewEx.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create GUI Local $hGui = GUICreate( "ListViewColorsFonts_Init\Example 1", 420, 200, -1, -1, $GUI_SS_DEFAULT_GUI-$WS_MINIMIZEBOX ) ; Create ListView Local $idListView = GUICtrlCreateListView( "", 10, 10, 400, 180, $GUI_SS_DEFAULT_LISTVIEW-$LVS_SINGLESEL, $WS_EX_CLIENTEDGE ) _GUICtrlListView_SetExtendedListViewStyle( $idListView, $LVS_EX_DOUBLEBUFFER+$LVS_EX_FULLROWSELECT ) Local $hListView = GUICtrlGetHandle( $idListView ) ; Reduces flicker ; Add columns to ListView _GUICtrlListView_AddColumn( $idListView, "Column 1", 94 ) _GUICtrlListView_AddColumn( $idListView, "Column 2", 94 ) _GUICtrlListView_AddColumn( $idListView, "Column 3", 94 ) _GUICtrlListView_AddColumn( $idListView, "Column 4", 94 ) ; Fill ListView Local $iItems = 100 For $i = 0 To $iItems - 1 GUICtrlCreateListViewItem( $i & "/Column 1|" & $i & "/Column 2|" & $i & "/Column 3|" & $i & "/Column 4", $idListView ) Next ; Perform initializations to add colors/fonts to single items/subitems ListViewColorsFonts_Init( $idListView, 7 ) ; $fColorsFonts = 7, ( $iAddRows = 100, $bNative = False ) ; Set a green back color for an entire item and a yellow back color for a single cell ListViewColorsFonts_SetItemColors( $idListView, 3, -1, 0xCCFFCC ) ; Green back color for entire item ListViewColorsFonts_SetItemColors( $idListView, 3, 2, 0xFFFFCC ) ; Yellow back color for cell 2 in item ; Force an update of local variables in drawing function ListViewColorsFonts_Redraw( $idListView ) ; Adjust height of GUI and ListView to fit ten rows Local $iLvHeight = _GUICtrlListView_GetHeightToFitRows( $hListView, 10 ) WinMove( $hGui, "", Default, Default, Default, WinGetPos( $hGui )[3] - WinGetClientSize( $hGui )[1] + $iLvHeight + 20 ) WinMove( $hListView, "", Default, Default, Default, $iLvHeight ) ; Show GUI GUISetState( @SW_SHOW ) ; Message loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Delete color/font info for listview ListViewColorsFonts_Exit( $idListView ) GUIDelete() EndFunc UDF topics The examples in UDF topics folder is about the use of subclassing as a substitute for a WM_NOTIFY message handler. Particularly about the message flow and performance issues. These examples illustrates some of the issues, that was discussed in the Subclassing section above, with code. The UDF topics folder contains these subfolders: 1) Subclassing\ - Creating listviews in GUI or child windows? 2) Performance\ - How many listviews can you create in GUI? More information about the examples: Next version In The code section above is already mentioned a number of subclass callback functions which are postponed to next version. The purpose of these additional functions is merely to optimize the code in terms of speed. A number of ListViewColorsFonts_Get-functions to complement the corresponding ListViewColorsFonts_Set-functions are also deferred to next version. For single items/subitems ($fColorsFonts = 1/2/4) colors and fonts are stored in $aListViewColorsFonts array which again is stored in $aListViewColorsFontsInfo. The three functions ListViewColorsFonts_SetItemColors / SetItemFonts / SetItemColorsFonts are used to update $aListViewColorsFonts item by item or subitem by subitem. It would be much faster to update $aListViewColorsFonts directly. Two functions are needed to get a copy of the array from $aListViewColorsFontsInfo and store the array again after the updates. And there is also a need for a couple of examples to illustrate the technique. Examples to dynamically update colors and fonts are missing in this version. Perhaps there is also a need for a few functions to support dynamically updates. For non-native listviews created with _GUICtrlListView_Create it's not uncommon to use ItemParam to store a user defined value. If index in $aListViewColorsFonts is stored in ItemParam, it's no longer possible to use ItemParam for such purposes. A couple of functions to give the user an opportunity to still be able to store a user defined value would be nice. Several global variables are defined in this version. They will be removed in the next version except for a few variables which probably will need to be global in performance terms. If there will be reported any issues or problems in this version, they of course also need to be addressed. The next version should be ready in 2-3 months, and it should also be the final version. Zip file The zip is structured in this way Examples\ UDF topics\ UDFs\ ListViewColorsFonts.au3 GuiImageListEx.au3 GuiListViewEx.au3 NamedColors.au3 OtherColors.au3 NamedColors.au3 contains global constants of named colors copied from .NET Framework Colors Class. You need AutoIt 3.3.10 or later. Tested on Windows 7 32/64 bit and Windows XP 32 bit. Comments are welcome. Let me know if there are any issues. (Set tab width = 2 in SciTE to line up comments by column.) ListViewColorsFonts.7z1 point
-
try this way... #include <IE.au3> HotKeySet("{ESC}", "_Close") _IEErrorHandlerRegister(_ErrFunc) $oIE = _IECreateEmbedded() $hGui = GUICreate("Test", 700, 500, -1, -1) GUICtrlCreateObj($oIE, 0, 0, 700, 500) _IENavigate($oIE, "about:blank") $sHTML = "" $sHTML &= "<html>" $sHTML &= "<head>" $sHTML &= "<title>Test</title>" $sHTML &= "</head>" $sHTML &= "<body>" $sHTML &= '<button type="button" id="btnMenu">=</button>' $sHTML &= '<button type="button" id="btnClose">X</button>' $sHTML &= "</body>" $sHTML &= "</html>" _IEDocWriteHTML($oIE, $sHTML) _IEAction($oIE, "refresh") GUISetState() ; ------------------------------------------------------------------------------- ; inject a reference to the javascript global object into the WebBrowser document ; this works for the BrowserControl, but it doesn't on the IE browser ; ; http://perfectionkills.com/unnecessarily-comprehensive-look-into-a-rather-insignificant-issue-of-global-objects-creation/#ecmascript_5_strict_mode $oIE.document.parentwindow.setTimeout("JSglobal = (1,eval)(""this"");", 0) Local $ohJS Do Sleep(1000) $ohJS = Execute('$oIE.document.parentwindow.JSglobal') Until IsObj($ohJS) ; getting references to javascript objects in this way will then work on ObjEvent $oButtonMenu = $ohJS.btnMenu ;_IEGetObjById($oIE, "btnMenu") $oButtonClose = $ohJS.btnClose ; _IEGetObjById($oIE, "btnClose") ; ------------------------------------------------------------------------------- $oEvent = ObjEvent($oButtonMenu, "_MY_EVENT_HANDLER_", "HTMLButtonElementEvents2") $oEvent2 = ObjEvent($oButtonClose, "_MY_EVENT_HANDLER_", "HTMLButtonElementEvents2") While (1) Sleep(20) WEnd Volatile Func _MY_EVENT_HANDLER_onclick($oEventObj) ; https://msdn.microsoft.com/en-us/library/aa703876(v=vs.85).aspx MsgBox(4096, "Yay!", "You clicked the button. But which one ? this ID --> " & $oEventObj.srcElement.id) EndFunc ;==>_MY_EVENT_HANDLER_onclick Func _Close() ; the end $oEvent.stop $oEvent2.stop $oEvent = 0 $oEvent2 = 0 $oIE = 0 ; Remove IE from memory GUIDelete($hGui) ; Remove GUI Exit EndFunc ;==>_Close Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc p.s. For another example of use for the WebControl, have a look to this script also... (https://www.autoitscript.com/forum/topic/186422-who-is-who-a-little-dragdrop-game/)1 point
-
I was sure that this problem was asked before. A quick search and: You can also see this in my rewritten XML.au3 UDF Func _XML_SelectSingleNode(ByRef $oXmlDoc, $sXPath) ; Error handler, automatic cleanup at end of function Local $oXML_COM_ErrorHandler = ObjEvent("AutoIt.Error", __XML_ComErrorHandler_InternalFunction) #forceref $oXML_COM_ErrorHandler __XML_IsValidObject_DOMDocumentOrElement($oXmlDoc) If @error Then Return SetError(@error, @extended, $XML_RET_FAILURE) Local $oNode_Selected = $oXmlDoc.selectSingleNode($sXPath) If @error Then Return SetError($XML_ERR_XPATH, $XML_EXT_DEFAULT, $XML_RET_FAILURE) ElseIf $oNode_Selected = Null Then Return SetError($XML_ERR_NONODESMATCH, $XML_EXT_DEFAULT, $XML_RET_FAILURE) ElseIf Not IsObj($oNode_Selected) Then ; https://www.autoitscript.com/forum/topic/177176-why-isobj-0-and-vargettype-object/ ; $XML_ERR_EMPTYOBJECT Return SetError($XML_ERR_NONODESMATCH, $XML_EXT_DEFAULT, $XML_RET_FAILURE) EndIf Return SetError($XML_ERR_SUCCESS, $XML_EXT_DEFAULT, $oNode_Selected) EndFunc ;==>_XML_SelectSingleNode1 point
-
@Danyfirex aha .. now I see. You were referring to my "nonsense" in the code: Func _GDPR_Anonymize_String1(ByRef $sString) Return SetError(@error, @extended, StringRegExpReplace($sString, '(?i)(.)(.{1,2})', '$1**')) EndFunc ;==>_GDPR_Anonymize_String1 where, the code will always return @error = 0 and @exteneded = 0 Yes, this was a quick beta version1 point
-
RegExp Replace - Insert Whitespace
pixelsearch reacted to jchd for a topic
A little more involved than a one-liner: Local $sValue = _ "WORD_1 : RESULT_1" & @CRLF & _ "ANYLETTER_2 : RESULT_2" & @CRLF & _ "WORDNEXT_3 : RESULT_3" & @CRLF & _ "SOMEWORDMORE_4 : RESULT_4" & @CRLF & _ "ONLY_5 : RESULT_6" Local $aValues = StringRegExp($sValue, "(\w+)[\h:]+(\w+)", 3) Local $size For $i = 0 To UBound($aValues) - 1 Step 2 If StringLen($aValues[$i]) > $size Then $size = StringLen($aValues[$i]) Next Local $sFormatted For $i = 0 To UBound($aValues) - 1 Step 2 $sFormatted &= StringFormat("%-" & $size & "s : %s\r\n", $aValues[$i], $aValues[$i + 1]) Next ConsoleWrite($sFormatted) No single regexp can scan the data to determinate the longest first word of each line and then go backwards to reformat stuff. You can as well make the first regexp collect only first words but you still have to go thru the resulting array to chase the max size, like in code above. Of course you could do the same in a more pedestrian way with more code, keeping track of max size so far. Anyway, after that you can replace the second For loop by a StringRegexpReplace to do the formatting, in place of the second For loop. That's just a matter of taste.1 point -
IIRC @extended is set to the WIndows error code. This codes can be found here: https://docs.microsoft.com/en-us/windows/desktop/Debug/system-error-codes--0-499- 267 means: ERROR_DIRECTORY, 267 (0x10B), The directory name is invalid.1 point
-
How to click button no id or name IE.au3
alienclone reacted to Subz for a topic
Try: #include <IE.au3> Local $oIE = _IECreate("https://viptools.es", 1) _IELoadWait($oIE) Local $oButtons = _IETagNameGetCollection($oIE, "button") If IsObj($oButtons) Then For $oButton In $oButtons If $oButton.getAttribute("data-target") = "#sharesmodal" Then _IEAction($oButton, "click") ExitLoop EndIf Next EndIf1 point -
Making a time logger
JackCaldwell reacted to abberration for a topic
Dude, I'm working on a timeclock to post in the examples section. It's not finished yet, but here's the code if you want to take a look at it. #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <DateTimeConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <ColorConstants.au3> #include <Array.au3> #include <String.au3> $filTimeData = "TimeclockData.ini" $filSettings = "TimeclockSettings.ini" $varTimeFormat = "ampm" $varCurrentTime = _FormatTime(@HOUR & ":" & @MIN) Local $varName $guiMain = GUICreate("Timeclock", 348, 134) ;$varColor = "$COLOR_" & IniRead($filSettings, "ColorScheme", "Color", "WHITE") ;MsgBox(0, "", $varColor) ;Assign("varColor", "$COLOR_" & IniRead($filSettings, "ColorScheme", "Color", "WHITE")) ;GUISetBkColor($varColor) $guiDate = GUICtrlCreateDate("", 16, 8, 82, 21, $WS_TABSTOP) $guiLabel = GUICtrlCreateLabel($varCurrentTime, 114, 8, 50, 17) $guiCombo = GUICtrlCreateCombo("", 176, 8, 154, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL,$WS_VSCROLL)) $guiButton1 = GUICtrlCreateButton("Clock In", 16, 40, 75, 23, $WS_GROUP) $guiButton2 = GUICtrlCreateButton("Begin Lunch", 96, 40, 75, 23, $WS_GROUP) $guiButton3 = GUICtrlCreateButton("Lunch Over", 176, 40, 75, 23, $WS_GROUP) $guiButton4 = GUICtrlCreateButton("Go Home", 256, 40, 75, 23, $WS_GROUP) $guiButton5 = GUICtrlCreateButton("Refresh Time", 16, 80, 75, 23, $WS_GROUP) $guiButton6 = GUICtrlCreateButton("Edit Data", 256, 80, 75, 23, $WS_GROUP) $guiMenuFile = GUICtrlCreateMenu("File") $guiMenuReport = GUICtrlCreateMenuItem("Generate Report", $guiMenuFile) $guiMenuExit = GUICtrlCreateMenuItem("Exit", $guiMenuFile) $guiMenuSettings = GUICtrlCreateMenu("Settings") $guiMenuAddUser = GUICtrlCreateMenuItem("Add User", $guiMenuSettings) $guiMenuDelUser = GUICtrlCreateMenuItem("Delete User", $guiMenuSettings) $guiMenuProgSettings = GUICtrlCreateMenuItem("Program Settings", $guiMenuSettings) $guiMenuAbout = GUICtrlCreateMenu("About") $guiMenuAboutTC = GUICtrlCreateMenuItem("About Trimeclock", $guiMenuAbout) GUISetState(@SW_SHOW) If NOT FileExists($filTimeData) Then _AddName() _PopulateCombo($vatrName) Else _PopulateCombo("NoName") EndIf _DisableButtons() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $guiMenuAddUser $varName = _AddName() If $varName <> "" Then _PopulateCombo($varName) EndIf Case $guiMenuDelUser _DeleteUsers() Case $guiButton1 $varDate = _DateConvert(GUICtrlRead($guiDate)) $varCurrentUser = GUICtrlRead($guiCombo) $varTime = _ReadTime() IniWrite($filTimeData, $varCurrentUser, $varDate & "a", $varTime) _DisableButtons() Case $guiButton2 $varDate = _DateConvert(GUICtrlRead($guiDate)) $varCurrentUser = GUICtrlRead($guiCombo) $varTime = _ReadTime() IniWrite($filTimeData, $varCurrentUser, $varDate & "b", $varTime) _DisableButtons() Case $guiButton3 $varDate = _DateConvert(GUICtrlRead($guiDate)) $varCurrentUser = GUICtrlRead($guiCombo) $varTime = _ReadTime() IniWrite($filTimeData, $varCurrentUser, $varDate & "c", $varTime) _DisableButtons() Case $guiButton4 $varDate = _DateConvert(GUICtrlRead($guiDate)) $varCurrentUser = GUICtrlRead($guiCombo) $varTime = _ReadTime() IniWrite($filTimeData, $varCurrentUser, $varDate & "d", $varTime) _DisableButtons() Case $guiCombo _EnableButtons() _DisableButtons() Case $guiDate _EnableButtons() _DisableButtons() EndSwitch WEnd Func _PopulateCombo($varName) GUICtrlSetData($guiCombo, "") $arrNames = IniReadSectionNames($filTimeData) $strNames = StringTrimLeft(_ArrayToString($arrNames, "|"), 2) If $varName = "NoName" Then $varName = $arrNames[1] EndIf GUICtrlSetData($guiCombo, $strNames, $varName) EndFunc Func _AddName() $varName = Inputbox("Enter A Name", "Please enter a name to add to the timeclock:") If $varName <> "" Then IniWriteSection($filTimeData, $varName, "") EndIf Return($varName) EndFunc Func _DisableButtons() $varCurrentUser = GUICtrlRead($guiCombo) $varDate = _DateConvert(GUICtrlRead($guiDate)) $varTime1 = _FormatTime(IniRead($filTimeData, $varCurrentUser, $varDate & "a", "null")) $varTime2 = _FormatTime(IniRead($filTimeData, $varCurrentUser, $varDate & "b", "null")) $varTime3 = _FormatTime(IniRead($filTimeData, $varCurrentUser, $varDate & "c", "null")) $varTime4 = _FormatTime(IniRead($filTimeData, $varCurrentUser, $varDate & "d", "null")) If $varTime1 <> "null" Then GUICtrlSetState ($guiButton1, $Gui_Disable) GUICtrlSetData($guiButton1, $varTime1) EndIf If $varTime2 <> "null" Then GUICtrlSetState ($guiButton2, $Gui_Disable) GUICtrlSetData($guiButton2, $varTime2) EndIf If $varTime3 <> "null" Then GUICtrlSetState ($guiButton3, $Gui_Disable) GUICtrlSetData($guiButton3, $varTime3) EndIf If $varTime4 <> "null" Then GUICtrlSetState ($guiButton4, $Gui_Disable) GUICtrlSetData($guiButton4, $varTime4) EndIf EndFunc Func _EnableButtons() GUICtrlSetState ($guiButton1, $Gui_Enable) GUICtrlSetState ($guiButton2, $Gui_Enable) GUICtrlSetState ($guiButton3, $Gui_Enable) GUICtrlSetState ($guiButton4, $Gui_Enable) GUICtrlSetData($guiButton1, "Clock In") GUICtrlSetData($guiButton2, "Begin Lunch") GUICtrlSetData($guiButton3, "Lunch Over") GUICtrlSetData($guiButton4, "Go Home") EndFunc Func _DateConvert($varDate) $arrDate = StringSplit($varDate, "/", 2) $varDate = StringFormat("%02d", $arrDate[2]) & StringFormat("%02d", $arrDate[0]) & StringFormat("%02d",$arrDate[1]) Return $varDate EndFunc Func _DeleteUsers() $guiDelUserForm = GUICreate("Delete User", 220, 200) $guiListview = GUICtrlCreateListView("Name|", 10, 10, 200, 150, $WS_BORDER, $LVS_EX_FULLROWSELECT + $LVS_EX_CHECKBOXES) _GUICtrlListView_SetColumnWidth($guiListView,0,180) $guiButton7 = GUICtrlCreateButton("Delete", 75, 170, 70, 20) GUISetState(@SW_SHOW) $arrNames = IniReadSectionNames($filTimeData) For $i = 1 To $arrNames[0] GUICtrlCreateListViewItem($arrNames[$i], $guiListview) Next While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($guiDelUserForm) ExitLoop Case $guiButton7 $varConfirm = MsgBox(49, "Caution", "Are you sure you want to delete selected userss?" & @crlf & "Deleting users will also delete the timeclock data associated with them.") If $varConfirm = 1 Then $varItemCount = _GUICtrlListView_GetItemCount ( $guiListView ) For $i = 1 To $varItemCount If _GUICtrlListView_GetItemChecked($guiListview, $i - 1) = "True" Then $varName = _GUICtrlListView_GetItemTextString ($guiListview, $i - 1) IniDelete($filTimeData, $varName) EndIf Next EndIf _PopulateCombo("NoName") _EnableButtons() _DisableButtons() GUIDelete($guiDelUserForm) ExitLoop EndSwitch WEnd EndFunc Func _ReadTime() $varTime = GUICtrlRead($GuiLabel) If StringRight($varTime, 2) = "am" OR StringRight($varTime, 2) = "pm" Then If StringRight($varTime, 2) = "pm" Then $varHour = StringLeft($varTime, 2) + 12 Else $varHour = StringLeft($varTime, 2) EndIf $varMin = StringMid($varTime, 3, 2) Else $varHour = StringLeft($varTime, 2) $varMin = StringMid($varTime, 3, 2) EndIf $varTime = $varHour & ":" & $varMin Return $varTime EndFunc Func _FormatTime($varTime) If $varTime <> "null" Then $varHour = StringLeft($varTime, 2) $varMin = StringRight($varTime, 2) If $varTimeFormat = "ampm" Then If $varHour < 13 Then $varCurrentTime = $varHour & ":" & $varMin & " am" Else $varCurrentTime = $varHour - 12 & ":" & $varMin & " pm" EndIf Else $varCurrentTime = $varHour & ":" & $varMin EndIf Else $varCurrentTime = "null" EndIf Return $varCurrentTime EndFunc1 point -
GDPR - string anonymisation function
mLipok reacted to abberration for a topic
Never heard of GDPR, but I found this article that might help: https://gdpr.report/news/2017/09/28/data-masking-anonymization-pseudonymization/ It looks like data masking is allowed, but the article didn't specify how much of it needs to be masked.1 point -
Making a time logger
JackCaldwell reacted to Earthshine for a topic
start with the _Timer functions in the help file. As a rule, the help files is where you start when you are new.1 point -
LAST VERSION - 1.3 28-Oct-11 The library allows to create HotKey Input control by using the low-level keyboard hook. This UDF is designed specially to support the >HotKey UDF library but it can be used separately. Please look at the example below to understand how it works. For more information, see detailed descriptions of all functions inside the library. Available functions HotKeyInput UDF Library v1.3 Previous downloads: 2564 HotKeyInput.au3 Example #Include <GUIConstantsEx.au3> #Include <HotKeyInput.au3> Global $Form, $HKI1, $HKI2, $Button, $Text $Form = GUICreate('Test', 300, 160) GUISetFont(8.5, 400, 0, 'Tahoma', $Form) $HKI1 = _GUICtrlHKI_Create(0, 56, 55, 230, 20) $HKI2 = _GUICtrlHKI_Create(0, 56, 89, 230, 20) ; Lock CTRL-ALT-DEL for Hotkey Input control, but not for Windows _KeyLock(0x062E) GUICtrlCreateLabel('Hotkey1:', 10, 58, 44, 14) GUICtrlCreateLabel('Hotkey2:', 10, 92, 44, 14) GUICtrlCreateLabel('Click on Input box and hold a combination of keys.' & @CR & 'Press OK to view the code.', 10, 10, 280, 28) $Button = GUICtrlCreateButton('OK', 110, 124, 80, 23) GUICtrlSetState(-1, BitOR($GUI_DEFBUTTON, $GUI_FOCUS)) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button $Text = 'Hotkey1: 0x' & StringRight(Hex(_GUICtrlHKI_GetHotKey($HKI1)), 4) & ' (' & GUICtrlRead($HKI1) & ')' & @CR & @CR & _ 'Hotkey2: 0x' & StringRight(Hex(_GUICtrlHKI_GetHotKey($HKI2)), 4) & ' (' & GUICtrlRead($HKI2) & ')' MsgBox(0, 'Code', $Text, 0, $Form) EndSwitch WEnd1 point
-
This is a small UDF for Hotkey (msctls_hotkey32) which allow to: 1) Create HotKey control (msctls_hotkey32) 2) Get and value(number) from HotKey control 3) Set value(number) in HotKey control 4) Get Hotkey format from Hotkey control which can be used in function HotKeySet 5) Get normal format from Hotkey control 6) Set rules for Hotkey control Thanks to Achilles for his Hotkey example which help me to do this UDF. Current functions: _GuiCtrlHotKey_Create - Create a HotKey control _GuiCtrlHotKey_GetHotkey - Get number identifying pressed keys in HotKey control _GuiCtrlHotKey_SetHotkey - Set Hotkey in HotKey Control _GuiCtrlHotKey_GetFormat - Get Normal and HotKey format from unique HotKey number _GuiCtrlHotKey_GetFullInfo - Get Normal and HotKey format and also HotKey number from HotKey Control _GuiCtrlHotKey_SetRules - Set rules for HotKey control HotKey example (hotkey_example.au3): #include-once #include <hotkeys.au3> #cs -----------Flags for rules:----------- Invalid keys: (used when need to block combination of keys) $HKCOMB_NONE - Unmodified keys; it is blocked nothing, it is used only for "Modifiers" $HKCOMB_S - SHIFT $HKCOMB_C - CTRL $HKCOMB_A - ALT $HKCOMB_SC - SHIFT+CTRL $HKCOMB_SA - SHIFT+ALT $HKCOMB_CA - CTRL+ALT $HKCOMB_SCA - SHIFT+CTRL+ALT Modifiers: (this modifiers are established when pressed "Invalid keys") $HOTKEYF_SHIFT - SHIFT $HOTKEYF_CONTROL - CTRL $HOTKEYF_ALT - ALT $HOTKEYF_EXT - Extra key ---------------------------------------------- #ce Global $HotKey $gui_Main = GUICreate('Get Hotkey', 220, 90) $bt = GUICtrlCreateButton('See Value', 10, 50, 200, 30); GUICtrlSetState(-1, $GUI_DEFBUTTON) $hWnd=_GuiCtrlHotKey_Create($gui_Main,10,10,180,25,0); <= Create Hotkey ;_GuiCtrlHotKey_SetRules($hWnd,$HKCOMB_S) ; <= Set rules for Hotkey (blocks shift-key) ;_GuiCtrlHotKey_SetRules($hWnd,$HKCOMB_C,BitOr($HOTKEYF_CONTROL,$HOTKEYF_ALT)); <= Set rules for Hotkey (pressing ctrl = ctrl+alt) Send("{NUMLOCK on}") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $bt $hotkey_info=_GuiCtrlHotKey_GetFullInfo($hWnd); <= Get Info about Hotkey If $hotkey_info<>-1 Then MsgBox(64,"Information","HotKey format: " & $hotkey_info[0] & _ @CRLF & "Normal format: " & $hotkey_info[1] & _ @CRLF & "HotKey value: " & $hotkey_info[2]) HotKeySet($hotkey); clear previous hotkey $hotkey=$hotkey_info[0] HotKeySet($hotkey,"hello") Endif EndSwitch WEnd Func hello() MsgBox(64,"","Hello!") EndFunc Example: hotkey_example.au3UDF: hotkeys.au31 point
-
Good job. Here is my version of Hotkeys Input Control UDF Library.1 point
-
It still does not affect @error and @extended. Saludos0 points
-
Maybe something like: Local $oButtons = _IETagNameAllGetCollection($oIE, "button") If IsObj($oButtons) Then For $oButton In $oButtons If $oButton.className = "btn btn-success" Then _IEAction($oButton, "click") ExitLoop EndIf Next EndIf0 points