Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/15/2023 in Posts

  1. Nine

    Printer Manager

    In this topic, it was mentioned by @mLipok that it could be doable to manage printers with winspool.drv DLL. It was enough to get my attention on it. I do not remember seeing any UDF gathering all those functions. Func _PRNT_GetDefaultPrinter() Func _PRNT_SetDefaultPrinter($sPrinter) Func _PRNT_OpenPrinter($sName) Func _PRNT_ClosePrinter($hPrinter) Func _PRNT_GetPrinterInfo($hPrinter, $bGlobal, $bRAW = False) Func _PRNT_SetPrinterInfo($hPrinter, $iProp, $iValue, $bGlobal) Func _PRNT_EnumPrinters() Func _PRNT_IsValidDevmode($tDevMode) Func _PRNT_EnumJobs($hPrinter) Version 2023-10-17 *added new functions _PRNT_IsValidDevmode and _PRNT_EnumJobs Version 2023-10-15 * solved a problem where garbage collector would destroy $tDevMode after a while on return of _PRNT_GetPrinterInfo There is a multitude of other functions that could be part of this UDF, but I have decided to stop here and see how you like it. If you have comments or suggestions, they are always welcome. Printer_UDF.zip
    1 point
  2. Revisiting secure solutions to send attachments in gmail. As per anyone else that might be using this with gmail, they might receive the following error: Error Code:2 Description:The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available This message goes away when you visit google secure account settings and turn it OFF: https://myaccount.google.com/lesssecureapps?pli=1 Some apps and devices use less secure sign-in technology, which makes your account vulnerable. You can turn off access for these apps, which we recommend, or turn it on if you want to use them despite the risks. Google will automatically turn this setting OFF if it’s not being used. Allow less secure apps: OFF Does anyone have any references to why it's not bad to turn off this secure access since as the summary explains, it seems like not a great thing to do.
    1 point
  3. I made a few changes to the code @Andreik provided! #define AUT_MANUALSTEP 0 #define AUT_AUTOSTEP 1 bool PixelSearch(LPRECT lpRect, int nCol, int nVar, int nStep, LPPOINT pPointResult, int stepMode = AUT_MANUALSTEP, int nCoordPixelMode = AUT_COORDMODE_SCREEN) { int q, r; int col; BYTE red, green, blue; BYTE red_low, red_high, green_low, green_high, blue_low, blue_high; HDC hdc; RECT relrect; POINT ptOrigin; bool m_bColorModeBGR = false; relrect.left = lpRect->left; relrect.top = lpRect->top; relrect.right = lpRect->right; relrect.bottom = lpRect->bottom; ConvertCoords(nCoordPixelMode, ptOrigin); relrect.left += ptOrigin.x; relrect.top += ptOrigin.y; relrect.right += ptOrigin.x; relrect.bottom += ptOrigin.y; col = nCol; if (m_bColorModeBGR == false) Util_RGBtoBGR(col); red = GetRValue(col); green = GetGValue(col); blue = GetBValue(col); if (nVar < 0) nVar = 0; else if (nVar > 0xff) nVar = 0xff; if (nVar == 0) { red_low = red_high = red; green_low = green_high = green; blue_low = blue_high = blue; } else { red_low = (nVar > red) ? 0 : red - nVar; green_low = (nVar > green) ? 0 : green - nVar; blue_low = (nVar > blue) ? 0 : blue - nVar; red_high = (nVar > 0xFF - red) ? 0xFF : red + nVar; green_high = (nVar > 0xFF - green) ? 0xFF : green + nVar; blue_high = (nVar > 0xFF - blue) ? 0xFF : blue + nVar; } hdc = GetDC(NULL); if (stepMode == AUT_MANUALSTEP) { for (q = relrect.left; q <= relrect.right; q = q + nStep) { for (r = relrect.top; r <= relrect.bottom; r = r + nStep) { col = GetPixel(hdc, q, r); red = GetRValue(col); green = GetGValue(col); blue = GetBValue(col); if (red >= red_low && red <= red_high && green >= green_low && green <= green_high && blue >= blue_low && blue <= blue_high) { q -= ptOrigin.x; r -= ptOrigin.y; pPointResult->x = q; pPointResult->y = r; ReleaseDC(NULL, hdc); return 0; } } } } else if (stepMode == AUT_AUTOSTEP) { nStep = lpRect->right - lpRect->left; for (int i = nStep; i > 0; i -= (i / 2)) { for (q = relrect.left; q <= relrect.right; q = q + i) { for (r = relrect.top; r <= relrect.bottom; r = r + i) { col = GetPixel(hdc, q, r); red = GetRValue(col); green = GetGValue(col); blue = GetBValue(col); if (red >= red_low && red <= red_high && green >= green_low && green <= green_high && blue >= blue_low && blue <= blue_high) { q -= ptOrigin.x; r -= ptOrigin.y; pPointResult->x = q; pPointResult->y = r; ReleaseDC(NULL, hdc); return 0; } } } } } ReleaseDC(NULL, hdc); return 1; } Changed the return type of the PixelSearch function to return a bool. If it finds the color it returns 0, if not it returns 1. I also added a parameter stepMode, its default is AUT_MANUALSTEP or 0. The AUT_AUTOSTEP basically just takes the difference of lpRect->right - lpRect->left and uses that as the step amount. It divides the difference by 2 each time it cycles through those for loops. If anyone can add to this or make this even better that would be awesome!
    1 point
×
×
  • Create New...