-
Posts
1,221 -
Joined
-
Last visited
-
Days Won
41
Werty's Achievements
-
How do you handle password in your code ?
Werty replied to cramaboule's topic in AutoIt General Help and Support
Then why not use a hardware serial like baseboard serial so the program can only be run on that machine. -
Werty reacted to a post in a topic: AutoIt Data Type Checker
-
Werty reacted to a post in a topic: DLL Call Problems
-
argumentum reacted to a post in a topic: DLL Call Problems
-
May not be related, but in AutoIt after version 3.3.12 there were things that were broken, like stuff I was able to do in 3.3.12 didnt work in later AutoIt versions, but that was concerning ImageMagick.dll COM object, dont know if that also ruined stuff like your problem. Reference post https://www.autoitscript.com/forum/topic/199781-rgb-imgs-to-cmyk-to-tiff/#comment-1433227
-
Check if an image is grayscale or not
Werty replied to Zhelkus's topic in AutoIt General Help and Support
Also... Func _RGBSaturation($r, $g, $b) Local $m = $r >= $g ? $r : $g >= $b ? $g : $b If $m = 0 Then Return 0 Return (($m - ($r <= $g ? $r : $g <= $b ? $g : $b)) / $m) * 100 EndFunc ..and then get rid of the _Max() and _Min() functions. With a little more effort the whole thing could probably be a one liner and getting rid of the RGBSaturation() func also. -
Check if an image is grayscale or not
Werty replied to Zhelkus's topic in AutoIt General Help and Support
Nice You dont have to use stride/offset or nested loop, nested loops are slow so use a single loop, the result is the same, also dont have to create that struct inside the loop all the time... Func _IsImageGrayScale_rafforzata($sInFile, $iEveryNthPixel = 1, $iTolerance = 8, $fGrayThreshold = 0.97) Local $qn=25 ;valore del quasi nero. originale 25 Local $saturazione = 10 ;valore della saturazione. Originale 10 _GDIPlus_Startup() Local $hImage = _GDIPlus_ImageLoadFromFile($sInFile) If @error Or $hImage = 0 Then _GDIPlus_Shutdown() Return SetError(1, 0, False) EndIf Local $iW = _GDIPlus_ImageGetWidth($hImage) Local $iH = _GDIPlus_ImageGetHeight($hImage) Local $hBitmap = _GDIPlus_BitmapCloneArea($hImage, 0, 0, $iW, $iH, $GDIP_PXF32ARGB) _GDIPlus_ImageDispose($hImage) Local $tBitmapData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local $tPixels = DllStructCreate("dword[" & $iW * $iH & "];", $tBitmapData.Scan0) Local $iTotal = 0, $iGray = 0 For $Loop = 1 To $iW * $iH Step $iEveryNthPixel Local $rgb = DllStructGetData($tPixels, 1, $Loop) Local $r = BitAND($rgb, 0xFF) Local $g = BitAND(BitShift($rgb, 8), 0xFF) Local $b = BitAND(BitShift($rgb, 16), 0xFF) ; Ignora pixel quasi bianchi o quasi neri (soglie più larghe) If ($r > 230 And $g > 230 And $b > 230) Or ($r < $qn And $g < $qn And $b < $qn) Then ContinueLoop $iTotal += 1 ;~ ; Metodo 1: tolleranza RGB If (Abs($r - $g) <= $iTolerance) And (Abs($r - $b) <= $iTolerance) And (Abs($g - $b) <= $iTolerance) Then $iGray += 1 ContinueLoop EndIf ;~ ; Metodo 2: saturazione If _RGBSaturation($r, $g, $b) < $saturazione Then $iGray += 1 EndIf Next _GDIPlus_BitmapUnlockBits($hBitmap, $tBitmapData) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() If $iTotal = 0 Then Return True ; Solo bianco/nero Return ($iGray / $iTotal) >= $fGrayThreshold EndFunc Func _RGBSaturation($r, $g, $b) Local $max = _Max3($r, $g, $b) Local $min = _Min3($r, $g, $b) If $max = 0 Then Return 0 Return (($max - $min) / $max) * 100 EndFunc ;---------------------------------------------------------------- Func _Max3($a,$b,$c) local $m=$a if $m<$b then $m=$b if $m<$c then $m=$c Return $m EndFunc Func _Min3($a,$b,$c) local $m=$a if $m>$b then $m=$b if $m>$c then $m=$c Return $m EndFunc On a side note, instead of... Local $iStride = DllStructGetData($tBitmapData, "Stride") Local $iScan0 = DllStructGetData($tBitmapData, "Scan0") ...you can do it like this Local $iStride = $tBitmapData.Stride Local $iScan0 = $tBitmapData.Scan0 -
It´s DELETE THIS.......................PLEASE!
-
Werty reacted to a post in a topic: AutoIt v3.3.17.1 Beta
-
Make active transparent icon on image background
Werty replied to Davidyese's topic in AutoIt General Help and Support
I dont see $btny used anywhere, $btnx appears to be used for both X and Y positions. -
MiniMark (a minimalistic rtf editor)
Werty replied to TheAutomator's topic in AutoIt Example Scripts
It's usually called "Strike(through)", not "Stripe", and maybe put an Underline under the characters in the bmp's that can be ctrl'ed, and maybe put a lowercase "u" in front of "uLine". It looks nice, havent tried it though, cant be bothered installing fonts nor compile it as exe. Btw, please put all the files in a folder before zipping, so people dont have to create a folder in their examples scripts folder themselfes. -
DLLCall fails in AutoIt but works in VB6
Werty replied to TimRude's topic in AutoIt General Help and Support
You're saying it works with VB6, then make a VB6 EXE or DLL that you can channel it through 😛 Your AU3 script sending the request to a VB6 exe/dll, which then calls the xyzdecrypt.dll and then send the result back to your AU3 script. Just as a last resort ofcourse. however it's done in VB6, dunno VB6. -
AutoIt always opens on left side of screen.
Werty replied to Ganadai's topic in AutoIt General Help and Support
In SciTE go to Options and Open User Options File and add this... ## Scite start position and size position.left=50 position.top=50 position.width=2450 position.height=1250 ...and change to your likings. You can change many things, here's how my user options file look... # User defined key commands user.shortcuts=\ # Ctrl+Shift+V|IDM_PASTEANDDOWN|\ #Ctrl+PageUp|IDM_PREVFILE|\ #Ctrl+PageDown|IDM_NEXTFILE|\ KeypadMinus|IDM_BLOCK_COMMENT|\ Ctrl+F1|IDM_HELP_SCITE| ## Scite start position and size position.left=50 position.top=50 position.width=2450 position.height=1250 split.vertical=0 # open new tab instead of new window check.if.already.open=1 # default linewrap wrap=0 # default statusbar visibility statusbar.visible=1 # clears output window before executing clear.before.execute=1 # default output window location. 0=bottom, 1=side output.initial.hide=0 # at open, load previously open files from close save.session=1 # set default zoom level magnification=1 # set default directory to last opened script open.dialog.in.file.directory=1 # show line numbers line.margin.visible=1 style.au3.32=style.*.32=$(font.base),back:#FFFFFF font.base=font:Courier New,size:10,$(font.override) font.small=font:Courier New,size:8,$(font.override) font.monospace=font:Courier New,size,size:12 indent.size=4 indent.size.*.au3=4 use.tabs=1 caret.line.back=#FFFEBF selection.fore=#006000 selection.alpha=50 selection.back=#EA7783 style.au3.34=fore:#0000FF,back:#FFFFFF style.au3.35=fore:#009933,back:#FFFFFF style.au3.0=fore:#000000,back:#FFFFFF style.au3.1=fore:#008000,italics,back:#FFFFFF style.au3.2=fore:#669900,back:#FFFFFF style.au3.3=fore:#0000FF,back:#FFFFFF style.au3.4=fore:#000090,back:#FFFFFF style.au3.5=fore:#0000FF,back:#FFFFFF style.au3.6=fore:#FF33FF,back:#FFFFFF style.au3.7=fore:#FF0000,back:#FFFFFF style.au3.8=fore:#FF0000,back:#FFFFFF style.au3.9=fore:#AA0000,back:#FFFFFF style.au3.10=fore:#FF8800,back:#FFFFFF style.au3.11=fore:#F000FF,back:#FFFFFF style.au3.12=fore:#A00FF0,back:#FFFFFF style.au3.13=fore:#FF0000,back:#FFFFFF style.au3.14=fore:#0000FF,back:#FFFFFF style.au3.15=fore:#0080FF,back:#FFFFFF -
Another bitmap brute-forcing thread
Werty replied to Hashim's topic in AutoIt General Help and Support
Updated version, and a possible solution to get the faster version running with tool.exe. Arrays are slow in AutoIt, strings are fast, so got rid of the arrays... #include <GDIPlus.au3> #include <WinAPI.au3> HotKeySet("{ESC}", "_exit") ;Be sure $posx and $posy is pointing at the correct spot! Global $posx = 37+16, $posy = 38+16 , $result = "", $code1, $code2, $code3, $code4, $capture, $pixels = DllStructCreate('dword[2816]') ;Lookup table to avoid searching Global $lookup = "1000000000004000000000000000006000320000000000009000008000000000700000000000000000000000000000000000000000000000005" ;Test section ;-------------------------------------------------------------- $gui = GUICreate("Getnumber", 640, 480, 100, 100) GUISetState() WinWaitActive($gui); <--- necessary or screencapture fails _GDIPlus_Startup() $graphics = _GDIPlus_GraphicsCreateFromHWND($gui) $image = _GDIPlus_BitmapCreateFromFile("3.png") _GDIPlus_GraphicsDrawImageRect($graphics, $image, 16, 16, 176, 56) ;-------------------------------------------------------------- ;/Test section $hDDC = _WinAPI_GetWindowDC($gui) $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $capture = _WinAPI_CreateCompatibleBitmap($hDDC, 88, 32) _WinAPI_SelectObject($hCDC, $capture) _WinAPI_BitBlt($hCDC, 0, 0, 88, 32, $hDDC, $posx, $posy, 0x00CC0020) _WinAPI_ReleaseDC($gui, $hDDC) ; <----NOTICE _WinAPI_DeleteDC($hCDC) $result = Getnumber($result) Consolewrite("Result: " & $result & @crlf) While 1 Sleep(10) WEnd Func Getnumber($result) Local $value = 64, $code1 = 0, $code2 = 0, $code3 = 0, $code4 = 0 DllCall('gdi32.dll', 'dword', 'GetBitmapBits', 'ptr', $capture, 'dword', DllStructGetSize($pixels), 'ptr', DllStructGetPtr($pixels)) For $loop = 1 To 2816 Step 440 $code1 += DllStructGetData($pixels, 1, $loop ) > 4278190080 ? $value:0 $code2 += DllStructGetData($pixels, 1, $loop+29) > 4278190080 ? $value:0 $code3 += DllStructGetData($pixels, 1, $loop+58) > 4278190080 ? $value:0 $code4 += DllStructGetData($pixels, 1, $loop+87) > 4278190080 ? $value:0 $value /= 2 Next Return StringMid($lookup, $code1+1, 1) & StringMid($lookup, $code2+1, 1) & StringMid($lookup, $code3+1, 1) & StringMid($lookup, $code4+1, 1) EndFunc Func _exit() _GDIPlus_Shutdown() Exit EndFunc As for the possible solution to get it to work with tool.exe, notice the "NOTICE" in above script, in the helpfile under GetWindowDC() it says... We may have been lucky that it worked at all with our gui as the gui is OWNED by us, so leaving out ReleaseDC() worked, but we dont OWN the tool.exe, so maybe try including the ReleaseDC(), you would have to put all the WinAPI stuff back into the loop, but as you said earlier, they are pretty fast as you saw no big changes in speed putting them outside the loop. it was the bitblt that required more time as we used the whole desktop that took time. -
Try with _WinAPI_GetFileSizeEx(), maybe there's a difference.
-
What causes an AutoIt app to "beep"
Werty replied to Fritterandwaste's topic in AutoIt General Help and Support
Have you tried using Opt("GUIOnEventMode", 1) ? Gui Reference in the helpfile, at the bottom "Gui Event Modes". https://www.autoitscript.com/autoit3/docs/guiref/GUIRef.htm -
Another bitmap brute-forcing thread
Werty replied to Hashim's topic in AutoIt General Help and Support
Oh, didnt know my code was complicated, thanks for letting me know. -
Another bitmap brute-forcing thread
Werty replied to Hashim's topic in AutoIt General Help and Support
@junkew, I fixed your script, I tried and tried with no result until I noticed you changed GetWindowDC() back to GetDC(), that doesnt work, it has to be GetWindowDC(). (though I have no idea why getdc($gui) doesnt work, I agree it should work somehow, I tried adding $CAPTUREBLT to the bitblt, with no result) #include <GDIPlus.au3> #include <WinAPI.au3> HotKeySet("{ESC}", "_exit") ;Be sure $posx and $posy is pointing at the correct spot! Global $posx = 37+16, $posy = 38+16 , $result = "", $code[4], $capture, $pixels = DllStructCreate('dword[2816]') ;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, 100, 100) GUISetState() WinWaitActive($gui); <--- necessary or screencapture fails _GDIPlus_Startup() $graphics = _GDIPlus_GraphicsCreateFromHWND($gui) $image = _GDIPlus_BitmapCreateFromFile("3.png") _GDIPlus_GraphicsDrawImageRect($graphics, $image, 16, 16, 176, 56) Sleep(250); <------- necessary because drawimagerect() is too slow, script occasionally fails without ;-------------------------------------------------------------- ;/Test section ;~ $hDDC = _WinAPI_GetDC(0) ;should be $hDDC = _WinAPI_GetWindowDC($gui) ;~ $hDDC = _WinAPI_GetDC($gui) $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $capture = _WinAPI_CreateCompatibleBitmap($hDDC, 88, 32) _WinAPI_SelectObject($hCDC, $capture) _WinAPI_BitBlt($hCDC, 0, 0, 88, 32, $hDDC, $posx, $posy, 0x00CC0020) _WinAPI_DeleteDC($hCDC) Sleep(250) local $t2 = TimerInit() $result = Getnumber($result) Consolewrite("Time: " & TimerDiff($t2) & @crlf) Consolewrite("Result: " & $result & @crlf) While 1 Sleep(10) WEnd Func Getnumber($result) Local $code[4] = [0,0,0,0], $value = 64 DllCall('gdi32.dll', 'dword', 'GetBitmapBits', 'ptr', $capture, 'dword', DllStructGetSize($pixels), 'ptr', DllStructGetPtr($pixels)) For $loop = 1 To 2816 Step 440 $code[0] += DllStructGetData($pixels, 1, $loop ) > 4278190080 ? $value:0 $code[1] += DllStructGetData($pixels, 1, $loop+29) > 4278190080 ? $value:0 $code[2] += DllStructGetData($pixels, 1, $loop+58) > 4278190080 ? $value:0 $code[3] += DllStructGetData($pixels, 1, $loop+87) > 4278190080 ? $value:0 $value /= 2 Next ;~ consolewrite($code[0] & $code[1] & $code[2] & $code[3]) Return String($digit[$code[0]]) & String($digit[$code[1]]) & String($digit[$code[2]]) & String($digit[$code[3]]) EndFunc Func _exit() _GDIPlus_Shutdown() Exit EndFunc