Leaderboard
Popular Content
Showing content with the highest reputation on 11/18/2015 in all areas
-
Try this: ;example needs GDI+ v1.1 which is available with Win7+ #include <GDIPlus.au3> Global $sFile = FileOpenDialog("Select an image", "", "Image (*.jpg;*.png;*.bmp;*.gif)") If @error Then Exit _GDIPlus_Startup() Global Const $hImage = _GDIPlus_ImageLoadFromFile($sFile), $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) Global $tHistogram = _GDIPlus_BitmapGetHistogramEx($hImage) _GDIPlus_ImageDispose($hImage) Global $fAverage, $i, $sState For $i = 1 To 256 $fAverage += $tHistogram.Grey(($i)) * $i Next _GDIPlus_Shutdown() $fAverage /= $iW * $iH $sState = $fAverage < 0x80 ? " dark" : " light" MsgBox(0, "Test", "Image is more " & $sState & ". Greyscale average is: " & $fAverage)1 point
-
Unzip with bat and begin launch of Install-help please
afallenhope reacted to ViciousXUSMC for a topic
There is a Zip.UDF that you can use, but I like this method even better if your on Win 7/8/10 $objShell5 = ObjCreate("Shell.Application") $FilesInZip5 = $objShell5.NameSpace($sZip).items $objShell5.NameSpace($sMaps).CopyHere($FilesInZip5,0x4)$sZip is the path to the zip file, and $sMaps is the path to extract.1 point -
Hi, you could easily transfer a 32-Bit-Color-picture into black/white! If this is done, count black/white pixels... You have to think about the threshold, if a colored pixel is black or white, example: if (R+G+B)/3>127 then white If Alpha is XXX then black(white)1 point
-
I am sure all efforts will be in vain! (probably only one of you will understand) Jos1 point
-
Trong, Thanks for the correction - I really should have read the thread from the start. M231 point
-
Here a function to count the used colors in a bitmap: #include <GDIPlus.au3> Global $sFile = FileOpenDialog("Select an image", "", "Image (*.jpg;*.png;*.bmp;*.gif)") If @error Then Exit _GDIPlus_Startup() Global Const $hImage = _GDIPlus_ImageLoadFromFile($sFile) Global $fTimer = TimerInit() Global $iColorCount = _GDIPlus_ImageGetColorCount($hImage) Global $fEndTime = Round(TimerDiff($fTimer), 2) MsgBox(0, "Color Counter", "Found " & $iColorCount & " unique colors in " & $fEndTime & " ms.") _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Func _GDIPlus_ImageGetColorCount($hImage) ;faster but uses a lot of memory for huge images! Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) If $iW * $iH > 2 ^ 24 Then Return SetError(1, 0, -1) ;will cause memory issues Local Const $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local Const $iScan0 = $tBitmapData.Scan0 Local $tPixel = DllStructCreate("byte Binary[" & $iW * $iH * 4 & "];", $iScan0) Local $bData = $tPixel.Binary _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData) Local $aResult = StringRegExp($bData, "[[:xdigit:]]{8}", 3), $y, $s, $iColorCount = 0 If $iW * $iH <> UBound($aResult) Then Return SetError(1, 0, -2) ;internal error For $y = 0 To UBound($aResult) - 1 $s = "_" & $aResult[$y] & "_" If Not IsDeclared($s) Then Assign($s, 0, 1) $iColorCount += 1 EndIf Next $bData = Null $tPixel = Null $aResult = Null Return $iColorCount EndFunc ;==>_GDIPlus_ImageGetColorCount Edit: ok, I see that your problem is not to count the colors. I should read carefully before posting... You can use _GDIPlus_BitmapGetPixel ( $hBitmap, 0, 0 ) to get the color to check whether it is b/w or w/b.1 point
-
Hi, this little script returns the percentage of pixels with a given color. I also have a Milliseconds-version somewhere in my ASM-folders...hard to find it, but i would try to find it if you want :o) #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <GDIPlus.au3> #include <GDIPlusConstants.au3> #include <StructureConstants.au3> #include <Array.au3> $bmpfile = "ergebnis.png" ;the image.... $color = "000000" ;color 24bit RGB , 000000 =black FFFFFF=white _GDIPlus_Startup() $t = TimerInit() $pBitmap = _GDIPlus_BitmapCreateFromFile($bmpfile) If @error Then MsgBox(0, "", "Fehler BitmapCreateFromFile") $BitmapData = _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF24RGB) If @error Then MsgBox(0, "", "Error locking region " & @error) $stride = DllStructGetData($BitmapData, "Stride") ;Stride - Offset, in bytes, between consecutive scan lines of the bitmap. If the stride is positive, the bitmap is top-down. If the stride is negative, the bitmap is bottom-up. ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $stride = ' & $stride & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $Width = DllStructGetData($BitmapData, "Width") ;Image width - Number of pixels in one scan line of the bitmap. ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Width = ' & $Width & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $Height = DllStructGetData($BitmapData, "Height") ;Image height - Number of scan lines in the bitmap. ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Height = ' & $Height & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $pixelFormat = DllStructGetData($BitmapData, "PixelFormat") ;Pixel format - Integer that specifies the pixel format of the bitmap ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $pixelFormat = ' & $pixelFormat & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $Scan0 = DllStructGetData($BitmapData, "Scan0") ;Scan0 - Pointer to the first (index 0) scan line of the bitmap. ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Scan0 = ' & $Scan0 & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $pixeldata = DllStructCreate("byte[" & (Abs($stride) * ($Height)) & "]", $Scan0) $BMP = StringTrimLeft(DllStructGetData($pixeldata, 1), 2) StringReplace($BMP, $color, $color) ;count number of pixel $count = @extended ;number of pixel with color ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $count = ' & $count & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $percent_color = Int($count / $Width / $Height * 10000) / 100 ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Width*$Height = ' & $Width * $Height & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $percent_color = ' & $percent_color & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $m = TimerDiff($t) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $m = ' & $m & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $BMPDataStart = "" $pixeldata = 0 _GDIPlus_BitmapUnlockBits($pBitmap, $BitmapData) _GDIPlus_ImageDispose($pBitmap) _WinAPI_DeleteObject($pBitmap) _GDIPlus_Shutdown() ShellExecute($bmpfile) sleep(1000) MsgBox(0, "color = " & $color, $percent_color & " % of the picture has pixels with color 0x" & $color)1 point
-
How to determine the PNG image is black or white.
Trong reacted to computergroove for a topic
Can you show your code? The pictures above are both black and white. What are you trying to do exactly? PixelSearch will only search the user defined area for 1 pixel being a user defined color. Maybe this will help. You can use this script to identify the location of the pixel position your mouse is currently on. It has been invaluable to me when using autoit: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=C:\Users\user\Desktop\PGCAH2.0.Exe #AutoIt3Wrapper_UseX64=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiConstants.au3> Opt("GUIOnEventMode", 1) Opt("WinTitleMatchMode", 4) Global $xoffset = 10;X axis distance from mouse pointer to blue label Global $yoffset = 23;Y axis distance from mouse pointer to blue label Global $wposx, $wposy, $dt, $cwin, $xcalcl, $xcalcr, $ycalc, $cpos, $pos, $tpos, $hexv, $pcolor Global $title = "Your Title Here" HotKeySet("{ESC}", "Terminate") $pgui = GUICreate($title, 250, 13, -1, -1, $ws_popup);Rear place holder for back of the blue label box (Title, Length of the blue lable box, Height of the blue label box,,) $startlab = GUICtrlCreateLabel(" X: 0000, Y: 0000", 0, -1080, 250, 13) GUICtrlSetBkColor($startlab, 13434879);blue label box color WinSetOnTop($pgui, "", 1) GUISetState(@SW_SHOW) While 1 _nmgp() WEnd Func _nmgp() Local $_cpos = MouseGetPos();get current position of the mouse on desktop Sleep(10) $pcolor = PixelGetColor($_cpos[0], $_cpos[1]);help $pos = MouseGetPos() GUICtrlSetData($startlab, " X: " & $pos[0] & ", Y: " & $pos[1] & " HEX: " & Hex($pcolor, 6) & " DEC: " & $pcolor) ;************************************ Moves the blue label with the mouse ***************************** If $dt = 1 Then $xcalcr = 0.95 * @DesktopWidth $xcalcl = 0.05 * @DesktopWidth $ycalc = 0.9 * @DesktopHeight If $pos[1] > $ycalc Then $wposy = $pos[1] - $yoffset * 2 Else $wposy = $pos[1] + $yoffset EndIf If $pos[0] > $xcalcr Then $wposx = $pos[0] - $xoffset * 3 ElseIf $pos[0] < $xcalcl Then $wposx = $pos[0] + 10 Else $wposx = $pos[0] - $xoffset EndIf Else _clientmouse() EndIf WinMove($title, "", $wposx, $wposy) ;************************************ End Moves the blue label with the mouse *************************** EndFunc Func _clientmouse() Opt("MouseCoordMode", 1) $tpos = MouseGetPos() $cpos = WinGetPos($cwin) $xcalcr = 0.95 * $cpos[2] $xcalcl = 0.95 * $cpos[2] $ycalc = 5.0 * $cpos[3];Y axis for offsetting the text box when you reach the top of the screen (so you can stil see the coordinates) If $tpos[1] > $ycalc Then $wposy = $tpos[1] - $yoffset * 2; Y Axis to determine the distance from the mouse pointer and the blue text box Else $wposy = $tpos[1] + $yoffset EndIf If $tpos[0] > $xcalcr Then $wposx = $tpos[0] - $xoffset - $xcalcr ; X Axis to determine the distance from the mouse pointer and the blue text box ElseIf $tpos[0] < $xcalcl Then $wposx = $tpos[0] + 10 Else $wposx = $tpos[0] - $xoffset EndIf EndFunc Func terminate() Exit 0 EndFunc Compile the above code and run it. You can hit esc to exit out of it. pixlesearch - https://www.autoitscript.com/autoit3/docs/functions/PixelSearch.htm If you want to look for a black color then I would try something like this: #include <MsgBoxConstants.au3> $color = PixelSearch(0,0,500,500,0);This checks the upper left corner of your main monitor for the color black (dec code '0') If Not @Error Then MsgBox(0,0,"Black was found!") EndIF1 point -
Wrote this one a long time ago, maybe that is something that helps?:1 point
-
You can also use the EventLog UDF included with AutoIt, and search the System logs for Event ID 1. http://superuser.com/questions/485131/how-can-i-tell-if-my-computer-went-to-sleep Adam1 point
-
Merging 2 differnet scripts
Blue_Drache reacted to Jos for a topic
Seriously MahM? You are banned for the next 7 days for your 3rd violation of our rules. Do not try to do this again or the ban will be permanent. This account will be disabled and your MahM account will get the 7 days posting ban. Jos1 point -
You can do it like this: ;... ; initialize and get session handle Local $hOpen = _WinHttpOpen() ; get connection handle Local $hConnect = _WinHttpConnect($hOpen, "https://login.xero.com") ; fill login form: Local $sRead = _WinHttpSimpleFormFill($hConnect, _ Default, _ ; location of the form "LoginForm", _ ; id of the form "name:userName", $sUserName, _ "name:password", $sPassword) While StringInStr($sRead, "<title>Working...</title>") ; Fill the confirmation form (WinHttp will do everything internally, no worries) $sRead = _WinHttpSimpleFormFill($hConnect) WEnd _WinHttpCloseHandle($hConnect) ;...Latest Winhttp.au3 is at https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au31 point
-
AutoIt v3.3.14.0 has been released. Thanks to everyone involved, both visible and behind the scenes. Download it here. Complete list of changes: History Note The Map functionality was disabled in this release as it was not ready. I will release another beta version later with it re-enabled for continued dev and test.1 point
-
Uploaded v3.3.14.2 with some changes that were causing issues. Download it here. AutoIt: Fixed: #pragma directive was not working correctly for setting Windows 10 options.UDFs: Fixed #3078: _ArrayUnique() error on 2D arrays with autocheck.Changed: _SQLite_Startup() no longer automatically downloads DLL files. THIS IS A SCRIPT BREAKING CHANGE1 point
-
Uploaded v3.3.14.1 Removed au3record.exe as it's often mistakenly flagged as malware causing the entire AutoIt zip/installer to be flagged. We'll host it separately.Reworked AutoIt3Help.exe and applied a digital signature to help with malware false positives - as above.No other changes to the AutoIt exes so no real need to update if you are not having issues.1 point
-
Here is a collection of small examples. Windows Explorer should be open before you run the examples. If you create shortcuts for the scripts, and copy the shortcuts to the desktop, you can run the examples and use Windows Explorer at the same time. For some of the examples you can select files or folders before you run the example. 1) GetCurrentFolder.au3 #include "Includes\AutomatingWindowsExplorer.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Get current folder Local $pFolder = GetCurrentFolder(), $sFolder SHGetPathFromIDList( $pFolder, $sFolder ) MsgBox( 0, "Folder", $sFolder ) ; Free memory _WinAPI_CoTaskMemFree( $pFolder ) EndFunc 2) SetCurrentFolder.au3 #include "Includes\AutomatingWindowsExplorer.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Set current folder to desktop Local $pDesktop = _WinAPI_ShellGetSpecialFolderLocation( $CSIDL_DESKTOP ) SetCurrentFolder( $pDesktop, $SBSP_ABSOLUTE ) ; Free memory _WinAPI_CoTaskMemFree( $pDesktop ) EndFunc 3) CountItems.au3 #include "Includes\AutomatingWindowsExplorer.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Count files and folders MsgBox( 0, "Count files and folders", CountItems() ) ; Count selected files and folders MsgBox( 0, "Count selected files and folders", CountItems( True ) ) EndFunc 4) GetFiles.au3 #include "Includes\AutomatingWindowsExplorer.au3" #include <Array.au3> Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Get all files with full path ;GetFiles( $fSelected = False, $fFullPath = False, $fPidl = False, $iMax = 0 ) Local $aFiles = GetFiles( False, True ) _ArrayDisplay( $aFiles, "All files" ) ; Get selected files with full path ;GetFiles( $fSelected = False, $fFullPath = False, $fPidl = False, $iMax = 0 ) $aFiles = GetFiles( True, True ) _ArrayDisplay( $aFiles, "Selected files" ) EndFunc 5) GetFolders.au3 #include "Includes\AutomatingWindowsExplorer.au3" #include <Array.au3> Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Get all folders ;GetFolders( $fSelected = False, $fFullPath = False, $fPidl = False, $iMax = 0 ) Local $aFolders = GetFolders() _ArrayDisplay( $aFolders, "All folders" ) ; Get selected folders ;GetFolders( $fSelected = False, $fFullPath = False, $fPidl = False, $iMax = 0 ) $aFolders = GetFolders( True ) _ArrayDisplay( $aFolders, "Selected folders" ) EndFunc 6) SetSelectedItem.au3 #include "Includes\AutomatingWindowsExplorer.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Set second item selected SetSelectedItem( 1 ) EndFunc 7) GetSetIconView.au3 #include "Includes\AutomatingWindowsExplorer.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Get current icon view Local $view = GetIconView() Local $iView, $iSize If IsArray( $view ) Then ; OS > XP $iView = $view[0] ; Icon view $iSize = $view[1] ; Icon size If $iView <> $FVM_DETAILS Then ; Not details view SetIconView( $FVM_DETAILS, 16 ) ; Set details view ElseIf $iView <> $FVM_ICON Then ; Not icon view SetIconView( $FVM_ICON, 48 ) ; Set icon view EndIf Sleep( 3000 ) ; Wait 3 seconds SetIconView( $iView, $iSize ) ; Restore old view Else ; OS = XP $iView = $view If $iView <> $FVM_DETAILS Then ; Not details view SetIconView( $FVM_DETAILS ) ; Set details view ElseIf $iView <> $FVM_ICON Then ; Not icon view SetIconView( $FVM_ICON ) ; Set icon view EndIf Sleep( 3000 ) ; Wait 3 seconds SetIconView( $iView ) ; Restore old view EndIf EndFunc Zipfile The zip contains examples and necessary include files. Examples.7z1 point
-
oddly enough, I was able to update the count with the below statement. $oIE.Navigate('JavaScript:UpdateCount();') I'm 50% there! Ya!!1 point