Leaderboard
Popular Content
Showing content with the highest reputation on 05/05/2020 in all areas
-
@trancexx: You rule anyway!2 points
-
UI Automation, wait for element to be visible.
TheXman reacted to seadoggie01 for a topic
Not really proficient... bored and lazy. There's a Bill Gates quote for lazy people... but I'm too lazy to find it1 point -
Gdi+ Cached Bitmap Functions
pixelsearch reacted to Bilgus for a topic
I was looking through the gdiplus.dll and saw the cached bitmap functions https://docs.microsoft.com/en-us/windows/win32/api/gdiplusheaders/nl-gdiplusheaders-cachedbitmap Functions: ;Short example (pseudocode!) Local $iW, $iH, $hWnd ;<- You supply these Local $hG = _GDIPlus_GraphicsCreateFromHWND($hWnd) Local $hBmp = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hG) Local $hCachedBmp = __GDIPlus_CachedBitmapCreate($hG, $hBmp) __GDIPlus_GraphicsDrawCachedBitmap($hG, $hCachedBmp, 0, 0) ;(hGraphics, hCachedBmp, X, Y) __GDIPlus_CachedBitmapDispose($hCachedBmp)1 point -
UI Automation, wait for element to be visible.
MightyWeird reacted to seadoggie01 for a topic
You can always wrap it in a loop with a Sleep call ;~ Local $iCount = 0 ; While we haven't found the next button While Not IsObj($oButton4) ; Search for it $oDesktop.FindFirst( $TreeScope_Descendants, $pCondition5, $pButton4 ) ; Attempt to create the object $oButton4 = ObjCreateInterface( $pButton4, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) ; If we found it (it's an object) If IsObj( $oButton4 ) Then ConsoleWrite( "$oButton4 OK" & @CRLF) Else ; Wait a little before retrying so we don't kill the old computers Sleep(500) ; Optionally, count the number of times this happens... ;~ $iCount += 1 ; If it loops too many times, return an error ;~ If $iCount >= 10 Then Return SetError(1, 0, False) EndIf WEnd Edit: And this works for finding a lot of things... I made this into a function to wait for elements/windows/etc to appear, cause I got bored...1 point -
You get this information much faster when using WMI. Example: ConsoleWrite("InstallDate (MM/DD/YYYY HH:MM:SS): " & _GetOSInstallDate() & @CRLF) Exit Func _GetOSInstallDate() Local $wbemFlagReturnImmediately = 0x10, $wbemFlagForwardOnly = 0x20 Local $colItems = "", $strComputer = "." Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\") Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems Return WMIDateStringToDate($objItem.InstallDate) Next Else Return "No WMI Objects Found for class: Win32_OperatingSystem" EndIf EndFunc ;==>_GetOSInstallDate Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate, 13, 2)) EndFunc ;==>WMIDateStringToDate1 point
-
I have moved the translation into a function. Now you should get the different translations easier . #include "Json.au3" ; (by @AspirinJunkie) Global $sRead1 = "This text will be translated into another language." ConsoleWrite("! >> ORIGINAL: " & $sRead1 & @CRLF) ConsoleWrite("> >> EN->DE : " & _GoogleAPITranslate($sRead1, "en", "de") & @CRLF) ConsoleWrite("> >> EN->FR : " & _GoogleAPITranslate($sRead1, "en", "fr") & @CRLF) ConsoleWrite("> >> EN->ES : " & _GoogleAPITranslate($sRead1, "en", "es") & @CRLF) ; ------------ Function : --------------- Func _GoogleAPITranslate($sMytext, $sFrom, $sTo) Local $sUrl, $oHTTP, $sResponse, $JSONData, $sOutput = "", $aData $sUrl = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" & $sFrom & "&tl=" & $sTo & "&dt=t&q=" & $sMytext $oHTTP = ObjCreate("Microsoft.XMLHTTP") $oHTTP.Open("POST", $sUrl, False) $oHTTP.Send() $sResponse = $oHTTP.ResponseText $JSONData = _JSON_Parse($sResponse) If VarGetType($JSONData) = 'Array' Then $aData = $JSONData[0] If VarGetType($aData) = 'Array' Then For $i = 0 To UBound($aData) -1 Step 1 $sOutput &= ($aData[$i])[0] ;*** & @CRLF Next EndIf EndIf Return $sOutput EndFunc ;==>_GoogleAPITranslate1 point
-
GUIListViewEx - BugFix Version 6 Apr 24
seadoggie01 reacted to Melba23 for a topic
seadoggie01, Thanks for that. I seem to remember that I had to change the "empty ListView" return to prevent a crash elsewhere. I will fix it in the next release. M231 point -
now I understand why of your eyes... P.S. sorry for the hilarity1 point
-
@singh54 That code only tells us that it thinks you're using an outdated browser, so it isn't very helpful in answering your question. What's the URL?1 point
-
You still use my first attempt, where I had already written, that the regular expression needs some fine-tuning . I was referring to those weird characters at the end of the translation. Use a more recent version, such as : #include "Json.au3" ; by @AspirinJunkie Global $g_sMytext, $g_sFrom, $g_sTo, $g_Url, $g_oHTTP, $g_JSONData, $g_aData, $g_sResponse, $g_sOutput $g_sMytext = 'This is an English text to be translated into Italian. ' & _ 'The Moderation team will do their best to act in fair and reasonable manner. Sanctions will ' & _ 'only be applied as a last resort and any action taken will be explained in the relevant thread. ' & _ 'If you feel that you have been unfairly moderated then contact the Moderator concerned - ' & _ 'using a PM or the "Report" button is preferable to opening a new thread (although new members ' & _ 'may have to do this). But do be aware that the Moderation team has the final word - the rules ' & _ 'are set out by the site owner and you are only welcome here if you respect his wishes.' $g_sFrom = "en" $g_sTo = "it" $g_Url = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" & $g_sFrom & "&tl=" & $g_sTo & "&dt=t&q=" & $g_sMytext $g_oHTTP = ObjCreate("Microsoft.XMLHTTP") $g_oHTTP.Open("POST", $g_Url, False) $g_oHTTP.Send() $g_sResponse = $g_oHTTP.ResponseText $g_JSONData = _JSON_Parse($g_sResponse) If VarGetType($g_JSONData) = 'Array' Then $g_aData = $g_JSONData[0] If VarGetType($g_aData) = 'Array' Then For $i = 0 To UBound($g_aData) -1 Step 1 $g_sOutput &= ($g_aData[$i])[0] ;*** & @CRLF Next ConsoleWrite("+ Translated >>>>> : " & @CRLF & $g_sOutput & @CRLF) EndIf EndIf You need the attached Json.au3 ! How does the translated text from your Excel spreadsheet look now? Please post the result of the SciTE console. EDIT : The Google API apparently does not recognize the combined word "exampletext" as valid, and returns it directly. But if you use "example text" , then the translation is "Testo di esempio". Here the API seems to differ from the translation done by the Google website. JSON.au31 point
-
Sure ... banned permanently! 🤐 Jos1 point
-
Actually it's pretty straightforward. An object is created that has a pointer to the original object as its property, and all the calls to methods of this new object are simply translated to the original one. Obviously GetIDsOfNames and Invoke of the new object checks for call to the new methods and alters the parameters array accordingly before calling the original. The only thing that was truly a challenge was how to free dynamically allocated memory from within itself. Doing it from x64 code is easy due to specific calling convention and execution algorithm, but from x86 it's nightmare until you figure out that it is not the spoon that bends, lol. There is no spoon. The code is super interesting, I wish I had a chance to see something like that ten years ago, and be able to learn from it. I would have asked thousands of questions. Who knows... maybe I'd be ruling the world now, and not that fuc*ker. This way I had to do it all by myself with little chance of ruling. The. World.0 points