Leaderboard
Popular Content
Showing content with the highest reputation on 08/12/2019 in all areas
-
isnt hiding these errors inside VLC also an option, rather than accomodating the behavior via brute force? Does this parameter kill those warnings? vlc.exe --no-qt-error-dialogs1 point
-
if you prefer to keep a leading zero when a number is less than 1 you could also use this: Local $a = "-0000.31415926" $a = String($a * 1) ConsoleWrite($a & @LF)1 point
-
A local variable with the same name as the Global variable will cause the local version to be used inside the function. Why are you redeclaring the variable $cell inside the function if you want to use the global version of it?1 point
-
Change line 15? Jos PS: We seriously need more information in case you want a real answer.1 point
-
Zip Create Within is a simple program, mostly based on my old Create Zip Within program, but uses 7-Zip instead of native zipping, plus it has no GUI. Basically, it zips a folder, then wipes the content of that folder, then places the created 7-Zip file inside that folder. I primarily use it myself, for the version update backup folders for my created programs. i.e. v1.0, v1.1, v1.2, v1.2_b01, v3.5_b05 and so on. I could of course, have not bothered with retaining the source folder, but I prefer to not have a parent folder full of files, that my AV just has to scan first before allowing access. REQUIREMENTS 7-Zip installed somewhere on your PC. Program will either auto-detect the usual location or provide a file browser to select it. Oops, I thought it did ... must be another project. FEATURES 1. Won't process a folder if it only contains a single .7z, .zip or .rar file ... just skips it. 2. Won't delete folder content, if the zipped file is not larger than half the source folder size ... just a precaution, and a folder window is opened up for user inspection. 3. Checks remaining free drive space, which needs to be more than twice the source folder size to allow zipping. LIMITATIONS I may at some point, do an update or three that removes all of these limitations. 1. Currently it only produces a .7z file, which is easily enough changed to .zip in the source code if you want. 2. Same with the amount of compression, which is the default. 3. No Registry entries created. 4. No GUI. 5. No settings to adjust, other than 7-Zip path and removal of source folder content. Removal is not the default setting, so if you want that, then just set the value to '1' in the 'Settings.ini' file. 6. Cannot currently disable (if Removal is enabled) the resulting Explorer window when size check fails. Indeed, you cannot change the amount of that size check. Both can be solved of course, by modifying the source code. 7. Does not currently provide a file browser for 7-Zip. Instead it checks the Registry and failing that uses a standard location. If they fail, you can manually edit the 'Settings.ini' file entry. 8. Not a lot of error checking. I should probably improve that, especially as regards successful zipping. USAGE There is four different ways to use the program. 1. Drag and drop your source folder on the program EXE or a shortcut to it. 2. Use the program via the command-line. 3. Create a Registry entry for folders, which will then allow processing via right-click. 4. Use my Batch Create & Run program for a drag & drop GUI element, especially for batch processing. HISTORY Many years ago, I created a program called 'Create Zip Within', which is where the current program gets its main idea from. 'Create Zip Within' in its original form, doesn't work beyond Windows XP, and uses Windows native zip ability. That native zipping creates some issues, which the program mostly works around and dealt with, but every once in a while it still has a failure ... which I made sure was recoverable from, at least manually. At the time I created the program, using AutoIt, my modus operandi was no third party programs. Years later, and for a good while now, I had wanted to create a 7-Zip version of that program, and I have sort of done that now, though I did so essentially from scratch, not using any of the previous code, and not including (so far) any floating dropbox or GUI ... so no batch ability on its own. When I say scratch, it is not strictly true, as I pinched a bunch of code from some more recent program ... just to speed development up ... not that there is a lot of code. I was using Windows 7, and I had a need ... needed to regain some space on a thumb drive. That last, is really why I did not use any previous code, as it wasn't accessible right then. DOWNLOAD The download also includes source. Zip Create Within v1.1.zip1 point
-
The easiest way is to use GUICtrlCreateLabel with $SS_SUNKEN style and a black background. Try this : #include <GUIConstantsEx.au3> #include <GuiToolbar.au3> #include <WinAPIConstants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> Global $g_hToolbar, $g_idMemo Global $g_iItem ; Command identifier of the button associated with the notification. Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp Example() Func Example() Local $hGUI, $aSize ; Create GUI $hGUI = GUICreate("Toolbar", 600, 400) $g_hToolbar = _GUICtrlToolbar_Create($hGUI) $aSize = _GUICtrlToolbar_GetMaxSize($g_hToolbar) $g_idMemo = GUICtrlCreateEdit("", 2, $aSize[1] + 20, 596, 396 - ($aSize[1] + 20), $WS_VSCROLL) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") ; Add standard system bitmaps _GUICtrlToolbar_AddBitmap($g_hToolbar, 1, -1, $IDB_STD_LARGE_COLOR) ; Add buttons _GUICtrlToolbar_AddButton($g_hToolbar, $e_idNew, $STD_FILENEW) _GUICtrlToolbar_AddButton($g_hToolbar, $e_idOpen, $STD_FILEOPEN) _GUICtrlToolbar_AddButton($g_hToolbar, $e_idSave, $STD_FILESAVE) _GUICtrlToolbar_AddButtonSep($g_hToolbar) _GUICtrlToolbar_AddButton($g_hToolbar, $e_idHelp, $STD_HELP) GUICtrlCreateLabel ("", 5,33,585,6, $SS_SUNKEN) GUICtrlSetBkColor (-1, 0) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>Example ; Write message to memo Func MemoWrite($sMessage = "") GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite ; WM_NOTIFY event handler Func _WM_NOTIFY($hWndGUI, $iMsgID, $wParam, $lParam) #forceref $hWndGUI, $iMsgID, $wParam Local $tNMHDR, $hWndFrom, $iCode, $iNew, $iFlags, $iOld Local $tNMTBHOTITEM $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $g_hToolbar Switch $iCode Case $NM_LDOWN ;---------------------------------------------------------------------------------------------- MemoWrite("$NM_LDOWN: Clicked Item: " & $g_iItem & " at index: " & _GUICtrlToolbar_CommandToIndex($g_hToolbar, $g_iItem)) ;---------------------------------------------------------------------------------------------- Case $TBN_HOTITEMCHANGE $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam) $iOld = DllStructGetData($tNMTBHOTITEM, "idOld") $iNew = DllStructGetData($tNMTBHOTITEM, "idNew") $g_iItem = $iNew $iFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags") If BitAND($iFlags, $HICF_LEAVING) = $HICF_LEAVING Then MemoWrite("$HICF_LEAVING: " & $iOld) Else Switch $iNew Case $e_idNew ;---------------------------------------------------------------------------------------------- MemoWrite("$TBN_HOTITEMCHANGE: $e_idNew") ;---------------------------------------------------------------------------------------------- Case $e_idOpen ;---------------------------------------------------------------------------------------------- MemoWrite("$TBN_HOTITEMCHANGE: $e_idOpen") ;---------------------------------------------------------------------------------------------- Case $e_idSave ;---------------------------------------------------------------------------------------------- MemoWrite("$TBN_HOTITEMCHANGE: $e_idSave") ;---------------------------------------------------------------------------------------------- Case $e_idHelp ;---------------------------------------------------------------------------------------------- MemoWrite("$TBN_HOTITEMCHANGE: $idHelp") ;---------------------------------------------------------------------------------------------- EndSwitch EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_NOTIFY1 point
-
_Excel_RangeWrite Not working
SkysLastChance reacted to Subz for a topic
Try: _Excel_RangeWrite($oWorkbook,Default, '=IF(AND(X' & 2 & '="X",Y' & 2 & '=""),1,"Hello")', "B" & 2)1 point -
Finally figured out swapping the color with a specific color. Turns out the GDI stuff uses 8 character aRGB not just normal 6 character RGB that you find in most google searches. the first 2 characters are for Transparency. 00 is totally transparent and FF = not transparent at all. So, now this sample will create 4 images. A basic capture, a Capture scaled up 3x, a Capture Scaled up 3x with a transparent background, a Capture scaled up 3x with a white background. ;Testing the replace pixel color #include <ScreenCapture.au3> ;Capture an un-modified screenshot to use as a base for visually verifying changes _ScreenCapture_Capture("C:\TEMP\Raw.jpg", 100, 50, 700, 550, False) ;Should I check OCR to see if it works better with greyscale? _GDIPlus_BitmapConvertFormat() ;Need to convert the specified Pixel color into a Negative number like I get from the Pixel Search for this to change to! ;Capture a screenshot and enlarge to Scale 3, save as TIFF Swap_Background(100, 50, 700, 550, "C:\TEMP\Enlarged_No_Mod.Tiff", 3, 0, 0, 0, 0) ;Make background transparent! ; Scale = 3, the image will be 3x the size which is usefull for OCR Swap_Background(100, 50, 700, 550, "C:\TEMP\Enlarged_Transparent.Tiff", 3, 0, 0, 0, 0, -1) ;Change background to White! could use 0x00000000 to make background transparent! ; Make background WHITE (Must use aRGB code, where first FF = transparency, remaining 6 FF are pulled from normal windows spy or color picker ; Could use this for setting background to transparent by using 0x00FFFFFF or 0x00000000 ; Scale = 3, the image will be 3x the size which is usefull for OCR Swap_Background(100, 50, 700, 550, "C:\TEMP\Enlarged_White.Tiff", 3, 0, 0, 0, 0, True, 0xFFFFFFFF) Func Swap_Background($x1, $y1, $x2, $y2, $sOutImage = "", $scale = 1, $left_indent = 0, $top_indent = 0, $right_indent = 0, $bottom_indent = 0, $Background = False, $NewColor = True) ConsoleWrite("$NewColor = " & hex($NewColor) & ", True Hex = " & Hex(True) & @CRLF) $hTimerFull = TimerInit() Local $hBitmap, $hwnd, $hDC, $hBMP, $hImage1, $hGraphic, $CLSID, $tParams, $pParams, $tData, $hImage2, $pos[4], $screenpos[4], $pos[4] Local $iPixel = 0 Local $Ext = StringUpper(StringMid($sOutImage, StringInStr($sOutImage, ".", 0, -1) + 1)) Local $giTIFColorDepth = 24 Local $giTIFCompression = $GDIP_EVTCOMPRESSIONNONE $hTimerCapt = TimerInit() $hBitmap = _ScreenCapture_Capture("", $x1, $y1, $x2, $y2, False) _GDIPlus_Startup() ConsoleWrite("Captured initial screenshot to analyze in (" & TimerDiff($hTimerCapt) & ")ms" & @CRLF) If $Background = True Then ;Find the most common pixel color (background) $hTimerCapt = TimerInit() Local $hBmpClr = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) Local $hBitmap0 = _GDIPlus_BitmapCreateFromScan0($x2 - $x1, $y2 - $y1) Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap0) _GDIPlus_GraphicsDrawImageRect($hContext, $hBmpClr, 0, 0, $x2 - $x1, $y2 - $y1) Local $tBitmapData = _GDIPlus_BitmapLockBits($hBitmap0, 0, 0, $x2 - $x1, $y2 - $y1, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) ;locks the bitmap for reading and writing, returns aRGB (first 2 are transpancy, FF for not transparent 00 for full transparent). More infor at http://msdn.microsoft.com/en-us/library/windows/desktop/ms536298(v=vs.85).aspx Local $iScan0 = DllStructGetData($tBitmapData, "Scan0") ;get scan0 (pixel data) from locked bitmap Local $tPixel = DllStructCreate("int[" & ($x2 - $x1) * ($y2 - $y1) & "];", $iScan0) Local $iPixelr, $iRowOffset Local $oDict = ObjCreate("Scripting.Dictionary") ;Create the Dictionary to store unique Pixel color counts For $iY = 0 To ($y2 - $y1) - 1 $iRowOffset = $iY * ($x2 - $x1) + 1 For $iX = 0 To ($x2 - $x1) - 1 ;get each pixel in each line and row $iPixelr = DllStructGetData($tPixel, 1, $iRowOffset + $iX) If $oDict.Exists($iPixelr) Then $oDict.Item($iPixelr) = $oDict.Item($iPixelr) + 1 Else $oDict.Add($iPixelr, 1) EndIf Next Next ;Clear up memory usage _GDIPlus_BitmapUnlockBits($hBitmap0, $tBitmapData) ;unlocks a portion of a bitmap that was locked by _GDIPlus_BitmapLockBits _GDIPlus_GraphicsDispose($hContext) _GDIPlus_BitmapDispose($hBitmap0) _GDIPlus_BitmapDispose($hBmpClr) ConsoleWrite("Finished identifying all Image colors in (" & TimerDiff($hTimerCapt) & ")ms" & @CRLF) $hTimerCapt = TimerInit() $iMax = 0 For $vKeys in $oDict If $oDict.Item($vKeys) > $iMax Then $iMax = $oDict.Item($vKeys) $iPixel = $vKeys EndIf Next ConsoleWrite("Pre BitAND Pixel = (" & $iPixel & ") - Post BitAND Pixel = (" & BitAnd($iPixel, 0xFFFFFFFF) & ")" & @CRLF) ;~ $iPixel = BitAnd($iPixel, 0xFFFFFF) ;This switches the Decimal Windows Color into normal Windows pixel color. ConsoleWrite("Finished identifying main color Converted to (" & $iPixel & ") in (" & TimerDiff($hTimerCapt) & ")ms" & @CRLF) ElseIf $Background = False Then ;Dont remove any pixels from the image (Default) $iPixel = "" Else ;If a Value was entered for $Background, assume it was a pixel color to remove $iPixel = $Background EndIf ; Convert the image to a bitmap $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) $hwnd = _WinAPI_GetDesktopWindow() $hDC = _WinAPI_GetDC($hwnd) $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, (($x2 - $x1) * $scale) - ($right_indent * $scale), (($y2 - $y1) * $scale) - ($bottom_indent * $scale)) _WinAPI_ReleaseDC($hwnd, $hDC) $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1) If hex($NewColor) = hex(True) Then ;8 digit color codes (aRGB) always seem to return as -1 which seem to match True?!? just using Hex to match so it works properly. ;Setup the Transparency details $hTimerCapt = TimerInit() Local $hIA = _GDIPlus_ImageAttributesCreate() _GDIPlus_ImageAttributesSetColorKeys($hIA, 1, True, $iPixel, $iPixel) _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hImage2, 0 - $left_indent, 0 - $top_indent, ($x2 - $x1) + $left_indent, ($y2 - $y1) + $top_indent, 0 - ($left_indent * $scale), 0 - ($top_indent * $scale), (($x2 - $x1) * $scale) + $left_indent, (($y2 - $y1) * $scale) + $top_indent, $hIA) ConsoleWrite("Finished changing main color to Transparent in (" & TimerDiff($hTimerCapt) & ")ms" & @CRLF) ElseIf hex($NewColor) = hex(False) Then ;Dont mess with the background color ;;; Else ;A color was identified, need to replace the background $iPixel with $Replacement $hTimerCapt = TimerInit() ConsoleWrite("Replacing (" & $iPixel & ") with (" & $NewColor & ")" & @CRLF) Local $aRemapTable[2][2] $aRemapTable[0][0] = 1 $aRemapTable[1][0] = $iPixel $aRemapTable[1][1] = $NewColor Local $hIA = _GDIPlus_ImageAttributesCreate() _GDIPlus_ImageAttributesSetRemapTable($hIA, $aRemapTable, 1) If @error Then ConsoleWrite("Error on RemapTable: (" & @error & ") @extended = (" & @extended & ")" & @CRLF) _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hImage2, 0 - $left_indent, 0 - $top_indent, ($x2 - $x1) + $left_indent, ($y2 - $y1) + $top_indent, 0 - ($left_indent * $scale), 0 - ($top_indent * $scale), (($x2 - $x1) * $scale) + $left_indent, (($y2 - $y1) * $scale) + $top_indent, $hIA) ConsoleWrite("Finished swapping main color (" & $aRemapTable[1][0] & ") with (" & $aRemapTable[1][1] & ") in (" & TimerDiff($hTimerCapt) & ")ms" & @CRLF) EndIf $hTimerCapt = TimerInit() $CLSID = _GDIPlus_EncodersGetCLSID($Ext) ; Set TIFF parameters $tParams = _GDIPlus_ParamInit(2) $tData = DllStructCreate("int ColorDepth;int Compression") DllStructSetData($tData, "ColorDepth", $giTIFColorDepth) DllStructSetData($tData, "Compression", $giTIFCompression) _GDIPlus_ParamAdd($tParams, $GDIP_EPGCOLORDEPTH, 1, $GDIP_EPTLONG, DllStructGetPtr($tData, "ColorDepth")) _GDIPlus_ParamAdd($tParams, $GDIP_EPGCOMPRESSION, 1, $GDIP_EPTLONG, DllStructGetPtr($tData, "Compression")) If IsDllStruct($tParams) Then $pParams = DllStructGetPtr($tParams) ; Save TIFF and cleanup _GDIPlus_ImageSaveToFileEx($hImage1, $sOutImage, $CLSID, $pParams) _GDIPlus_ImageDispose($hImage1) _GDIPlus_ImageDispose($hImage2) _GDIPlus_GraphicsDispose($hGraphic) _WinAPI_DeleteObject($hBMP) _GDIPlus_Shutdown() ConsoleWrite("Generated the Scaled TIFF image in (" & TimerDiff($hTimerCapt) & ")ms" & @CRLF) ConsoleWrite("Completed Image modification. Total time = (" & Round(TimerDiff($hTimerFull) / 1000, 1) & ")seconds" & @CRLF & @CRLF) EndFunc1 point
-
You're welcome! I'd appreciate any feedback you have on it. In particular, the use of 2D arrays to represent JSON objects, how well does that work for everyone? I believe they should be compatible with the 2D array handling routines from the standard Array.au3 UDF library. I'll be working on adding comments for each function next – hopefully, that'll help me get my error codes organized. Slightly edited for clarity.1 point