
BakedCakes
Active Members-
Posts
29 -
Joined
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
BakedCakes's Achievements
-
Au3toCmd -- Avoid false virus positives. (Version: 2022.09.01)
BakedCakes replied to Exit's topic in AutoIt Example Scripts
When running Deskotp\one-two\three\program.cmd, the cmd exits without writing anything to stdout and stderr. However, it works correctly if I put program.cmd directly in Desktop. Looks like it doesn't like nested folder with dashes in them?- 176 replies
-
- a3x
- false positives
-
(and 3 more)
Tagged with:
-
Check if only elevated users can modify a folder
BakedCakes replied to BakedCakes's topic in AutoIt General Help and Support
Nevermind, reading a bit more into DACL on msdn: explicit and inherited ACEs, the related functions, SIDs, account names, etc. it sounds a bit too involved than I expected it to be and easy to make a mistake. Instead of dealing with ACLs, I will just prompt the user that the program will move itself into Program Files if they want to enable the Run at Startup. Program Files already has a secure DACL set on it, which a created subfolder would inherit, so I can make the script copy itself in there, run the copied script and make the initial script exit and self-delete itself via a batch script. -
Check if only elevated users can modify a folder
BakedCakes replied to BakedCakes's topic in AutoIt General Help and Support
Setting ACL is not something I want, I want to just read ACL and tell the user to move the exe to somewhere more secure. Was hoping this could be done without including giant UDFs or external binaries. -
Given a folder path, I want to make sure that only elevated users are able to modify the folder and the files directly in it. As to why -- my script runs as Admin via #RequireAdmin and it has an option to run at startup as Admin, which it achieves by setting up an autorun task with Task Scheduler. The issue is, if the user enables the Run at Startup when the script executable is in a unprotected folder, e.g. the Desktop, any other process can overwrite the script.exe with a malicious executable, which would automatically run as Admin on the next startup, i.e. it this can be used as a privilege escalation vulnerability. Thus I want the user to be able to enable the Run at Startup only when the executable is in a secured folder. It sounds like the right approach would be to check folder's ACL, but unless I have missed something, there don't seem to be any functions listed in the help file that can be used to read folder's ACLs?
-
inna reacted to a post in a topic: I can WinActivate osk but I cannot ControlClick on it
-
I can WinActivate osk but I cannot ControlClick on it
BakedCakes replied to inna's topic in AutoIt General Help and Support
Add #RequireAdmin at the beginning so that the script runs as Administrator, OSK seems to be a privileged process so a non-admin process can't interact with it. -
Set #AutoIt3Wrapper_Res_Language= to a number from https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource#remarks under langID e.g. #AutoIt3Wrapper_Res_Language=0x0409 for the US English. You can find all the AutoIt3Wrapper pragmas in C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\Directives.au3
-
On Windows 10 the app icon + Description field are used in TrayTip to indicate which application that has made the TrayTip. It would make sense for it to use ProductName, rather than Description. Any way I can make it use ProductName instead? #AutoIt3Wrapper_Res_ProductName=My App Name #AutoIt3Wrapper_Res_Description=Shows a traytip TrayTip("Attention!", "Have a nice day!", 10) Sleep(5000) This should display "My App Name" instead of "Shows a traytip". To quote MSDN https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource: You wouldn't expect to see "Keyboard Driver for AT-Style Keyboards" in there, instead you'd expect to see something like "Logitech Hub" -- a ProductName. @Jos Would this qualify as a bug in AutoIt?
-
BakedCakes reacted to a post in a topic: Object equality test isn't working, i.e. $oObject == $oObject ; ==> False!?
-
Why do event handlers call $oSender.AddRef() but do not call the matching $oSender.Release() once they are done with the object? Doesn't that lead to a memory leak?
-
When you create an Object and compare it with itself, you get False. To borrow part of an example from the ObjCreateInterface() help page: Example() Func Example() Local Const $sCLSID_TaskbarList = "{56FDF344-FD6D-11D0-958A-006097C9A090}" Local Const $sIID_ITaskbarList = "{56FDF342-FD6D-11D0-958A-006097C9A090}" Local Const $sTagITaskbarList = "HrInit hresult(); AddTab hresult(hwnd); DeleteTab hresult(hwnd); ActivateTab hresult(hwnd); SetActiveAlt hresult(hwnd);" Local $oTaskbarList = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList, $sTagITaskbarList) ConsoleWrite(($oTaskbarList == $oTaskbarList) & @CRLF) ; ==> False EndFunc I expected object instances to support an equality test as they could be compared by their internal pointer values, but instead they don't seem to support the equality test at all?
-
I was able to find some extra controls by calling _WinAPI_EnumChildWindows() on the main window and then calling it on each of the returned controls/windows (controls like a button, a label, etc. are just windows in win32). Turns out that the UIA element tree doesn't necessity map 1:1 to controls, there might be just one control that is reporting to be an entire subtree of UIA because it draws the UI on its own. I was incorrect to assume that it's a 1:1 mapping. Oh, and calling ControlSend() on one of those extra controls did what I wanted. That was it, getting LegacyIAccessiblePattern of a tab and calling DoDefaultAction() on it makes Chrome switch to that tab. I thought that Legacy* methods were deprecated and likely not working, seeing how it's all grayed out in UIA Spy (while non-Legacy are in bright yellow), but no, apparently they do work. Thank you for all of the suggestions, @junkew, my questions have been resolved
-
So... Are you saying that it's not possible to get Control ID of elements that don't have anything identifiable, like $UIA_ClassNamePropertyId or $UIA_NativeWindowHandlePropertyId or $UIA_AutomationIdPropertyId, like that Pane in my screenshot? My goal here is to send a hotkey to a specific control, e.g. Ctrl+Shift+T. Can this be done without mixing UIA and AutoIt Control Ids? The only way of doing this that I know of is to use AutoIt's ControlSend(), which requires such mixing. Is there a purely UI Automation way of sending a hotkey combination to an element? Or perhaps there is a purely Control Id way of doing this? The only reason why I'm trying to figure out the Control Id of a control using UIA is because I'm unable to get it via classical means -- I'm unable to get the Class, ClassnameNN, etc. of the control using AutoIt Window Info, as it's picking up another control that is overlayered above the one I want to select, even when toggling the "Use Spy++ control detection logic" option. Btw, this is a separate question from the one about switching tabs in Chrome, just so that we are on the same page. What do you mean by a click? Do you mean a AutoIt's MoseClick() or some way of clicking via the UI Automation framework? Doing a click via AutoIt's MouseClick() or UIA_MoseClick() from UIA UDF's UIA_Functions.au3 (it too uses AutoIt's MouseClick() inside) would not work, as the tab might be off the screen. If you have too many tabs, they overflow off-screen (off-window?) and can't be clicked on as they are not visible. Doing a click via UI Automation's Invoke() method would not work either, as the TabItem does not implement the InvokePattern interface. It does, however, implement SelectionItemPattern interface and the currently active tab has $UIA_SelectionItemIsSelectedPropertyId set to True, while the rest of the TabItems have it set to False, but calling Select() or even AddToSelection() on a currently unselected tab doesn't seem to do anything -- Chrome still displays the tab that it has been displaying. So I wonder if I'm doing something wrong (see the code in the previous post) or perhaps Chrome simply doesn't implement TabItem's Select() to do anything meaningful like switching tabs? I specifically want to automate Chrome tab switching via the UI Automation framework. In an earlier post, Decibel has shown that it's possible to open a new tab by calling Invoke() on the New Tab button, so I thought it would be possible to interact with other UI elements too, for example tabs.
-
Another question: is it possible to get Control ID of elements that don't have anything identifiable, like $UIA_ClassNamePropertyId or $UIA_NativeWindowHandlePropertyId or $UIA_AutomationIdPropertyId? AutoIt docs for Controls say: So if all controls have control ids, I should be able to somehow acquire them? What I want to do is call AutoIt's ControlSend() on a control, for example, this pane:
-
Trying to figure out how to switch tabs in Chrome. For some reason calling Select() on a Chrome tab doesn't make Chrome show that tab, it still shows the previously selected tab. #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=y ; If target application is running as 64 bit code #include "UIA_Constants.au3" Opt( "MustDeclareVars", 1 ) Opt("WinTitleMatchMode", 2);Match any substring in the title (case-sensitive) Example() Func Example() Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtag_IUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) Local $hWindow = WinGetHandle("[TITLE:Google Chrome; CLASS:Chrome_WidgetWin_1]") ConsoleWrite( "$hWindow: " & $hWindow & ", " & WinGetTitle($hWindow) & @CRLF ) Local $pElement, $oChrome $oUIAutomation.ElementFromHandle($hWindow, $pElement) $oChrome = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement9) If Not IsObj( $oChrome ) Then Return ConsoleWrite( "$oChrome ERR" & @CRLF ) ConsoleWrite( "$oChrome OK" & @CRLF ) Local $pCondition1, $pCondition2, $pAndCondition2 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_TabItemControlTypeId, $pCondition1 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "New Tab", $pCondition2 ) $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pAndCondition2 ) If Not $pAndCondition2 Then Return ConsoleWrite( "$pAndCondition2 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition2 OK" & @CRLF ) Local $pTabItem1, $oTabItem1 $oChrome.FindFirst( $TreeScope_Descendants, $pAndCondition2, $pTabItem1 ) $oTabItem1 = ObjCreateInterface( $pTabItem1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oTabItem1 ) Then Return ConsoleWrite( "$oTabItem1 ERR" & @CRLF ) ConsoleWrite( "$oTabItem1 OK" & @CRLF ) Local $pSelectionItemPattern1, $oSelectionItemPattern1 $oTabItem1.GetCurrentPattern( $UIA_SelectionItemPatternId, $pSelectionItemPattern1 ) $oSelectionItemPattern1 = ObjCreateInterface( $pSelectionItemPattern1, $sIID_IUIAutomationSelectionItemPattern, $dtag_IUIAutomationSelectionItemPattern ) If Not IsObj( $oSelectionItemPattern1 ) Then Return ConsoleWrite( "$oSelectionItemPattern1 ERR" & @CRLF ) ConsoleWrite( "$oSelectionItemPattern1 OK" & @CRLF ) $oSelectionItemPattern1.Select() ConsoleWrite( "$oSelectionItemPattern.Select()" & @CRLF ) EndFunc