Leaderboard
Popular Content
Showing content with the highest reputation on 11/13/2024 in all areas
-
Win 11 - My own border color ( Help area )
Danyfirex reacted to argumentum for a topic
These border colors are set by the app every time the window is created. The example for this is already posted. Since this is more of an app than an example, I opened a thread here for support. The script and compilation to .exe is the files area for download. According to Microsoft, the possibility to set the border color is available from Windows 11 Build 22000 onwards.1 point -
Gui window not close when click on "X" button
Werty reacted to pixelsearch for a topic
GUISetOnEvent($GUI_EVENT_CLOSE, "_Close") Where is the _Close function ?1 point -
Help Encoding Unicode
Musashi reacted to pixelsearch for a topic
There is an interesting post from @jchd where he explains why we can't use in a RegEx pattern the 2 values of a surrogate pair (for example 0xD83D & 0xDE2D), this is because "the AutoIt RegEx engine has already merged them to the actual codepoint 0x1F62D" (which corresponds to the "Loudly Crying Face" emoji) So matching the corresponding emoji with a pattern like \x{1F62D} works (tested) but if I'm not wrong, the 2 separate values (high & low surrogate value) aren't really helpful during an AutoIt RegEx ? I found the explanation of the merging process on this wikipedia UTF-16 page, look at the dinosaur emoji at the upper right corner of the page, the merging process is explained there, plus same explanations lower in the web page. jchd, thanks for the [\p{Cc}] pattern which matches control characters (not only those < ascii 0x20), it may help at times. I also experimented the [\p{Cf}] which worked too (format characters). Concerning the pattern [\p{Cs}] for the surrogates pair, I was only able to match a character whose code goes from 0xDC00 to 0xDFFF (which in fact is the range of low surrogates values, but it shouldn't be really useful in a RegEx pattern, I guess) Impossible to use a RexEx pattern with the surrogate high values [\x{D800}-\x{DBFF}] as it generates an immediate error, these characters codes are invalid by themselves in Unicode (?) @lowbattery Thanks for sharing the code above, it's instructive1 point -
I'll write up a walkthrough later, meanwhile, have you seen the update of the getnumber() func I made, it's shorter and slightly faster now... Func Getnumber($result) Local $code[3] = [0,0,0], $value = 64 $bitmap1 = _GDIPlus_BitmapLockBits($clone, 0, 0, 34, 20, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) $pixels = DllStructCreate("dword[" & 680 & "];", DllStructGetData($bitmap1, "Scan0")) For $loop = 1 To 680 Step 102 $code[0] += DllStructGetData($pixels, 1, $loop ) = 4278255360 ? $value:0 $code[1] += DllStructGetData($pixels, 1, $loop+16) = 4278255360 ? $value:0 $code[2] += DllStructGetData($pixels, 1, $loop+32) = 4278255360 ? $value:0 $value /= 2 Next _GDIPlus_BitmapUnlockBits($clone, $bitmap1) Return String($digit[$code[0]]) & String($digit[$code[1]]) & String($digit[$code[2]]) EndFunc Edit, doh, I see in your quote that you've seen it.1 point
-
Loop over 1M numbers fails on 9964th iteration
argumentum reacted to Hashim for a topic
Since you were kind enough to write the code I decided to go ahead and waste some more time by testing this, and HOLY SHIT is this solution fast. I also tested the first-column bitmap solution a few days ago and didn't personally notice a massive improvement - both take at least 24 hours to output the whole 1M dataset. However, this genius solution blows them out of the water, doing the whole thing in 6-8 hours - 4 times as fast! Combined with a modified version of argumentum's Do-Until loop to retry outputs until they're in valid format, I got less than 40 false positives out of a million - not as effective as the bitmap solutions but still low enough to manually correct them without issue, and this is without my version having any sleep calls at all. I've also noticed that without any sleep calls the first code is almost always a false positive, which may be something to do with the start-up time of LockBits. This is almost definitely the solution I'm going to be using going forward because it's too genius not to, but I'd love to understand more about the maths behind it and how exactly it does what it does, especially so much faster than the bitmap solutions, if either you or @AndyG would care to explain. I'm guessing 4278255360 is a uint32, but what exactly do the numbers in the lookup table represent? What's the significance of 680 and 102? And how exactly does the ternary: $code[0] += DllStructGetData($pixels, 1, $loop ) = 4278255360 ? 64 : 0 ...work to recognise the first digit?1 point -
What about $GUI_EVENT_FOCUS and $GUI_EVENT_BLUR ? Never used them before !1 point
-
To have the hint text automatically disappear when the input cell is clicked.
1stPK reacted to argumentum for a topic
GUIGetMsg() should go to a variable, then do the if/then/else.1 point -
1st try (58) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded. do i have to do something? Edit: ok now it works. Now I have to understand how it works? @DesktopWidth x @DesktopHeight = 1920x1080 Global $posx = 958, $posy = 499, $result = ""1 point
-
Yup, ~2 milliseconds on my pc, and that's without the fancy rotating stuff. The basics #include <GDIPlus.au3> #include <ScreenCapture.au3> ;Be sure $posx and $posy is pointing at the correct spot! Global $posx = 1718, $posy = 699, $result = "" ;Lookup table to avoid searching Global $digit[115] = [1,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0, _ 0,0,0,0,0,0,0,0,0,0,6,0,0,0,3,2,0,0,0,0, _ 0,0,0,0,0,0,0,0,9,0,0,0,0,0,8,0,0,0,0,0, _ 0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, _ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, _ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,5] $capture = _ScreenCapture_Capture("", $posx, $posy, $posx+34, $posy+20) $bitmap = _GDIPlus_BitmapCreateFromHBITMAP($capture); for some reason createfromhbitmap is not a fully compatible gdiplus bitmap $clone = _GDIPlus_BitmapCloneArea($bitmap, 0, 0, 34, 20, $GDIP_PXF32ARGB); so we have to do this before it works correctly _GDIPlus_BitmapDispose($bitmap) Func Getnumber($result) Local $code[3] = [0,0,0], $value = 64 $bitmap1 = _GDIPlus_BitmapLockBits($clone, 0, 0, 34, 20, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) $pixels = DllStructCreate("dword[" & 680 & "];", DllStructGetData($bitmap1, "Scan0")) For $loop = 1 To 680 Step 102 $code[0] += DllStructGetData($pixels, 1, $loop ) = 4278255360 ? $value:0 $code[1] += DllStructGetData($pixels, 1, $loop+16) = 4278255360 ? $value:0 $code[2] += DllStructGetData($pixels, 1, $loop+32) = 4278255360 ? $value:0 $value /= 2 Next _GDIPlus_BitmapUnlockBits($clone, $bitmap1) Return String($digit[$code[0]]) & String($digit[$code[1]]) & String($digit[$code[2]]) EndFunc And a runable script (zipped folder with script and test images attached) #include <GDIPlus.au3> #include <ScreenCapture.au3> HotKeySet("{ESC}", "_exit") ;Be sure $posx and $posy is pointing at the correct spot! Global $posx = 1718, $posy = 699, $result = "" ;Lookup table to avoid searching Global $digit[115] = [1,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0, _ 0,0,0,0,0,0,0,0,0,0,6,0,0,0,3,2,0,0,0,0, _ 0,0,0,0,0,0,0,0,9,0,0,0,0,0,8,0,0,0,0,0, _ 0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, _ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, _ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,5] ;Test section ;-------------------------------------------------------------- $gui = GUICreate("Getnumber", 640, 480, -1, -1) GUISetState() WinWaitActive($gui); <--- necessary or screencapture fails _GDIPlus_Startup() $graphics = _GDIPlus_GraphicsCreateFromHWND($gui) $image = _GDIPlus_BitmapCreateFromFile("518.png") _GDIPlus_GraphicsDrawImageRect($graphics, $image, 280, 200, 136, 31) Sleep(10); <------- necessary because drawimagerect() is too slow, script occasionally fails without ;-------------------------------------------------------------- ;/Test section $time = TimerInit() $capture = _ScreenCapture_Capture("", $posx, $posy, $posx+34, $posy+20) $bitmap = _GDIPlus_BitmapCreateFromHBITMAP($capture); for some reason createfromhbitmap is not a fully compatible gdiplus bitmap $clone = _GDIPlus_BitmapCloneArea($bitmap, 0, 0, 34, 20, $GDIP_PXF32ARGB); so we have to do this before it works correctly _GDIPlus_BitmapDispose($bitmap) $result = Getnumber() Consolewrite("Result: " & $result & " Time: " & TimerDiff($time)/1000 & @crlf) While 1 Sleep(10) WEnd Func Getnumber() Local $code[3] = [0,0,0] $bitmap1 = _GDIPlus_BitmapLockBits($clone, 0, 0, 34, 20, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) $pixels = DllStructCreate("dword[" & 680 & "];", DllStructGetData($bitmap1, "Scan0")) $value = 64 For $loop = 1 To 680 Step 102 $code[0] += BitAnd(BitShift(DllStructGetData($pixels, 1, $loop ), 8), 1) = 1 ? $value:0 $code[1] += BitAnd(BitShift(DllStructGetData($pixels, 1, $loop+16), 8), 1) = 1 ? $value:0 $code[2] += BitAnd(BitShift(DllStructGetData($pixels, 1, $loop+32), 8), 1) = 1 ? $value:0 $value /= 2 Next $result = String($digit[$code[0]]) & String($digit[$code[1]]) & String($digit[$code[2]]) $code = 0 _GDIPlus_BitmapUnlockBits($clone, $bitmap1) Return $result EndFunc Func _exit() _GDIPlus_Shutdown() Exit EndFunc Not much code it takes. I havent checked for memoryleaks and stuff, too tired now, if you spot anyting please tell. Be sure to change the $posx and $posy to point at the correct spot, as it is now it fits a 3440x1440 monitor. (you can comment out line 56 that gives error so you can take a screenshot to find the correct spot) /edit Changed, zip not updated Changed again, $code[0] += DllStructGetData($pixels, 1, $loop ) = 4278255360 ? $value:0 $code[1] += DllStructGetData($pixels, 1, $loop+16) = 4278255360 ? $value:0 $code[2] += DllStructGetData($pixels, 1, $loop+32) = 4278255360 ? $value:0 getnumber.zip1 point
-
Removing emojis from text string
pixelsearch reacted to jchd for a topic
ConsoleWrite() silently "converts" Unicode text to ANSI, replacing almost all non-ANSI characters by question marks. This doesn't work fairly with non-latin languages. Below CW() is a homebrew Unicode-aware ConsoleWrite(): ; Mixed language strings $s = "Большая проблема 大问题 बड़ी समस्या مشكلة كبيرة" CW($s) ConsoleWrite($s & @LF) ; A familly with different Fitzpatrick settings = only one glyph $s = "Our familly " & ChrW(0xD83D) & ChrW(0xDC68) & ChrW(0xD83C) & ChrW(0xDFFB) & ChrW(0x200D) & ChrW(0xD83D) & ChrW(0xDC69) & ChrW(0xD83C) & ChrW(0xDFFF) & ChrW(0x200D) & ChrW(0xD83D) & ChrW(0xDC66) & ChrW(0xD83C) & ChrW(0xDFFD) CW($s) ConsoleWrite($s & @LF) Result: Большая проблема 大问题 बड़ी समस्या مشكلة كبيرة ??????? ???????? ??? ???? ?????? ????? ????? Our familly 👨🏻👩🏿👦🏽 Our familly ?????????????? I don't know which charset this legacy version of ACDSee handles for filenames. You can remove emojis or a wider range of Unicode charset explicitely using a regexp. BUT there is a pitfall however: AutoIt charset is UCS2, a limitation of Unicode UTF16 to the BMP (Unicode plane 0) using 16-bit encoding units. But there is more: Unicode codepoints in planes 1..16 use surrogate values to represent. For instance 😭 is represented in UCS2 (AutoIt string) as ChrW(0xD83D) & ChrW(0xDE2D). You might think: pretty easy, just use a regexp pattern to match and replace these values, using StringRegExpReplace($s, "[\x{D800}-\x{DFFF}]", "-") NO! Just because PCRE (the regexp engine used by AutoIt) invokation internally merges the two surrogates into the actual 😭 codepoint 0x1F62D (LOUDLY CRYING FACE). This will replace all series of non-BMP codepoints by an underscore: $s = "Большая проблема 大问题 बड़ी समस्या مشكلة كبيرة Test Title 😭" & @LF $s &= "Our familly " & ChrW(0xD83D) & ChrW(0xDC68) & ChrW(0xD83C) & ChrW(0xDFFB) & ChrW(0x200D) & ChrW(0xD83D) & ChrW(0xDC69) & ChrW(0xD83C) & ChrW(0xDFFF) & ChrW(0x200D) & ChrW(0xD83D) & ChrW(0xDC66) & ChrW(0xD83C) & ChrW(0xDFFD) CW($s) $t = StringRegExpReplace($s, "[\x{10000}-\x{1FFFF}]+", "_") CW($t) Result: Большая проблема 大问题 बड़ी समस्या مشكلة كبيرة Test Title 😭 Our familly 👨🏻👩🏿👦🏽 Большая проблема 大问题 बड़ी समस्या مشكلة كبيرة Test Title _ Our familly ___ Note that in the last line, there are 3 "people" joined with ChrW(0x200D) [Zero Width Joiner] hence three underscores. Yet I suspect that your image viewer will bark at codepoints outside the default 8-bit codepage of your system. If you still get question marks in the last example above, then your only bet is to correctly convert characters into their 8-bit codepage counterpoint, or by a useable substitution character when impossible. Func _StringToCodepage($sStr, $iCodepage = Default) If $iCodepage = Default Then $iCodepage = 65001 ; or Int(RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Nls\Codepage", "OEMCP")) Local $aResult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $iCodepage, "dword", 0, "wstr", $sStr, "int", StringLen($sStr), _ "ptr", 0, "int", 0, "ptr", 0, "ptr", 0) Local $tCP = DllStructCreate("char[" & $aResult[0] & "]") $aResult = DllCall("Kernel32.dll", "int", "WideCharToMultiByte", "uint", $iCodepage, "dword", 0, "wstr", $sStr, "int", StringLen($sStr), _ "struct*", $tCP, "int", $aResult[0], "ptr", 0, "ptr", 0) Return DllStructGetData($tCP, 1) EndFunc ;==>_StringToCodepage Invoke this conversion function with the codepage ID which suits your needs. See https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers1 point -
How to embed the source code of an html page using WebDriver? - (Moved)
SOLVE-SMART reacted to Kreten8 for a topic
Thanks for the quick reply, but in the meantime I found the _WD_GetSource function which solved my problem0 points