Jump to content

TheDcoder

Active Members
  • Posts

    7,103
  • Joined

  • Days Won

    88

Everything posted by TheDcoder

  1. For reference: #3571: (Beta) Map values are erased
  2. The UDF converts them into native data-types before returning them
  3. @Decibel Use Ubound($aCars) to get count of an array.
  4. @mLipok Thanks for keeping the UDF alive and updated . Just wanted to let you know that _XML_Validate_File is incorrectly mentioned as _XML_ValidateFile in the current functions list.
  5. I was busy so didn't bother, I will play around with your code today (if I have the time)
  6. Nice hack with the ListViewItem control
  7. Not really a fan of one liners, I prefer more simple and understandable code LOL . Yes, that is true. But my inner perfectionist wanted to handle all cases, you never know what a user might throw at you . I made this snippet while working on a freelance project which I have to complete tomorrow, so it is a half-baked attempt
  8. ; #FUNCTION# ==================================================================================================================== ; Name ..........: ConvertTime12To24 ; Description ...: Converts 12 hour time to 24 hour time, made while keeping _DateDiff's format in mind :) ; Syntax ........: ConvertTime12To24($sTime, $sPeriod[, $sDelimiter = ':']) ; Parameters ....: $sTime - Timestamp. (Can be a single digit or a pattern like H:M:S) ; $sPeriod - AM or PM. ; $sDelimiter - [optional] Separator between units of time. Default is ':'. ; Return values .: $sTime in 24 hour format with 0 padding ; Author ........: Damon Harris (TheDcoder) ; Remarks .......: Ensures that the first 3 parts have 0 padding if the time unit is single digit (Example 09 instead of 9) ; Link ..........: https://git.io/vdWnY ; Example .......: ConvertTime12To24('8:07:22', 'PM') ; =============================================================================================================================== Func ConvertTime12To24($sTime, $sPeriod, $sDelimiter = ':') $aTime = StringSplit($sTime, ':') For $iElement = 1 To ($aTime[0] > 3 ? 3 : $aTime[0]) $aTime[$iElement] = StringFormat('%.2i', Number($aTime[$iElement])) Next If $sPeriod = 'PM' Then $aTime[1] = StringFormat('%.2i', Number($aTime[1]) + 12) Return _ArrayToString($aTime, $sDelimiter, 1) EndFunc
  9. You're welcome
  10. Yes, all automation functions or operations will freeze if there is no session with a virtual display attached to it. Stuff like conversion and comparison will work because it does not involve anything which requires a display. Your welcome
  11. Regarding your script not working when the remote console is closed, I have had the same problem a few months ago, have a look at my workaround here: https://stackoverflow.com/a/45746816/3815591 Quoting the text for reference:
  12. It worked . Thanks for the advice, I did play around with the $treescope constants but I didn't try the subtree option... I must have been very tired, thanks again!
  13. I am just glad that I found a workaround anyway. From the chrominum docs: UI Automation support is very limited. So it makes sense why chrome has different results when using treewalkers and findall. Looks like I am sticking with my function
  14. Hello again. I am playing around with UI Automation again. Maybe I found a potential bug in this UDF When I use LegacyIAccessibleName with _UIA_getObjectByFindAll it is not working, but when I try to iterate through the objects I can find the correct element using the Legacy Name. Here is an example: #include "UIA\UIAWrappers.au3" Local $oChrome=_UIA_getObjectByFindAll($UIA_oDesktop, "controltype:=UIA_WindowControlTypeId;class:=Chrome_WidgetWin_1", $treescope_children) Local $oUIElement=_UIA_getObjectByFindAll($oChrome, "title:=Play;ControlType:=UIA_ButtonControlTypeId", $treescope_subtree) _UIA_action($oUIElement,"highlight") $oMuteButton = _UIA_getObjectByFindAll($oChrome, 'LegacyIAccessibleName:=Mute;ControlType:=UIA_ButtonControlTypeId') MsgBox(0, "Highlight", "Using _UIA_getObjectByFindAll to find object and highlight") _UIA_action($oMuteButton,"highlight") MsgBox(0, "Highlight", "Using GetSiblingObjectByLegacyName to find object and highlight") $oMuteButton = GetSiblingObjectByLegacyName($oUIElement, "Mute") _UIA_action($oMuteButton,"highlight") Func GetSiblingObjectByLegacyName($oSiblingObject, $sName) $UIA_oUIAutomation.RawViewWalker($UIA_pTW) $oTW = ObjCreateInterface($UIA_pTW, $sIID_IUIAutomationTreeWalker, $dtagIUIAutomationTreeWalker) While IsObj($oSiblingObject) = True $oTW.GetNextSiblingElement($oSiblingObject, $UIA_pUIElement) $oSiblingObject = ObjCreateInterface($UIA_pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If _UIA_getPropertyValue($oSiblingObject, $UIA_LegacyIAccessibleNamePropertyId) = $sName Then Return $oSiblingObject WEnd EndFunc In this example I made a custom function which iterates through all of the sibling objects for a given object and finds the correct object by the Legacy Name... and guess what? _UIA_getObjectByFindAll cannot find it, I wonder why? You can run this example by opening a youtube video in chrome, it should highlight the play button and the mute button. Thanks for the help in advance, TD
  15. @ISI360 I think he wants a code snippet manager
  16. First off, why are you playing 2 games while watching a youtube at 2x? Seems like a good way to clog your brain Anyway, it still shouldn't make a large difference. If you really want efficiency, use Sleep(10000000000) instead of Sleep(10).
  17. Sleep(10000) should be less taxing on the CPU because if you use Sleep(10) in a while loop, AutoIt will have to check the loop every 10ms and thus consumes more resources. The Sleep function in AutoIt uses Window's Sleep function which I would guess is more optimized and does not check every millisecond. A little reading suggests that it uses the system ticks... I am not sure what that means by the way but it does look more promising. Albeit, the difference would be too subtle and shouldn't make any real difference in this age of computers . Use what you feel comfortable with, I personally prefer Sleep(10)
  18. This script shows the right usage for GUICtrlGetHandle: #NoTrayIcon #RequireAdmin #include <Constants.au3> #include <GUIConstants.au3> #include <SendMessage.au3> #include <ScrollBarsConstants.au3> #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) Global $Form1 = GUICreate("Form1", 577, 329, 330, 318) Global $Buildprop = GUICtrlCreateButton("Build.prop Info", 24, 56, 113, 185) Global $Logs = GUICtrlCreateEdit("", 216, 56, 297, 193, BitOR($GUI_SS_DEFAULT_EDIT,$ES_READONLY)) GUICtrlSetOnEvent($Buildprop, '_Buildprop') GUISetOnEvent($GUI_EVENT_CLOSE, '_AllExit', $Form1) GUICtrlSetData($Logs, "Logs" & @CRLF) GUISetState(@SW_SHOW, $Form1) If not FileExists(@TempDir & "\adb.exe") Then FileInstall("adb.exe", @TempDir & "\adb.exe", $FC_OVERWRITE) If not FileExists(@TempDir & "\AdbWinApi.dll") Then FileInstall("AdbWinApi.dll", @TempDir & "\AdbWinApi.dll", $FC_OVERWRITE) If not FileExists(@TempDir & "\AdbWinUsbApi.dll") Then FileInstall("AdbWinUsbApi.dll", @TempDir & "\AdbWinUsbApi.dll", $FC_OVERWRITE) While 1 Sleep(3000) _SendMessage(GUICtrlGetHandle($Logs), $WM_VSCROLL, $SB_BOTTOM, 0) WEnd Func _AllExit() GUIDelete(@GUI_WinHandle) Exit EndFunc Func _Buildprop() $iPID = Run("adb shell getprop ro.build.id", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($iPID) $sOutput = StringStripWS(StdoutRead($iPID), $STR_STRIPLEADING + $STR_STRIPTRAILING) GUICtrlSetData($Logs, GUICtrlRead($Logs) & 'Display id | ' & $sOutput & @CRLF) EndFunc I have spoon-fed the code, But I recommend that you understand how the code and the functions work in AutoIt. https://www.autoitscript.com/wiki/Tutorials
  19. $file = FileOpen("C:\temp\log.log", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop If @error Then MsgBox(0, "Error", "FileReadLine has set @error to: " & @error) ConsoleWrite("Line read:" & $line) Wend ConsoleWrite("EOF") FileClose($file) Try this code and see if you catch an error message
  20. Looks like it is using OOP. AutoIt doesn't support OOP natively
  21. Can you post your script so that we can have a look at what is going wrong?
  22. Ah! Yes, that might be true.
  23. The text is wrapped inside <span> tags, not <button>. So innertext should also contain the span tags, try this: $oIE = _IEAttach ("Платформа") Sleep(1000) $oLinks = _IETagNameGetCollection ($oIE, 'button') For $oLink in $oLinks If StringInStr($oLink.InnerText, "Ниже") <> 0 Then _IEAction ($oLink, 'click') EndIf Next
×
×
  • Create New...