Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/14/2019 in all areas

  1. jguinch

    Printers Management UDF

    Hello. I did create these few functions several months ago. I post here, if it can interest someone. These functions based on WMI queries allow you to manage printers : add / delete printer, driver, port, or obtain configuration, set default printer ... I let you discover it with the code. Here is the list of the available functions : _PrintMgr_AddLocalPort _PrintMgr_AddLPRPort _PrintMgr_AddPrinter _PrintMgr_AddPrinterDriver _PrintMgr_AddTCPIPPrinterPort _PrintMgr_AddWindowsPrinterConnection _PrintMgr_CancelAllJobs _PrintMgr_CancelPrintJob _PrintMgr_EnumPorts _PrintMgr_EnumPrinter _PrintMgr_EnumPrinterConfiguration _PrintMgr_EnumPrinterDriver _PrintMgr_EnumPrinterProperties _PrintMgr_EnumPrintJobs _PrintMgr_EnumTCPIPPrinterPort _PrintMgr_Pause _PrintMgr_PortExists _PrintMgr_PrinterExists _PrintMgr_PrinterSetComment _PrintMgr_PrinterSetDriver _PrintMgr_PrinterSetPort _PrintMgr_PrinterShare _PrintMgr_PrintTestPage _PrintMgr_RemoveLocalPort _PrintMgr_RemoveLPRPort _PrintMgr_RemovePrinter _PrintMgr_RemovePrinterDriver _PrintMgr_RemoveTCPIPPrinterPort _PrintMgr_RenamePrinter _PrintMgr_Resume _PrintMgr_SetDefaultPrinter And some examples : #include <Array.au3> #include "PrintMgr.au3" _Example() Func _Example() ; Remove a printer called "My old Lexmark printer" : _PrintMgr_RemovePrinter("My old Lexmark printer") ; Remove the driver called "Lexmark T640" : _PrintMgr_RemovePrinterDriver("Lexmark T640") ; Remove the TCP/IP printer port called "TCP/IP" _PrintMgr_RemoveTCPIPPrinterPort("MyOLDPrinterPort") ; Add a driver, called "Samsung ML-451x 501x Series", and driver inf file is ".\Samsung5010\sse2m.inf" _PrintMgr_AddPrinterDriver("Samsung ML-451x 501x Series", "Windows NT x86", @ScriptDir & "\Samsung5010", @ScriptDir & "\Samsung5010\sse2m.inf") ; Add a TCP/IP printer port, called "MyTCPIPPrinterPort", with IPAddress = 192.168.1.10 and Port = 9100 _PrintMgr_AddTCPIPPrinterPort("MyTCPIPPrinterPort", "192.168.1.10", 9100) ; Add a printer, give it the name "My Printer", use the driver called "Samsung ML-451x 501x Series" and the port called "MyTCPIPPrinterPort" _PrintMgr_AddPrinter("My Printer", "Samsung ML-451x 501x Series", "MyTCPIPPrinterPort") ; Set the printer called "My Printer" as default printer _PrintMgr_SetDefaultPrinter("My Printer") ; Connect to the shared printer "\\192.168.1.1\HPDeskjetColor") _PrintMgr_AddWindowsPrinterConnection("\\192.168.1.1\HPDeskjetColor") ; List all installed printers Local $aPrinterList = _PrintMgr_EnumPrinter() _ArrayDisplay($aPrinterList) ; List all printers configuration Local $aPrinterConfig = _PrintMgr_EnumPrinterConfiguration() _ArrayDisplay($aPrinterConfig) ; List all installed printer drivers Local $aDriverList = _PrintMgr_EnumPrinterDriver() _ArrayDisplay($aDriverList) ; Retrieve the printer configuration for the printer called "Lexmark T640" $aPrinterConfig = _PrintMgr_EnumPrinterConfiguration("Lexmark T640") _ArrayDisplay($aPrinterConfig) ; Add a local printer port (for a file output) _PrintMgr_AddLocalPort("c:\temp\output.pcl") ; Remove the local port _PrintMgr_RemoveLocalPort("c:\temp\output.pcl") ; Enum a print job Local $aJobList = _PrintMgr_EnumPrintJobs() _ArrayDisplay($aJobList) EndFunc ;==>_Example Download link : PrintMgr_Example.au3 PrintMgr.au3
    1 point
  2. water

    Task Scheduler

    Version 1.6.0.1

    2,270 downloads

    Extensive library to control and manipulate Microsoft Task Scheduler Service. Please check this site for the implementation status! Please check the History.txt file in the archive for the changelog. Please check the WIKI for details about how to use the UDF. BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort KNOWN BUGS (last changed: 2021-02-03) None Things to come (last changed: 2021-02-03) None
    1 point
  3. If you set the Label background colour with GUICtrlSetBkColor() and happen to forget the colour you set it as, then why not try GUICtrlGetBkColor() Function: #include-once #include <WinAPIGdi.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: GUICtrlGetBkColor ; Description ...: Retrieves the RGB value of the control background. ; Syntax ........: GUICtrlGetBkColor($hWnd) ; Parameters ....: $hWnd - Control ID/Handle to the control ; Return values .: Success - RGB value ; Failure - 0 ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func GUICtrlGetBkColor($hWnd) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) EndIf Local $hDC = _WinAPI_GetDC($hWnd) Local $iColor = _WinAPI_GetPixel($hDC, 0, 0) _WinAPI_ReleaseDC($hWnd, $hDC) Return $iColor EndFunc ;==>GUICtrlGetBkColorExample use of Function: #include <MsgBoxConstants.au3> #include 'GUICtrlGetBkColor.au3' Example() Func Example() Local $hGUI = GUICreate('GUICtrlGetBkColor() Example', 500, 350) Local $iLabel = GUICtrlCreateLabel('', 10, 10, 480, 330) GUISetState(@SW_SHOW, $hGUI) Local $aColor = [0x0000FF, 0x8FFF9F, 0xEC4841, 0xB0E35D, 0x440BFD] ; Random colour array. Local $iColor = 0 For $i = 0 To UBound($aColor) - 1 GUICtrlSetBkColor($iLabel, $aColor[$i]) Sleep(20) $iColor = GUICtrlGetBkColor($iLabel) ; Pass the controldid to the function. MsgBox($MB_SYSTEMMODAL, '', 'Background Color: ' & _ConvertToHexFormat($aColor[$i]) & @CRLF & _ 'GUICtrlGetBkColor() Hex Format: ' & _ConvertToHexFormat($iColor) & @CRLF & _ 'GUICtrlGetBkColor() Returned: ' & $iColor, 0, $hGUI) Next GUIDelete($hGUI) EndFunc ;==>Example Func _ConvertToHexFormat($iColor) Return Hex($iColor, 6) EndFunc ;==>_ConvertToHexFormatAdditional thanks to Yashied for pointing out the obvious in this >forum message about _WinAPI_GetPixel() and the hint about returning a RGB number
    1 point
  4. Yep, my opinion hasn't changed on that one!
    1 point
  5. Batch Create & Run v1.5 has been uploaded, see first post for download. New screenshot added ... but taken before I belatedly widened the program window. (v1.5) The source path being processed, is now shown in path input field and List tip. Path of dropped source is now shown in path input field, immediately after dropping. Process status is now shown in color with text, in the program window, rather than as a splash. NOTE - Slowly bit by bit, I am getting rid of the use of Splash in many of my programs, and just using a changing colored status text field (label) instead. The benefits should be obvious. Current program drive & name (without path) is now shown in added fields. The program window has been enlarged to accommodate changes etc, including some field widths increased. NOTE - My uses are driving these changes or improvements. I find I am using this program even more now ... even allowing me to simplify some of the other programs I develop, because the Batch element is often covered well enough by this program. Some of the changes are to give easier or better visual clues at a glance ... in an effort to aid in not accidentally using the wrong program for any listed source files.
    1 point
  6. Why does your script contain this twice?
    1 point
  7. Don't forget resistors of high and low values: MΩ, GΩ (if working with very high voltage), mΩ and even µΩ (e.g. current sense resistors). Also, kilo is k, not K but that is possible to cope with this. It's probable that a BOM can refer to "CAPACITOR MKP X2", hence digits in designations may occur, depending on the nomenclature used. Provided fractional values have a leading zero (e.g. 0.27 = 270mΩ): #include <array.au3> Local $sRes = "RESISTOR THICK FILM 4.64K ±1% 1/4W ±100PPM/°C 1206 SMT" & @LF & _ "RESISTOR METAL STIRP 4.7m ±0.5% 3 W ±100PPM/°C AXIAL THT" & @LF & _ "RESISTOR THICK FILM 3.83K ±1% 1/4W ±100PPM/°C 1206 SMT" & @LF & _ "RESISTOR CARBON FILM 22K ±10% 1/2W AXIAL THT" & @LF & _ "RESISTOR WIREWOUND 22 ±5% 3W ±30PPM/°C AXIAL THT" & @LF & _ "RESISTOR METAL OXIDE 4.7K ±5% 2 W ±300PPM/°C AXIAL THT" & @LF & _ "RESISTOR METAL OXIDE 1.13G ±1% 1/2 W ±50PPM/°C AXIAL THT" & @LF & _ "RESISTOR THICK FILM 0 1/8W 0805 SM" $a = StringRegExp($sRes, "(?m)^[\w\s]+\s(\d+\.?\d*[GMKmµ]?)\s", 3) _ArrayDisplay($a)
    1 point
  8. @guner7 You're welcome. Everything that is in a pair of round parenthesis is captured, as long as there's no captouring groups, atomic groups, or lookaround. Since the \s* is outside the round parenthesis, it is not captured
    1 point
  9. You are right, didn't realize that mixed up f2f2f2 and f0f0f0 ;). _WinAPI_GetPixel 0,0 seems to catch the border of the button, so getbckcolor needs to be adjusted by 3,3 to capture the buttons background. It get's even worse with an Input control, where the default will capture the input caret. So depending on the control type this one still needs more tweaking. #include <WinAPIGdi.au3> $h_GUI = GUICreate("# WINDOW #", 200, 200) $c_button = GUICtrlCreateButton("TEST", 40, 34, 90, 90) GUICtrlSetBkColor($c_button, 0x000000) $c_input = GUICtrlCreateInput("test", 10, 130, 180, 20) GUISetState(@SW_SHOW) For $i = 0x000000 To 0xffffff GUICtrlSetBkColor($c_button, $i) GUICtrlSetData($c_input, Hex(GUICtrlGetBkColor($c_button), 6)) Next ; #FUNCTION# ==================================================================================================================== ; Name ..........: GUICtrlGetBkColor ; Description ...: Retrieves the RGB value of the control background. ; Syntax ........: GUICtrlGetBkColor($hWnd) ; Parameters ....: $hWnd - Control ID/Handle to the control ; Return values .: Success - RGB value ; Failure - 0 ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func GUICtrlGetBkColor($hWnd) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local $hDC = _WinAPI_GetDC($hWnd) Local $iColor = _WinAPI_GetPixel($hDC, 3, 3) _WinAPI_ReleaseDC($hWnd, $hDC) Return $iColor EndFunc ;==>GUICtrlGetBkColor
    1 point
  10. Compile it with this option #AutoIt3Wrapper_Change2CUI=y You need the full SciTE package! Br, UEZ
    1 point
×
×
  • Create New...