Leaderboard
Popular Content
Showing content with the highest reputation on 07/20/2020 in all areas
-
To make it easier to maintain the UIA code, I've decided to split the code this way: This new thread is used for the actual UIA UDFs. Ie. the files stored in Includes folders and named UIA_*.au3 or UIAEH_*.au3. The UIASpy thread contains only code that is used directly in the UIASpy GUI, but not the UIA UDFs in this new thread. Using UIA Code contains only example code, but neither UIA UDFs nor UIASpy. UIA Events contains GUI code to detect events and it contains example code, but neither UIA UDFs nor UIASpy. This means that every time the code in the UDF files in this new thread is updated (eg. because of Windows 10 feature updates twice a year), you must install the files in the Includes folders in the other threads yourself. The easiest way is simply to copy all UDF files to the Includes folders. UDF Files CUIAutomation2.au3 - UIA constants for Windows 7 used in the first examples CUIAutomation2-a.au3 - The original UIA constants for Windows 7 from junkew's thread UIA_AccVars.au3 - Used to calculate properties of type VT_UNKNOWN, copied and modified from this thread UIA_Constants.au3 - UIA constants (copied from UIA header files) up to and including Windows 10 1809 UIA_ConstNames.au3 - Contains functions for converting UIA constants from values to names UIA_Functions.au3 - A collection of small utility functions UIA_Functions-a.au3 - First version of utility functions UIA_ObjectFromTag.au3 - Creates callback objects used in event handlers, copied and modified from this post by trancexx UIA_SafeArray.au3 - Constants and functions to handle safearrays, copied from this thread UIA_Variant.au3 - Constants and functions to handle variants, copied from this thread UIAEH_AutomationEventHandler.au3 - Implements the AutomationEventHandler UIAEH_FocusChangedEventHandler.au3 - Implements the FocusChangedEventHandler UIAEH_NotificationEventHandler.au3 - Implements the NotificationEventHandler, published in Windows 10 1709 UIAEH_PropertyChangedEventHandler.au3 - Implements the PropertyChangedEventHandler UIAEH_StructureChangedEventHandler.au3 - Implements the StructureChangedEventHandler Folders The UI Automation projects can be stored in a folder structure this way: UI Automation\ Code\ - Using UIA code Events\ - UIA events Spy tool\ - UIASpy.au3 UDFs\ - UDF files The UDF files must be installed in Includes\ in the first three folders. Threads UIASpy - UI Automation Spy Tool is a GUI tool that provides information about windows and controls and their interconnection and provides functionality to generate sample code. UIASpy is essential for creating UI Automation code. In Using UI Automation Code in AutoIt you can find and download examples and read information about using UIA code. UI Automation Events is about implementing event handlers and includes GUIs to detect events. IUIAutomation MS framework automate chrome, FF, IE, .... created by junkew August 2013 is the first AutoIt thread on UIA code. Zip-file The zip contains source code for the UDF files. You need AutoIt 3.3.12 or later. Tested on Windows XP, Windows 7 and Windows 10. Comments are welcome. Let me know if there are any issues. UIAIncludes.7z1 point
-
Differentiate if running as local admin vs domain admin?
Earthshine reacted to Subz for a topic
_AD_IsMemberOf("Domain Admins", @Username) is the easiest method imho.1 point -
Differentiate if running as local admin vs domain admin?
Earthshine reacted to TheXman for a topic
You should be able to get the information by running the WHOAMI console command with the appropriate switch(es).1 point -
I create a another user and then it works perfect the problem is ö so vbs script can not process the letter ö so that is no problem with your script thanks för you take time to find this solution..1 point
-
Unfortunately, Swedish is not my mother tongue. "det gär inte att skapa genvägen" Google has translated the following for me: "it does not like to create the shortcut" I interpret that the attempt to save the shortcut in VBscript was unsuccessful. I suspect that VBScipt cannot process the letter 'ö' in Borje. Just create another user without special characters and try it there.1 point
-
I didn't run his code, and I was very tired last night, and probably shouldn't have bothered replying, but he asked me in HexChat and I remembered I had some code from years ago that probably did close to what he wanted ... it was very specific though and didn't need to cater for regions. In my code in the 4th post (my second reply) you can see I use the following. GUICtrlSetData($Date_to, $now) GUICtrlSetData($Date_totime, $time) And you can see from earlier in the code, where I set the controls up. $style = "yyyy/MM/dd" GUICtrlSendMsg($Date_to, $DTM_SETFORMAT_, 0, $style) $style = "HH:mm:ss" GUICtrlSendMsg($Date_totime, $DTM_SETFORMAT_, 0, $style) Be aware though, that I did this a few years ago with an older version of AutoIt.1 point
-
Like I expected, I overlooked something simple, I had the date in the wrong order in my example, I was using DMY instead of YMD. #include <DateTimeConstants.au3> #include <GUIConstantsEx.au3> #include <GuiDateTimePicker.au3> #include <MsgBoxConstants.au3> Example() Func Example() GUICreate("My GUI get date", 200, 200, 800, 200) Local $idDate = GUICtrlCreateDate("", 10, 10, 185, 20, $DTS_TIMEFORMAT) Local $hDate = GUICtrlGetHandle($idDate) ; to select a specific default format Local $sStyle = "HH:mm:ss" GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, $sStyle) ; Set time Local $aDate[7] = [False, 2020, 1, 1, 13, 33, 37] Local $bRet = _GUICtrlDTP_SetSystemTime($hDate, $aDate) ConsoleWrite('_GUICtrlDTP_SetSystemTime returned ' & ($bRet ? 'success' : 'failure') & @CRLF) GUISetState(@SW_SHOW) ; Loop until the user exits. While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd MsgBox($MB_SYSTEMMODAL, "Time", GUICtrlRead($idDate)) EndFunc ;==>Example This works perfectly and it doesn't even depend on strings, let alone have regional issues! I am happy Edit: Just noticed another helpful tidbit, remember to set the first element of the time/date array to False, otherwise it won't work! At-least it did not for me.1 point
-
You may want to try hooking to the control using either : _WinAPI_SetWindowLong with the $GWL_WNDPROC option or SetWindowSubclass Win32 API In both cases, by hooking to the message WM_KEYDOWN, you should get better response time...I think.1 point
-
GUICtrlSetBkColor($color_block0, '0x00' & $originalColor) GUICtrlSetBkColor($color_block0, '0x' & $originalColor) In the last code above I see no difference in sending the above to the Label Control for the colors. The first two digits are for the transparency but I see no difference with either version above. I should though, technically. In other code I have written it is important to add the first two 00's.. some controls you have to use FF's I guess the transparency values are reversed on some controls? But if you do this GUICtrlSetBkColor($color_block0, $originalColor) Color is WAY off. Interesting experiment results.1 point
-
I have played a bit with the code, and finally i found a solution. You can do it, as shark007 said, by substracting/adding 30 from r,g and b components. Or you can calculate the percentage of the color, and adding it to the number. The discovery was that the HEX() does not work well with floating point numbers. Here are my playings with it: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <Color.au3> #include <ColorConstants.au3> HotKeySet("{ESC}", "close") Global $GUI = GUICreate("", 570, 245) Global $color_block0 = GUICtrlCreateLabel('', 10, 20, 50, 50) Global $color_block1 = GUICtrlCreateLabel('', 120, 20, 100, 100) Global $color_block2 = GUICtrlCreateLabel('', 230, 20, 100, 100) Global $color_block3 = GUICtrlCreateLabel('', 340, 20, 100, 100) Global $color_block4 = GUICtrlCreateLabel('', 450, 20, 100, 100) Global $BTN = GUICtrlCreateButton("Doit", 5, 130, 50, 20) Global $BTN1 = GUICtrlCreateButton("Random Color", 145, 130, 100, 20) GUISetState(@SW_SHOW) Global $shadeV Global $shade1 Global $shade2 Global $shade3 Global $shade4 Global $originalColor Global $rgb[3] Global $hexRGB Global $CR, $CB, $CG $rgb[0] = 255 $rgb[1] = 200 $rgb[2] = 0 $hexRGB = "0x" & Hex($rgb[0], 2) & Hex($rgb[1], 2) & Hex($rgb[2], 2) $originalColor = $hexRGB ConsoleWrite("ORIGINAL" & @CRLF) ConsoleWrite("HEX RGB: " & $hexRGB & @CRLF) ConsoleWrite("RGB: " & $rgb[0] & ', ' & $rgb[1] & ', ' & $rgb[2] & @CRLF & @CRLF) $shadeV =0.2 TheRGB() ApplyColors() While 1 Sleep(10) Local $g = GUIGetMsg() If $g = $BTN Then TheRGB() ApplyColors() EndIf If $g = $BTN1 Then $rgb[0] = Int(Random(0, 255)) $rgb[1] = Int(Random(0, 255)) $rgb[2] = INT(Random(0, 255)) $hexRGB = "0x" & Hex($rgb[0], 2) & Hex($rgb[1], 2) & Hex($rgb[2], 2) $originalColor = $hexRGB ConsoleWrite ("-> "& $hexRGB) TheRGB() ApplyColors() EndIf WEnd Func close() Exit EndFunc ;==>close Func TheRGB() $shade1 = CalcRGB($rgb[0], $rgb[1], $rgb[2]) $shade2 = CalcRGB($CR, $CG, $CB) $shade3 = CalcRGB($CR, $CG, $CB) $shade4 = CalcRGB($CR, $CG, $CB) $rgb[0] = $CR $rgb[1] = $CG $rgb[2] = $CB EndFunc ;==>TheRGB Func CalcRGB($r, $g, $b) ;~ $shadeV=30 ; Alternative calculation ;~ $CR = $r - $shadeV ;~ $CG = $g - $shadeV ;~ $CB = $b - $shadeV $CR = $r + int((255-$r)* $shadeV) $CG = $g + int((255-$g)* $shadeV) $CB = $b + int((255-$b)* $shadeV) If $CR > 255 Then $CR = 255 If $CG > 255 Then $CG = 255 If $CB > 255 Then $CB = 255 If $CR < 0 Then $CR = 0 If $CG < 0 Then $CG = 0 If $CB < 0 Then $CB = 0 ConsoleWrite(" -- " & $CR & " " & $CG & " " & $CB & @CRLF) ConsoleWrite(Hex($CR, 2) & " " & Hex($CG, 2) & " " & Hex($CB, 2) & @CRLF & @CRLF) Return "0x" & Hex($CR, 2) & Hex($CG, 2) & Hex($CB, 2) EndFunc ;==>CalcRGB Func ApplyColors() GUICtrlSetBkColor($color_block0, $originalColor) GUICtrlSetBkColor($color_block1, $shade1) GUICtrlSetBkColor($color_block2, $shade2) GUICtrlSetBkColor($color_block3, $shade3) GUICtrlSetBkColor($color_block4, $shade4) EndFunc ;==>ApplyColors1 point
-
The following works for me... most of the time. you need to break down the 6 digit hexidecimal color code to its rgb components. To do that, split the 6 digit hex code into its 3 separate (2 digit) RGB components Local $StartColor = 'insert your 6 digit hex here' Local $lString = StringLeft($StartColor, 2) Local $mString = StringMid($StartColor, 3, 2) Local $rString = StringRight($StartColor, 2) Then convert each of the 2 digit hex results to decmal and add ( to lighten) or subtract ( to darken) in the range of 0-255 The greater the number used, the greater the possibility of changing the color completely. Local $reddec = Dec($lString) + 30 Local $greendec = Dec($mString) + 30 Local $bluedec = Dec($rString) + 30 Then take each of these 3 decimal rgb results and convert them back to a 6 digit hexidecmal number Local $newcolor = Hex($reddec, 2) & Hex($greeendec, 2) & Hex($bluedec, 2) $newcolor is the slightly modified color you seek.1 point
-
The shortcut with the icon is now default. If you don't like the shortcuts, just delete them. New version is in the first post. @Borje Just send me a virtual cup of coffee or click the like/thanks at the rigth side. 😀1 point
-
Using UI Automation Code in AutoIt
GicuPiticu reacted to LarsJ for a topic
How to topics, 1 - 7 How to topics is a guide to use UIASpy to identify windows and controls and to create sample code to obtain information and perform actions. Topics 1 - 7: Introductory topics Top of next post (bottom of this post) Topics 8 - 15: Sample code creation Topics 16 - 17: Other How to topics How to perform UI Automation tasks How to use UIASpy to detect elements How to use UIASpy to create sample code How to create sample code through Detail info page How to create sample code through Sample code menu How to create sample code by copying listview rows How to create objects with ObjCreateInterface How to create UI Automation main objects How to identify and find application top window How to identify and find UI elements (controls) How to get UI element property values How to create element action objects How to get pattern property values How to perform element actions How to create executable code How to perform a mouse click in middle of bounding rectangle How to perform a control click via PostMessage and $UIA_AutomationIdPropertyId 1. How to perform UI Automation tasks UI Automation tasks are almost always performed in a top-down and step-by-step procedure. The task is divided into smaller sub-tasks that cannot be further divided. Each sub-task is performed in 2-4 steps. Clicking a button in a window is divided into 2 sub-tasks: Identify the window Identify and click the button The window that's identified in the first sub-task is used to identify the button in the second sub-task. Identifying the window is done in 2 steps: Create condition to identify the window Find the window based on the condition Identifying and clicking the button is done in 4 steps: Create condition to identify the button Find the button based on the condition Create an action to click the button Perform the action and click the button Here, the procedure is illustrated schematically: UIASpy can provide information to identify windows and controls and can generate sample code to implement the 2-4 steps. 2. How to use UIASpy to detect elements Open UIASpy. Click Left pane | Delete top windows to delete all treeview top windows. To detect a window, place the mouse cursor over the window title bar and press F2. To detect a control, place the mouse cursor over the control and press F1. Switch back to UIASpy window. 3. How to use UIASpy to create Sample code Through Sample code creation, you can more or less create all code in a simple automation task: Create UI Automation initial code Create condition and find application window Create condition and find control in window Get information about windows and controls Create pattern objects to perform actions Get information related to pattern objects Perform actions with pattern object methods Add a Sleep() statement if necessary In short, there are 3 ways to create sample code with UIASpy: Use the UIASpy Sample code main menu Right click a selected row in the Detail info listview page and Click Create sample code to create code based on selected row(s) Right click a selected row in the Detail info listview page or in a Sample code listview page and Click Copy to sample code to copy variable names and values to sample code (preferred) or Click Copy selected items to copy variable names and values to clipboard Then paste the code into an editor. 4. How to create sample code through Detail info page The Detail info listview page is also the default listview page. This makes sample code creation easy and fast. You can find a brief description with pictures and code snippets in the UIASpy thread. But not all code can be created this way. In many cases, there is a need to use the Sample code main menu. 5. How to create sample code through Sample code menu Much more code can be created through the Sample code menu than through the Detail info page. In addition, the menu can be used to set Sample code options and for Sample code maintenance. You can find a brief description with a picture in the UIASpy thread. 6. How to create sample code by copying listview rows To copy information from the Detail info listview page or a Sample code listview page into the editor right-click a selected row and click Copy to sample code: Paste the code into the editor: ; --- Copy element info --- ; $UIA_NativeWindowHandlePropertyId 0x00090244 7. How to create objects with ObjCreateInterface All objects needed in most automation tasks can be created using UIASpy sample code features. This is by far the easiest way to create the objects. There is really no need to create the objects in other ways. Top of post1 point -
Sample code creation through Detail info listview page The Detail info listview page is also the default listview page. This makes sample code creation easy and fast. But not all code can be created this way. In many cases, there is a need to use the Sample code main menu. Sample code is created by selecting one or more rows in a single listview group. Right-click a selected row and click Create sample code. The code is displayed in the listview code page. Click Create sample code in the picture above to generate this code: ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition0 $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "Notepad", $pCondition0 ) If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF ) ConsoleWrite( "$pCondition0 OK" & @CRLF ) Local $pWindow, $oWindow $oDesktop.FindFirst( $TreeScope_Descendants, $pCondition0, $pWindow ) $oWindow = ObjCreateInterface( $pWindow, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow ) Then Return ConsoleWrite( "$oWindow ERR" & @CRLF ) ConsoleWrite( "$oWindow OK" & @CRLF ) Click the selected treeview item in the left pane window to return to the detail information and add more sample code. Or paste the code into the code editor. Create sample code also copies the code to clipboard. Only selected rows that specifically belongs to the listview group in which a row is right-clicked are included in sample code. The only exception to this are the groups "Element Properties (identification)" and "Element Properties (session unique)". For these two groups, selected rows from both groups are included in sample code. This makes it possible to use session unique properties in window identification: Click Create sample code in the picture to generate this code: ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition0, $pCondition1, $pAndCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "Notepad", $pCondition0 ) $oUIAutomation.CreatePropertyCondition( $UIA_NativeWindowHandlePropertyId, 0x0000000000050314, $pCondition1 ) $oUIAutomation.CreateAndCondition( $pCondition0, $pCondition1, $pAndCondition1 ) If Not $pAndCondition1 Then Return ConsoleWrite( "$pAndCondition1 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition1 OK" & @CRLF ) Local $pWindow, $oWindow $oDesktop.FindFirst( $TreeScope_Descendants, $pAndCondition1, $pWindow ) $oWindow = ObjCreateInterface( $pWindow, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow ) Then Return ConsoleWrite( "$oWindow ERR" & @CRLF ) ConsoleWrite( "$oWindow OK" & @CRLF ) See Automating Notepad with sample code - step by step and Automating Notepad with sample code - all at once for examples of creating sample code.1 point