Leaderboard
Popular Content
Showing content with the highest reputation on 08/11/2021 in all areas
-
Calculation Mistakes in Large Arrays
Dana86 reacted to 636C65616E for a topic
Well, i'm sorry about that, maybe not the answer you're looking for, but dealing with high computation in AutoIt is not really the point of the langague. So if i was you, i would just code stuff in C ... AutoIt is intended to be a Scripting/Automation language ... I guess some people gonna hate me for that haha And if you're afraid of C (some people are), you can still get really good perf with any language oriented for calculus (Python, R, Maple, Matlab, ...) or perfs (Ada, Fortran, ... (but if you're afraid of C ... well hahahaha)) but not a scripting language ... Also, interpreted languages usually s*ck for computation when not explicitly designed for it ...1 point -
Trying to store the ClassName into Variable
636C65616E reacted to Overthink for a topic
i've searched in web even in microsoft website and I solved changing RunAs to RunAsWait. So does'nt matter which flag you use(NOPROFILE, PROFILE), they will work. The difference between them are the time to run and discover the privileges that account used have. I would like to thanks @Nine and you for the support and the attention with me.1 point -
Is it possible to improve the search speed in this code?
Loc reacted to 636C65616E for a topic
no as it is an array it returns the whole binary data if you don't specify an index1 point -
@636C65616EAre you sure your second example works ? I highly doubt it should, as DllStructGetData($tmp, 1) would only return the first DWORD. Unless you use a Struct with BYTE, it will make a bad copy...1 point
-
Calculation Mistakes in Large Arrays
boludoz reacted to JockoDundee for a topic
Fool me once, shame on me…1 point -
_ArraySearch not work for me.
JockoDundee reacted to boludoz for a topic
Ok, wait a minute dear Jos.1 point -
Fine... but I meant your scriptcode!1 point
-
This links back to this very thread, so were I an AI, I would now be in a fatal embrace. What a terrible place to spend eternity. ☹️1 point
-
Is it possible to improve the search speed in this code?
Loc reacted to 636C65616E for a topic
As stated by @Nine, i guess what's making your script slow is the fact that you are calling your functions on each condtions test (i looked realy quickly the code, but as far as i saw you're fetching the same colors each time). Just fetch the data/colors/we once, and then check/compare them. In a more general way, and that's valid in nearly any programming case and based on some elementary logic: if the data you want to test are constant on some period of time, compute them once. For instance : we suppose we get some function called PredictWeather (self explenatory) that takes a fair 5h computation time if PredictWeather() == 'Tempest' then ; do some stuff elseif PredictWeather() == 'Sunny' then ; do some other stuff endif If the prediction is "Sunny" it will take 10h to run (because you call the function 2 times), instead compute once and check : local $prediction = PredictWeather() if $predition == 'Tempest' then ; do some stuff elseif $prediction == 'Sunny' then ; do some stuff endif ; an other way: because switch evaluate once switch PredictWeather() case 'Tempest' ; ... case 'Sunny' ; ... endswitch EDIT: Futhermore: On each call you are Allocating and Releasing lot of memory that doesn't need to be done that many time: GDI_StartUp should be called one at start, and ShuDown once at end, CreateYour objects onces, etc, etc if not _WinAPI_DwmIsCompositionEnabled() then MsgBox(0x30,"Error","Error") endif _GDIPlus_Startup() func FetchColors() local $aPos = WinGetPos($WinHandle) $iWidth = $aPos[2] $iHeight = $aPos[3] local $hDDC = _WinAPI_GetDC($WinHandle) local $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC,$iWidth,$iHeight) _WinAPI_SelectObject($hCDC, $hBMP) DllCall("User32.dll","int","PrintWindow","hwnd",$WinHandle,"hwnd",$hCDC,"int",0) _WinAPI_BitBlt($hCDC,0,0,$iWidth,$iHeight,$hDDC,0,0,0x00CC0020) $BMP = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) ; local $aPixelColor = _GDIPlus_BitmapGetPixel($BMP,$iX,$iY) ; HERE FETCH EVERYTHING ONCE ; one dirty trick: haha local $ret = ObjCreate('scripting.dictionary') for $x in $OX for $y in $OY $ret.Add($x & ':' & $y, _GDIPlus_BitmapGetPixel($BMP,$x,$y)) next next _WinAPI_ReleaseDC($WinHandle,$hDDC) _WinAPI_DeleteDC($hCDC) _WinAPI_DeleteObject($hBMP) _GDIPlus_ImageDispose($BMP) return $ret endfunc local $cols = FetchColors() ; you can access each coords likes that ; _GetColor($hwnd, $OX[0], $OY[1]) = $cols.Item($OX[0] & ':' & $OY[1]) ; anyway that's not the 'good' way to do it, accessing any of the dictionary items takes something like log(n) operations ; and you need to compute a string key, etc ; also accessing an unknown key will return an empty string so you need to take that in consideration ; so just for example purpose _GDIPlus_Shutdown() EDIT2: fetching the raw pixel array + some sidenotes might be one of the best solution ... (note: idk why _WinAPI_CopyStruct "fail") #include <GDIPlus.au3> #include <GDIPlusConstants.au3> #include <WinAPIMisc.au3> ; just for testing purpose, you shouldn't deploy with this kind of stuff ; when ragequiting the script, windows should release the process mem and allocated handles (thanks Microsoft) func assert($check, $line = @SCRIPTLINENUMBER) if not $check then MsgBox(0x10, 'ERROR', 'Assert failed at line ' & $line) Exit endif endfunc func GetBPP($type) switch $type ; $GDIP_PXF01INDEXED ; 1 bpp, indexed ; $GDIP_PXF04INDEXED ; 4 bpp, indexed case $GDIP_PXF08INDEXED return 'BYTE' case $GDIP_PXF16GRAYSCALE, $GDIP_PXF16RGB555, $GDIP_PXF16RGB565, $GDIP_PXF16ARGB1555 return 'WORD' ; $GDIP_PXF24RGB ; 24 bpp - 8 bits for each RGB case $GDIP_PXF32RGB, $GDIP_PXF32ARGB, $GDIP_PXF32PARGB return 'DWORD' case else MsgBox(0x10, 'ERROR', 'Unsupported bpp') Exit endswitch endfunc func GetRawBitmap($aWinHandle, $type = $GDIP_PXF32RGB) local $str = GetBPP($type) local $tmp = WinGetPos($aWinHandle) assert(@ERROR = 0) local $width = $tmp[2] local $height = $tmp[3] local $hDDC = _WinAPI_GetDC($aWinHandle) assert($hDDC <> 0) local $hCDC = _WinAPI_CreateCompatibleDC($hDDC) assert($hCDC <> 0) local $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $width, $height) assert($hBMP <> 0) $tmp = _WinAPI_SelectObject($hCDC, $hBMP) assert($tmp <> 0) $tmp = _WinAPI_PrintWindow($aWinHandle, $hCDC) assert($tmp = True) $tmp = _WinAPI_BitBlt($hCDC, 0, 0, $width, $height, $hDDC, 0, 0, 0x00CC0020) assert($tmp = True) local $BMP = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) assert(@ERROR = 0) local $data = _GDIPlus_BitmapLockBits($BMP, 0, 0, $width, $height, $GDIP_ILMREAD, $type) assert(@ERROR = 0) $str &= '[' & ($width * $height) & ']' $tmp = DllStructCreate($str, $data.Scan0) ; weirdly zero memory ; local $raw = _WinAPI_CopyStruct($tmp, $str) ; assert(@ERROR = 0) local $raw = DllStructCreate($str) DllStructSetData($raw, 1, Binary(DllStructGetData($tmp, 1))) _GDIPlus_BitmapUnlockBits($BMP, $data) assert(@ERROR = 0) ; a good practice: dispose/release/free objects in reverse order of instantiation/allocation, as it is common one may rely on a precedent ; no assert on release because w/e _GDIPlus_BitmapDispose($BMP) _WinAPI_DeleteObject($hBMP) _WinAPI_DeleteDC($hCDC) _WinAPI_ReleaseDC($aWinHandle, $hDDC) ; to keep ref and prevent deallocation of the raw buffer local $ret = [$width,$height,$raw] return $ret endfunc func GetPixel(byref $raw, $x, $y) ; , $line = @SCRIPTLINENUMBER) ; assert(0 <= $y and $y < $raw[1], $line) ; assert(0 <= $x and $x < $raw[0], $line) local $ind = $y * $raw[0] + $x ; this is a normalized/flattened array return DllStructGetData($raw[2], 1, 1 + $ind) endfunc if not _WinAPI_DwmIsCompositionEnabled() then MsgBox(0x10, 'ERROR', 'DWM not enabled') Exit endif _GDIPlus_Startup() local $pid = Run('notepad.exe', '') local $hwnd = WinWait('[CLASS:Notepad]', '', 10) local $time = TimerInit() local $raw = GetRawBitmap($hwnd) ConsoleWrite('GetRawBitmap exec time: ' & Round(TimerDiff($time)) & ' ms' & @CRLF) MsgBox(0, 'Info', '[0,0] = 0x' & hex(GetPixel($raw,0,0),6)) ProcessClose($pid) _GDIPlus_Shutdown()1 point -
Trying to store the ClassName into Variable
Overthink reacted to 636C65616E for a topic
To be fair, I never played with this before, so I can't help (but we're talking about OS privileges here, so it's not related to SSMS itself: only the Microsoft profile running the programm)1 point -
Look example of _GDIPlus_BitmapLockBits to get an idea how to parse your $BMP into a 2D array.1 point
-
The _WinAPI_GetClassName($hWnd) returns the class name of the window, not the class name of the combo. This is why it does not work. If the combo box name change from one instance to the other you could use the feature [REGEXPCLASS:...] to identify the combo : ControlSend($hWnd, "", "[REGEXPCLASS:WindowsForms10.COMBOBOX.*]", "SQL")1 point
-
Trying to store the ClassName into Variable
Overthink reacted to 636C65616E for a topic
try using the 'advanced mode' : "NAME:combo ...." or the ID : 197698, from one version to an other this value may change edit: side note, double check what your concatenate string is because Global $hWnd = WinWait("[TITLE:Connect to Server]", "", 0) Local $Class = _WinAPI_GetClassName($hWnd) Should return 'WindowsForms10.Window.8.app ........' (the WINDOW class) and you want the class of the control => 'WindowsForms10.COMBOBOX. .......' as i stated in my second message ^^1 point -
@Marlon13 This works for me. Please test and report back -- #include "wd_core.au3" #include "wd_helper.au3" Local $sDesiredCapabilities, $sSession SetupGecko() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.facebook.com/") MsgBox(0, "Pause", "") _WD_DeleteSession($sSession) _WD_Shutdown() Func SetupGecko() _WD_Option('Driver', 'geckodriver.exe') _WD_Option('DriverParams', '--log trace --marionette-port 2828') _WD_Option('Port', 4444) $sDesiredCapabilities = '{"capabilities":{"alwaysMatch": {"moz:firefoxOptions": {"args": ["-profile", "' & GetDefaultFFProfile() & '"],"log": {"level": "trace"}}}}}' EndFunc ;==>SetupGecko Func GetDefaultFFProfile() Local $sDefault, $sProfilePath = '' Local $sProfilesPath = StringReplace(@AppDataDir, '\', '/') & "/Mozilla/Firefox/" Local $sFilename = $sProfilesPath & "profiles.ini" Local $aSections = IniReadSectionNames ($sFilename) If Not @error Then For $i = 1 To $aSections[0] $sDefault = IniRead($sFilename, $aSections[$i], 'Default', '0') If $sDefault = '1' Then $sProfilePath = $sProfilesPath & IniRead($sFilename, $aSections[$i], "Path", "") ExitLoop EndIf Next EndIf Return $sProfilePath EndFunc1 point
-
WebDriver UDF - Help & Support (II)
MarkIT reacted to Letraindusoir for a topic
Very much appreciated. Follow your advice , Now it Works good.1 point -
[Solved] How to attach to an already running Chrome instance ?
MarkIT reacted to JohnWIlling for a topic
I found a simple solution to reconnect to an existing chromedriver. Once the driver is loaded, the "session id" is returned. Subsequent communication is via TCP to the defined port while passing in the session id. Global $sSessionFileName = "Session.ID" $sSession = _WD_CreateSession($sDesiredCapabilities) If @error <> $_WD_ERROR_Success Then Exit -1 EndIf FileWrite($sSessionFileName, $sSession & @CRLF) What I've done is to write out to a file the value of the sessionid following the call to _WD_CreateSession. Then when restarting an new app, I would call the following: Func _WD_ReAttach($Type) Local Const $sFuncName = "_WD_ReAttach" Switch $Type Case $eFireFox SetupFireFox() Case $eChrome SetupChrome() Case $eEdge SetupEdge() EndSwitch Local $pFile = FileOpen($sSessionFileName, 0) If (@error = 0) Then $sSession = FileReadLine($pFile) EndIf EndFunc ;==>_WD_ReAttach Which sets up the _WD_Option then reads in the saved session string. I can then continue interacting with the Chrome driver.... John W.1 point -
I wish I had more time to game! But been too obsessed with writing new simulations & testing theories with autoit and python.0 points