Leaderboard
Popular Content
Showing content with the highest reputation on 06/04/2022 in all areas
-
Latest update just released. See below for change log.3 points
-
GuiFlatButton UDF : Change Colors of Regular Buttons
mumpel reacted to kurtykurtyboy for a topic
GuiFlatButton is a UDF to easily create regular buttons with different colors for background, foreground, border, hover, focus, etc.. This started as an effort to change the background color of a button and eventually grew into a full UDF. If you've looked around forums for changing button background colors, you have probably noticed that each proposed workaround has its own set of issues/side-effects. The answers usually circle back to 'use ownerdrawn buttons' and 'not worth it'. Well, now it is possible for anyone to easily create ownerdrawn buttons - totally worth it! Some issues with other workarounds such as drawing with GDI+ or using a colored label as a 'button': Not 'real' buttons so you lose built-in functionality that windows gives to buttons Messy / inefficient code in the main while loop to check for mouse position Slow to respond to click, paint, etc... Having to deal with GUIRegisterMsg messages Not straight-forward to implement GuiFlatButton is not a workaround; it is a technique to respond to Windows' built-in owner-drawn button events. With minimal effort, we can now create true simple colored buttons. The idea is to create an owner-drawn button using GUICtrlCreateButton then subclass the GUI and controls to handle the button-specific events to paint it however we want. This UDF magically does all of this for us! No need to worry about event handling or main while loop logic. How to use It couldn't be any easier! Simply create a new button using the familiar syntax. This creates an ownerdrawn button with default colors. $mybutton1 = GuiFlatButton_Create("Button 1", 78, 20, 120, 40) If you want to change the background and text colors: GuiFlatButton_SetBkColor(-1, 0x5555FF) GuiFlatButton_SetColor(-1, 0xFFFFFF) Advanced Usage Set background/text/border all at once GuiFlatButton_SetColors(-1, 0x0000FF, 0xFFFFFF, 0x9999FF) Set ALL colors for ALL button states! (normal, focus, hover, selected) Local $aColorsEx = [0x0000FF, 0xFFFFFF, -2, 0x4444FF, 0xFFFFFF, 0xAAAAFF, 0x6666FF, 0xFFFFFF, 0xCCCCFF, 0x0000EE, 0xFFFFFF, 0x7777EE] GuiFlatButton_SetColorsEx(-1, $aColorsEx) Set default colors to apply to any future buttons ;set colors GuiFlatButton_SetDefaultColors(0x0000FF, 0xFFFFFF, 0x9999FF) ;create buttons $mybutton1 = GuiFlatButton_Create("Button 1", 12, 20, 120, 40) $mybutton2 = GuiFlatButton_Create("Button 2", 143, 20, 120, 40) Set ALL color defaults ;set colors Local $aColorsEx = [0x0000FF, 0xFFFFFF, -2, 0x4444FF, 0xFFFFFF, 0xAAAAFF, 0x6666FF, 0xFFFFFF, 0xCCCCFF, 0x0000EE, 0xFFFFFF, 0x7777EE] GuiFlatButton_SetDefaultColorsEx($aColorsEx) ;create buttons $mybutton1 = GuiFlatButton_Create("Button 1", 12, 20, 120, 40) $mybutton2 = GuiFlatButton_Create("Button 2", 143, 20, 120, 40) Available Functions Simple Example #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include "GuiFlatButton.au3" Example() ;GUI with one button Func Example() Local $hGUI, $mybutton1 $hGUI = GUICreate("GuiFlatButton Ex0", 275, 120) GUISetBkColor(0x333333) Local $idLabel = GUICtrlCreateLabel("Click the button", 10, 100, 150, 30) GUICtrlSetColor(-1, 0xFFFFFF) ;create new button then set the background and foreground colors $mybutton1 = GuiFlatButton_Create("Button 1" & @CRLF & "Line 2", 78, 20, 120, 40, $BS_MULTILINE) GuiFlatButton_SetBkColor(-1, 0x5555FF) GuiFlatButton_SetColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW, $hGUI) Local $i = 0 Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $mybutton1 $i += 1 GUICtrlSetData($idLabel, $i) ConsoleWrite($i & @CRLF) EndSwitch Sleep(10) WEnd GUIDelete() EndFunc ;==>Example Menu/Toolbar Example #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include "GuiFlatButton.au3" Example() ;Example GUI with toolbar Func Example() Local $hGUI, $idLabel, $aButtons, $iTbSize $hGUI = GUICreate("GuiFlatButton Ex2", 300, 200) GUISetBkColor(0x444444) $idLabel = GUICtrlCreateLabel("Click a button", 10, 180, 150, 30) GUICtrlSetColor(-1, 0xFFFFFF) $aButtons = createToolbar() $iTbSize = UBound($aButtons) GUISetState(@SW_SHOW, $hGUI) Local $i = 0 Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $aButtons[0] To $aButtons[$iTbSize - 1] ConsoleWrite("1") GUICtrlSetData($idLabel, GuiFlatButton_Read($iMsg)) EndSwitch Sleep(10) WEnd GUIDelete() EndFunc ;==>Example Func createToolbar() Local $aButtons[6] Local $bkColor = 0x777777 Local $textColor = 0xFFFFFF Local $borderColor = 0x999999 Local $aBtnClrs[12] = [0x777777, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT, 0x888888, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT, 0x999999, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT, 0x666666, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT] For $i = 0 To UBound($aButtons) - 1 $aButtons[$i] = GuiFlatButton_Create("B" & $i, $i * 50, 0, 50, 17) GuiFlatButton_SetColorsEx($aButtons[$i], $aBtnClrs) Next Return $aButtons EndFunc ;==>createToolbar Icon Example You can even easily add icons to your buttons -- just create a new button and send it an icon! #include <GDIPlus.au3> #include "GuiFlatButton.au3" Example() ;buttons with Icon images Func Example() ;get images for demonstration _GDIPlus_Startup() ;initialize GDI+ Local $hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 258, 24, 24) ;extract the 'Save' icon Local $hBitmap = _GDIPlus_BitmapCreateFromHICON($hIcon) ;Create Bitmap from Icon (for demonstration) Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ;Create HBitmap from Bitmap _GDIPlus_BitmapDispose($hBitmap) ;dispose the bitmap _GDIPlus_Shutdown() ;done with GDI+ Local $hGUI = GUICreate("GuiFlatButton Ex5", 255, 400) GUISetBkColor(0xEEEEEE) ;set default colors of future buttons Local $aColorsEx = _ [0xE2E5E8, 0X000000, 0x888888, _ ; normal : Background, Text, Border 0xE2E5E8, 0X000000, 0x333333, _ ; focus : Background, Text, Border 0xE8E8E8, 0X000000, 0x666666, _ ; hover : Background, Text, Border 0xDDDDDD, 0X000000, 0xAAAAAA] ; selected : Background, Text, Border GuiFlatButton_SetDefaultColorsEx($aColorsEx) ;normal button with icon $label1 = GUICtrlCreateLabel( "$BS_TOOLBUTTON -->", 5, 10) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) Local $mybutton1 = GuiFlatButton_Create("Save", 130, 5, 50, 48, $BS_TOOLBUTTON) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybutton1), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align top Local $mybuttonT = GuiFlatButton_Create("Top", 5, 65, 120, 55, $BS_TOP) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonT), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align top-left Local $mybuttonTL = GuiFlatButton_Create("Top-Left", 5, 125, 120, 55, BITOR($BS_TOP, $BS_LEFT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonTL), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align top-right Local $mybuttonTR = GuiFlatButton_Create("Top-Right", 5, 185, 120, 55, BITOR($BS_TOP, $BS_RIGHT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonTR), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align left Local $mybuttonL = GuiFlatButton_Create("Left", 5, 245, 120, 55, $BS_LEFT) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonL), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align bottom Local $mybuttonB = GuiFlatButton_Create("Bottom", 130, 65, 120, 55, $BS_BOTTOM) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonB), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align bottom-left Local $mybuttonBL = GuiFlatButton_Create("Bottom-Left", 130, 125, 120, 55, BITOR($BS_BOTTOM, $BS_LEFT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonBL), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align bottom-right Local $mybuttonBR = GuiFlatButton_Create("Bottom-Right", 130, 185, 120, 55, BITOR($BS_BOTTOM, $BS_RIGHT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonBR), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align right Local $mybuttonR = GuiFlatButton_Create("Right", 130, 245, 120, 55, $BS_RIGHT) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonR), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) GuiFlatButton_SetState($mybuttonR, $GUI_DISABLE ) ;disabled Local $mybuttonDisable = GuiFlatButton_Create("Disabled", 130, 310, 120, 55, $BS_TOOLBUTTON) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonDisable), $BM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)) GuiFlatButton_SetState($mybuttonDisable, $GUI_DISABLE ) ;clean up! _WinAPI_DestroyIcon( $hIcon ) _WinAPI_DeleteObject( $hHBitmap ) GUISetState(@SW_SHOW, $hGUI) Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch Sleep(10) WEnd GUIDelete() EndFunc ;==>Example I'm sure there are some use-cases I've forgotten, so feedback is welcome! Download the latest UDF and several more examples: GuiFlatButton_20220919.zip (1,121) Update 2022-09-19 Added update from 05/25 back in after it was accidentally removed Update 2022-09-01 Added $BS_MULTILINE button style Added ellipses when text is longer than the button Fixed compatibility with Opt("MustDeclareVars", 1) Update 2022-05-25 Fixed issue, buttons disappear when a GUI containing a child window with WS_EX_MDICHILD extended style is moved Update 2022-05-24 Fixed issue releasing subclassing when GUI is deleted but program is not closed Fixed occasional white background flicker Added function GuiFlatButton_GetPos Update 2021-01-02 Fixed bug, not drawing correctly after deleting GUI with GUIDelete() Fixed bug, changing default colors changed all buttons, even previously created buttons Made some internal functions more efficient Update 2019-04-14 Fixed bug, not showing pressed down state when clicking rapidly Added Icon/Bitmap support! Added function GuiFlatButton_SetPos to change the position and/or size of a button Update 2019-02-09 Added 2 new functions to set the button colors globally for all future buttons. GuiFlatButton_SetDefaultColors GuiFlatButton_SetDefaultColorsEx Credits to: Melba23 (UDF template) LarsJ (general subclassing code) 4ggr35510n (TrackMouseEvent example) binhnx (disable dragging with $WS_EX_CONTROLPARENT) GUIRegisterMsg in AutoIt Help (owner-draw button example) funkey (_WinAPI_DrawState example)1 point -
Roku's External Control Protocol is not specific to any particular Roku device. It works on any Roku device that has ECP enabled, including TV's. If any particular ECP command is sent to a device that it does not support, the device will just ignore the command.1 point
-
1 point
-
You can find the function documented here: https://docs.microsoft.com/en-us/windows/win32/gdiplus/-gdiplus-image-flat I am pretty sure that Windows API only uses C and it doesn't have classes or methods... but, maybe GDI+ is different, I am not familiar with it. I guess you'll just have to wait for someone else to answer your question1 point
-
@TheDcoder, Actually, I am trying to add a feature in my GUI lib for D lang. I want to add JPEG images to my ImageList. It receives only an HBITMAP. So I need to use GDI plus. Well, it's been a long while and now I read about your own programming lang. Best wishes for your endeavor. There is still scope for a good basic style language.1 point
-
@mLipok0.9.1 is an interim bug fix where I cherry picked a few commits, mostly to address the recent issue with _WD_GetWebDriverVersion & MS Edge. The other commits already in the master branch will be in the next "full" release (most likely 0.10.0).1 point
-
GuiBuilderPlus [updated March 24, 2024]
mLipok reacted to argumentum for a topic
really ?. Use a newer version of AutoIt1 point -
HttpApi UDF - HTTP Server API
argumentum reacted to TheXman for a topic
What's New in Version v1.2.1 Added _HTTPAPI_HttpReceiveRequestEntityBody(), which was authored by @dreamscd. The function returns additional request body entities. This is required when POST and PUT requests have body data but the EntityChunkCount is not used. i.e. When sending POST requests using WinHttp. The process_post_request function, in the example script, was modified to include the processing of additional request body entities, if they exist. Thanks @dreamscd. Corrected an issue in _HTTPAPI_GetKnownRequestHeaderValue(). It was reading header value as wchar, when it is actually stored as char. Corrected an issue in _HTTPAPI_HttpSendHttpResponse(). Response status text was not getting set properly. Corrected a function header. It listed a parameter that was not being used.1 point -
I recently bought an IP Camera to monitor my house. There is a web access to view the video stream but not to record it. Here is the IP Camera in question, it should work with every other similar product. So I made a simple example which does the job. Here is the code : #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <GDIPlus.au3> #include <Memory.au3> #region Global Vars Global Const $sProgramTitle = "IP Camera stream + record" ;EDIT THE FOLLOWING LINE ONLY: Global Const $iIPAddress = "192.168.1.99", $iPort = 99, $shtauth = "yourauth==" Global Const $STM_SETIMAGE = 0x0172 Global $blRecording = False, $blGUIMinimized = False Global Const $sRecordDir = @ScriptDir & "\ip_camera_stream" Global $bRecvtmp = Binary(""), $bStream = $bRecvtmp Global $iImgLen = 0, $iStreamLen = 0, $iWritten = 0, $iEOH = 0, $iContLenPos = 0, $hImgFile = 0, $pBuffer = 0, $iImgCount = 0 Global Const $iContLengthLen = StringLen("Content-Length: ") Global $sStream = "", $sTrim2ContLen = "" Global $hBMP = 0, $hGraphics = 0, $hHBITMAP2 = 0, $hFamily = 0, $hFont = 0, $tLayout = "", $hFormat = 0, $hBrush = 0 #endregion Global Vars TCPStartup() Global $iSocket = TCPConnect($iIPAddress, $iPort) If @error Then MsgBox(16, $sProgramTitle, "Could not connect !") Exit -1 EndIf TCPSend($iSocket, _ "GET /videostream.cgi HTTP/1.1" & @CRLF & _ "Host: " & $iIPAddress & ":" & $iPort & @CRLF & _ "Connection: keep-alive" & @CRLF & _ "Authorization: Basic " & $shtauth & @CRLF & @CRLF) #region GUI Global $hGUI = 0, $pPic = 0, $hPic = 0, $btnRecord = 0 $hGUI = GUICreate($sProgramTitle, 640, 525) $pPic = GUICtrlCreatePic("", 0, 0, 640, 480, $SS_BITMAP) GUICtrlSetState($pPic, $GUI_DISABLE) $hPic = GUICtrlGetHandle($pPic) $btnRecord = GUICtrlCreateButton("Record", 10, 490, 80, 26) GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND") GUISetState(@SW_SHOW, $hGUI) #endregion GUI _GDIPlus_Startup() $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, 17) $tLayout = _GDIPlus_RectFCreate(10, 10, 100, 40) $hFormat = _GDIPlus_StringFormatCreate() $hBrush = _GDIPlus_BrushCreateSolid(0xAFFF0000) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $btnRecord If $blRecording Then GUICtrlSetData($btnRecord, "Record") Else If Not FileExists($sRecordDir) Then DirCreate($sRecordDir) GUICtrlSetData($btnRecord, "Stop recording") EndIf $blRecording = Not $blRecording EndSwitch $bRecvtmp = TCPRecv($iSocket, 4096, 1) ;4kb If @error Then ExitLoop If Not BinaryLen($bRecvtmp) Then ContinueLoop $bStream &= $bRecvtmp If $iImgLen = 0 Then $sStream = BinaryToString($bStream) $iContLenPos = StringInStr($sStream, "Content-Length: ", 2) $iEOH = StringInStr($sStream, @CRLF & @CRLF, 2, 1, $iContLenPos) If $iEOH = 0 Or $iContLenPos = 0 Then ContinueLoop $sTrim2ContLen = StringTrimLeft($sStream, $iContLenPos + $iContLengthLen - 1) $iImgLen = Number(StringLeft($sTrim2ContLen, StringInStr($sTrim2ContLen, @CR, 2) - 1)) $bStream = BinaryMid($bStream, $iEOH + 4) EndIf If $iImgLen = 0 Then ContinueLoop $iStreamLen = BinaryLen($bStream) If $iStreamLen < $iImgLen Then ContinueLoop If Not $blGUIMinimized Then $hBMP = Load_BMP_From_Mem($bStream) If $blRecording Then $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBMP) _GDIPlus_GraphicsDrawStringEx($hGraphics, "[•REC]", $hFont, $tLayout, $hFormat, $hBrush) EndIf $hHBITMAP2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBMP) _WinAPI_DeleteObject(_SendMessage($hPic, $STM_SETIMAGE, 0, $hHBITMAP2)) _GDIPlus_ImageDispose($hBMP) If $blRecording Then _GDIPlus_GraphicsDispose($hGraphics) _WinAPI_DeleteObject($hHBITMAP2) EndIf If $blRecording Then $pBuffer = DllStructCreate("byte[" & $iImgLen & "]") If $iStreamLen > $iImgLen Then DllStructSetData($pBuffer, 1, BinaryMid($bStream, 1, $iImgLen)) $bStream = BinaryMid($bStream, $iImgLen) Else DllStructSetData($pBuffer, 1, $bStream) $bStream = Binary("") EndIf $hImgFile = _WinAPI_CreateFile($sRecordDir & "\snap_" & StringFormat("%.4d", $iImgCount) & ".jpg", 3, 4, 4) _WinAPI_WriteFile($hImgFile, DllStructGetPtr($pBuffer), $iImgLen, $iWritten) _WinAPI_CloseHandle($hImgFile) $iImgCount += 1 EndIf $iImgLen = 0 WEnd _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_Shutdown() TCPCloseSocket($iSocket) TCPShutdown() Func WM_SYSCOMMAND($hWnd, $iMsg, $wParam, $lParam) Local Const $SC_MINIMIZE = 0xF020, $SC_RESTORE = 0xF120 Switch BitAND($wParam, 0xFFF0) Case $SC_MINIMIZE, $SC_RESTORE $blGUIMinimized = Not $blGUIMinimized EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_SYSCOMMAND Func Load_BMP_From_Mem($bImage) ;_GDIPlus_BitmapCreateFromMemory2 ;Author: UEZ ;Modified: ProgAndy, Yashied, FireFox If Not IsBinary($bImage) Then Return 0 Local $memBitmap = Binary($bImage) Local $iLen = BinaryLen($memBitmap) Local $GMEM_MOVEABLE = 0x0002 Local $aResult = DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", $GMEM_MOVEABLE, "ulong_ptr", $iLen) Local $hData = $aResult[0] $aResult = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", $hData) If @error Then Return 0 Local $tMem = DllStructCreate("byte[" & $iLen & "]", $aResult[0]) DllStructSetData($tMem, 1, $memBitmap) DllCall("kernel32.dll", "bool", "GlobalUnlock", "handle", $hData) If @error Then Return 0 $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $hData, "int", True, "ptr*", 0) $hStream = $aResult[3] If @error Then Return 0 $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) If @error Then Return 0 DllCall('oleaut32.dll', 'long', 'DispCallFunc', 'ptr', $hStream, 'ulong_ptr', 8 * (1 + @AutoItX64), 'uint', 4, 'ushort', 23, 'uint', 0, 'ptr', 0, 'ptr', 0, 'str', '') Return $aResult[2] EndFunc ;==>Load_BMP_From_Mem _ Advanced example : Preview : Attachment : IP Camera.au3 IP Camera.au3 (Previous: 34 downloads) Enjoy, I'm watching U !1 point
-
Code Study (Get Information from Monitor)
ARPFre reacted to argumentum for a topic
; generated with https://www.autoitscript.com/forum/files/file/338-scriptomatic-warraysupport/ #include "Array.au3" Opt("MustDeclareVars",1) Opt("TrayIconDebug",1) Opt("TrayAutoPause",0) Global $_nice_COMerrorArray, $_nice_COMerrorObj _nice_COMerrorHandler(1) ; COM error handler. ToolTip("mouse over the trayicon for debug info.", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - WmiMonitorID",1,4) Global $a = _WMI_WmiMonitorID() If @error Then Switch @error Case 1 MsgBox(262144, "WMI ScriptOMatic error", "No WMI Objects Found for class: ""WmiMonitorID""" ) Case 2 MsgBox(262144, "WMI ScriptOMatic error", "ObjGet failed") Case 3 MsgBox(262144, "WMI ScriptOMatic error", "ObjCreate failed") Case 4 MsgBox(262144, "WMI ScriptOMatic error", "ConnectServer failed") Case Else MsgBox(262144, "WMI ScriptOMatic error", "unknown error") EndSwitch Else Switch @extended Case 0 ToolTip("Done.", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - WmiMonitorID",1,4) Case 1 ToolTip("Nothing, you've got nothing."&@CR&@CR&"Adjust the query", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - WmiMonitorID",2,4) Case 2 ToolTip("More than you can chew."&@CR&@CR&"Adjust the ""$iLimit"" or the query", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - WmiMonitorID",2,4) EndSwitch If $_nice_COMerrorArray[0][0] Then _nice_COMerrorHandler(2) _ArrayDisplay( $a ,"ScriptOMatic - ""WmiMonitorID""") EndIf Func _WMI_WmiMonitorID( $iLimit = 1000 , $sComputer = "." , $sUser = "" , $sPassword = "" ) ; Generated by AutoIt ScriptOMatic ; Description: Monitor ID ; Class Methods: ; ; ( this Class did not list methods ) Local $wbemFlagReturnImmediately = 0x10 Local $wbemFlagForwardOnly = 0x20 Local $colItems = "" Local $sReturn="" Local $iExt = 0 If 1 > Int( $iLimit ) Then $iLimit = 1 Local $aReturn[1000][ Int( $iLimit ) + 1] $aReturn[0][0] = 0 $aReturn[0][1] = 0 Local $aErr[1][2] = [[0, 0]] If $sComputer & $sUser & $sPassword = "." Then ToolTip("...ObjGet", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - WmiMonitorID",1,4) Local $oWMIService = ObjGet("winmgmts:\\" & $sComputer & "\root\WMI") If Not IsObj($oWMIService) Then Return SetError(2, 99, $aErr) Else ToolTip("...ObjCreate", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - WmiMonitorID",1,4) Local $wmiLocator = ObjCreate("WbemScripting.SWbemLocator") If Not IsObj($wmiLocator) Then Return SetError(3, 99, $aErr) ToolTip("...ConnectServer", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - WmiMonitorID",1,4) Local $oWMIService = $wmiLocator.ConnectServer($sComputer, "\root\WMI", $sUser, $sPassword) If Not IsObj($oWMIService) Then Return SetError(4, 99, $aErr) EndIf ToolTip("...ExecQuery", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - WmiMonitorID",1,4) Local $colItems = $oWMIService.ExecQuery("SELECT * FROM WmiMonitorID", _ "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) ToolTip("...ExecQuery executed."& @CR &"...waiting for data.", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - WmiMonitorID",1,4) If IsObj($colItems) Then ; Class Properties: Names: ; $aReturn[ 1 ][ 0 ] = "Active" $aReturn[ 2 ][ 0 ] = "InstanceName" $aReturn[ 3 ][ 0 ] = "ManufacturerName" $aReturn[ 4 ][ 0 ] = "ProductCodeID" $aReturn[ 5 ][ 0 ] = "SerialNumberID" $aReturn[ 6 ][ 0 ] = "UserFriendlyName" $aReturn[ 7 ][ 0 ] = "UserFriendlyNameLength" $aReturn[ 8 ][ 0 ] = "WeekOfManufacture" $aReturn[ 9 ][ 0 ] = "YearOfManufacture" $aReturn[0][0] = 9 For $objItem In $colItems $aReturn[0][1] = $aReturn[0][1] + 1 If Not Mod( $aReturn[0][1] , 100 ) Then ToolTip("...adding "& $aReturn[0][1] &" of "&$iLimit &" ??", @DesktopWidth - 30,@DesktopHeight - 130, "ScriptOMatic - WmiMonitorID",1,4) If $aReturn[0][1] > $iLimit Then $iExt = 2 ExitLoop EndIf ; Class Properties: Values: ; $aReturn[ 1 ][ $aReturn[0][1] ] = $objItem.Active $aReturn[ 2 ][ $aReturn[0][1] ] = $objItem.InstanceName $aReturn[ 3 ][ $aReturn[0][1] ] = Array_Join( $objItem.ManufacturerName ) $aReturn[ 4 ][ $aReturn[0][1] ] = Array_Join( $objItem.ProductCodeID ) $aReturn[ 5 ][ $aReturn[0][1] ] = Array_Join( $objItem.SerialNumberID ) $aReturn[ 6 ][ $aReturn[0][1] ] = Array_Join( $objItem.UserFriendlyName ) $aReturn[ 7 ][ $aReturn[0][1] ] = $objItem.UserFriendlyNameLength $aReturn[ 8 ][ $aReturn[0][1] ] = $objItem.WeekOfManufacture $aReturn[ 9 ][ $aReturn[0][1] ] = $objItem.YearOfManufacture Next If $aReturn[0][1] = 0 Then $iExt = 1 ReDim $aReturn[$aReturn[0][0] + 1][$aReturn[0][1] + 1] Return SetError( 0 , $iExt , $aReturn ) Else Return SetError(1 ,99 ,$aErr) EndIf EndFunc Func Array_Join($aArray, $sSeparator = " , ") Local $n, $sOut = "" If IsObj($aArray) Then For $value In $aArray $sOut &= $value & $sSeparator Next Return StringTrimRight($sOut, StringLen($sSeparator)) Else For $n = 0 To UBound($aArray) - 1 If $aArray[$n] = 0 Then ContinueLoop $sOut &= Chr($aArray[$n]); & $sSeparator Next Return $sOut Return StringTrimRight($sOut, StringLen($sSeparator)) EndIf EndFunc ;==>Array_Join #Region # ValueToDescription Functions # #EndRegion # ValueToDescription Functions # Func _nice_COMerrorHandler($i = 0) If $i == 1 Then Dim $_nice_COMerrorArray[301][9] $_nice_COMerrorArray[0][0] = 0 $_nice_COMerrorObj = ObjEvent("AutoIt.Error", "_nice_COMerrorHandler") Return EndIf If $i == 2 Then If Not @Compiled Then Local $n = 0, $c = 0, $s = FileRead(@ScriptFullPath) Local $a = StringSplit($s, @CRLF, 1) For $n = 1 To $_nice_COMerrorArray[0][0] If Int($_nice_COMerrorArray[$n][7]) > $a[0] Then ContinueLoop $_nice_COMerrorArray[$n][8] = StringStripWS($a[Int($_nice_COMerrorArray[$n][7])], 3) Next If StringInStr($s, "; only for the ANSI compiled version" & @CRLF) Then For $n = 1 To $a[0] If StringInStr($a[$n], "; only for the ANSI compiled version") Then $c += 1 If $n > 50 Then ExitLoop Next For $n = 1 To $_nice_COMerrorArray[0][0] $_nice_COMerrorArray[$n][7] = $_nice_COMerrorArray[$n][7] - $c Next EndIf EndIf $_nice_COMerrorArray[1][0] = "" ReDim $_nice_COMerrorArray[$_nice_COMerrorArray[0][0] + 1][9] _ArrayDisplay($_nice_COMerrorArray, "ScriptOMatic - COM Errors intercepted ( the script will continue after this screen )") Return EndIf If $_nice_COMerrorArray[0][0] = 300 Then $_nice_COMerrorArray[0][8] = "ScriptLine: only first 300 errors shown !!!" Return EndIf If StringInStr($_nice_COMerrorArray[1][0], "|" & $_nice_COMerrorObj.scriptline & "|") Then Return $i = $_nice_COMerrorArray[0][0] + 1 $_nice_COMerrorArray[0][0] = $i $_nice_COMerrorArray[$i][1] = "0x" & Hex($_nice_COMerrorObj, 8) $_nice_COMerrorArray[$i][2] = $_nice_COMerrorObj.windescription $_nice_COMerrorArray[$i][3] = $_nice_COMerrorObj.source $_nice_COMerrorArray[$i][4] = $_nice_COMerrorObj.helpfile $_nice_COMerrorArray[$i][5] = $_nice_COMerrorObj.helpcontext $_nice_COMerrorArray[$i][6] = $_nice_COMerrorObj.lastdllerror $_nice_COMerrorArray[$i][7] = $_nice_COMerrorObj.scriptline $_nice_COMerrorArray[1][0] = $_nice_COMerrorArray[1][0] & "|" & $_nice_COMerrorObj.scriptline & "|" If $i == 1 Then $_nice_COMerrorArray[0][1] = "ErrorNumber:" $_nice_COMerrorArray[0][2] = "WinDescription:" $_nice_COMerrorArray[0][3] = "Source:" $_nice_COMerrorArray[0][4] = "HelpFile:" $_nice_COMerrorArray[0][5] = "HelpContext:" $_nice_COMerrorArray[0][6] = "LastDLLerror:" $_nice_COMerrorArray[0][7] = "ScriptLineNumber:" $_nice_COMerrorArray[0][8] = "ScriptLine:" EndIf EndFunc ;==>_nice_COMerrorHandler ...some thing like this. That runs. To pay it forward1 point -
It was not the wrong forum, I was replaying to this post " änd need help from the author for configuring an IP Camera using AutoIt.1 point
-
Now I am not exactly sure if this is against the rules. (As Canon does not want you reverse engineering their tools to write your own. And don't offer there SDKs to the general public.) So if it sorry and you can promptly lock this. I came back to AutoIt after a good 5 years just to be able to control my Canon EOS Rebel Camera for the eclipse (August 21, 2017) and the following is what I have done as a "api" to their graphical interface for the camera. #include <String.au3> #include <Array.au3> Local Const $exposures = StringSplit("BULB|30 Sec|25 Sec|20 Sec|15 Sec|13 Sec|10 Sec|8 Sec|6 Sec|5 Sec|4 Sec|3.2 Sec|2.5 Sec|2 Sec|1.6 Sec|1.3 Sec|1 Sec|0.8 Sec|0.6 Sec|0.5 Sec|0.4 Sec|0.3 Sec|1/4 Sec|1/5 Sec|1/6 Sec|1/8 Sec|1/10 Sec|1/13 Sec|1/15 Sec|1/20 Sec|1/25 Sec|1/30 Sec|1/40 Sec|1/50 Sec|1/60 Sec|1/80 Sec|1/100 Sec|1/125 Sec|1/160 Sec|1/200 Sec|1/250 Sec|1/320 Sec|1/400 Sec|1/500 Sec|1/640 Sec|1/800 Sec|1/1000 Sec|1/1250 Sec|1/1600 Sec|1/2000 Sec|1/2500 Sec|1/3200 Sec|1/4000 Sec","|") Local Const $ISOS[6] = ["AUTO","100","200","400","800","1600"] Func Capture() ControlClick(" EOS DIGITAL","","[NAME:takePictureButton]") EndFunc Func BULB() ControlSend(" EOS DIGITAL","","[NAME:olcTv]","{DOWN}") EndFunc Func SetExposure($cur,$expos) $index = _ArraySearch($exposures,$expos) $index1 = _ArraySearch($exposures,$cur) If $index-$index1 < 0 Then ControlSend(" EOS DIGITAL","","[NAME:olcTv]",_StringRepeat("{Left}",$index1-$index)) Else If $index-$index1 > 0 Then ControlSend(" EOS DIGITAL","","[NAME:olcTv]",_StringRepeat("{RIGHT}",$index-$index1)) EndIf EndIF EndFunc Func GUICtrlGetBkColor($hWnd) Local $hDC = _WinAPI_GetDC($hWnd) Local $iColor = _WinAPI_GetPixel($hDC, 10, 10) _WinAPI_ReleaseDC($hWnd, $hDC) Return Hex($iColor,6) EndFunc Func CheckWarning() $i = GUICtrlGetBkColor(ControlGetHandle(" EOS DIGITAL","","[NAME:ledWarning]")) Return $i == "E80000" EndFunc Func SetAutoISO() ControlSend(" EOS DIGITAL","","[NAME:olcIso]","{DOWN}") EndFunc Func SetISO($iso) SetAutoISO() ControlSend(" EOS DIGITAL","","[NAME:olcIso]",_StringRepeat("{RIGHT}",_ArraySearch($ISOS,$iso))) EndFunc Now I know there are probably many problems with this. (Namely the first Const... ) And possibly some other areas that are just not logical. But bear in mind I am uploading this on the 20th after spending 2 days relearning AutoIt after 5 years of using Java and Python. Any improvements would be nice. (I have a lot I need to add still.) I can also work on a way to return the captured image.1 point
-
The UDF from worked for me, though trying to stop it, etc. didn't. What I wanted is to have a way to take a picture 'at will', then show that latest picture for as long as I wanted, then switch back to the webcam when I wanted (in other words, some sort of control over what is happening as well as getting that latest pic to show - in the same spot as the webcam). My total application is not done, so there may be more features I'll put in overall, though here's some code (tested, working on my system) that might be of use to others. Note that it uses 'brute force' methods as I'm still new to GUI, etc. but the end result is that it works! #include <GUIConstants.au3> #include <WebcamUDF.au3> ; create webcam $webcamgui = GUICreate("webcam", 250, 192, @DesktopWidth/2 - 250/2,@DesktopHeight/2 - 192/2, $WS_POPUP) _WebcamInit() _Webcam($webcamgui, 250, 192, 0, 0) GUISetState(@SW_SHOW) $picgui = GUICreate("picture", 251, 192, @DesktopWidth/2 - 250/2, @DesktopHeight/2 - 192/2, $WS_POPUP) GUISetState(@SW_HIDE) ; create controls $gui = GUICreate("controls", 250, 80, @DesktopWidth/2 - 250/2, @DesktopHeight/2 - 192/2 + 192,$WS_POPUP) $button = GUICtrlCreateButton("picture", 10, 10) $webcam = GUICtrlCreateButton("webcam", 90, 10) $snapit = GUICtrlCreateButton("Take Picture", 160,10) $closeit = GUICtrlCreateButton("Close",90,50) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE,$closeit _WebcamStop() Exit Case $button ; create picture $picgui = GUICreate("picture", 250, 192, @DesktopWidth/2 - 250/2, @DesktopHeight/2 - 192/2, $WS_POPUP) $picshow = GUICtrlCreatePic("snapshot.bmp", 0, 0, 250, 192) GUISetState(@SW_SHOW) Case $webcam GUIDelete($picgui) case $snapit GUIDelete($picgui) ConsoleWrite("Taking snapshot ..." & @CRLF) _WebcamSnapShot() ConsoleWrite("Snapshot taken !" & @CRLF) EndSwitch WEnd1 point
-
Webcam UDF
Parsix reacted to BinaryBrother for a topic
Modified Cam snapshot function to convert the image to preferred format. *Tested with PNG, JPG, and BMP. Also fixed any errors the UDF was giving. Also added timestamp switch to capture method. P.S. Yes, I know there were 10 more optimal ways to do the modifications I've done... but here it is anyway. #include-once #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <Date.au3> ;~ ##################################################### ;~ ### ### ;~ ### Webcam UDF ### ;~ ### ### ;~ ### Functions : _WebcamInit() ### ;~ ### _Webcam() ### ;~ ### _WebcamStop() ### ;~ ### _WebcamSnapShot() ### ;~ ### ### ;~ ### Made by L|M|TER ### ;~ ### --------------------------------------------- ### ;~ ### ### ;~ ### Copyright ©2008 - L|M|TER ### ;~ ### Updated and modified - BinaryBrother ### ;~ ##################################################### ;~ Declaring Variables $WM_CAP_START = 0x400 $WM_CAP_UNICODE_START = $WM_CAP_START + 100 $WM_CAP_PAL_SAVEA = $WM_CAP_START + 81 $WM_CAP_PAL_SAVEW = $WM_CAP_UNICODE_START + 81 $WM_CAP_UNICODE_END = $WM_CAP_PAL_SAVEW $WM_CAP_ABORT = $WM_CAP_START + 69 $WM_CAP_DLG_VIDEOCOMPRESSION = $WM_CAP_START + 46 $WM_CAP_DLG_VIDEODISPLAY = $WM_CAP_START + 43 $WM_CAP_DLG_VIDEOFORMAT = $WM_CAP_START + 41 $WM_CAP_DLG_VIDEOSOURCE = $WM_CAP_START + 42 $WM_CAP_DRIVER_CONNECT = $WM_CAP_START + 10 $WM_CAP_DRIVER_DISCONNECT = $WM_CAP_START + 11 $WM_CAP_DRIVER_GET_CAPS = $WM_CAP_START + 14 $WM_CAP_DRIVER_GET_NAMEA = $WM_CAP_START + 12 $WM_CAP_DRIVER_GET_NAMEW = $WM_CAP_UNICODE_START + 12 $WM_CAP_DRIVER_GET_VERSIONA = $WM_CAP_START + 13 $WM_CAP_DRIVER_GET_VERSIONW = $WM_CAP_UNICODE_START + 13 $WM_CAP_EDIT_COPY = $WM_CAP_START + 30 $WM_CAP_END = $WM_CAP_UNICODE_END $WM_CAP_FILE_ALLOCATE = $WM_CAP_START + 22 $WM_CAP_FILE_GET_CAPTURE_FILEA = $WM_CAP_START + 21 $WM_CAP_FILE_GET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 21 $WM_CAP_FILE_SAVEASA = $WM_CAP_START + 23 $WM_CAP_FILE_SAVEASW = $WM_CAP_UNICODE_START + 23 $WM_CAP_FILE_SAVEDIBA = $WM_CAP_START + 25 $WM_CAP_FILE_SAVEDIBW = $WM_CAP_UNICODE_START + 25 $WM_CAP_FILE_SET_CAPTURE_FILEA = $WM_CAP_START + 20 $WM_CAP_FILE_SET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 20 $WM_CAP_FILE_SET_INFOCHUNK = $WM_CAP_START + 24 $WM_CAP_GET_AUDIOFORMAT = $WM_CAP_START + 36 $WM_CAP_GET_CAPSTREAMPTR = $WM_CAP_START + 1 $WM_CAP_GET_MCI_DEVICEA = $WM_CAP_START + 67 $WM_CAP_GET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 67 $WM_CAP_GET_SEQUENCE_SETUP = $WM_CAP_START + 65 $WM_CAP_GET_STATUS = $WM_CAP_START + 54 $WM_CAP_GET_USER_DATA = $WM_CAP_START + 8 $WM_CAP_GET_VIDEOFORMAT = $WM_CAP_START + 44 $WM_CAP_GRAB_FRAME = $WM_CAP_START + 60 $WM_CAP_GRAB_FRAME_NOSTOP = $WM_CAP_START + 61 $WM_CAP_PAL_AUTOCREATE = $WM_CAP_START + 83 $WM_CAP_PAL_MANUALCREATE = $WM_CAP_START + 84 $WM_CAP_PAL_OPENA = $WM_CAP_START + 80 $WM_CAP_PAL_OPENW = $WM_CAP_UNICODE_START + 80 $WM_CAP_PAL_PASTE = $WM_CAP_START + 82 $WM_CAP_SEQUENCE = $WM_CAP_START + 62 $WM_CAP_SEQUENCE_NOFILE = $WM_CAP_START + 63 $WM_CAP_SET_AUDIOFORMAT = $WM_CAP_START + 35 $WM_CAP_SET_CALLBACK_CAPCONTROL = $WM_CAP_START + 85 $WM_CAP_SET_CALLBACK_ERRORA = $WM_CAP_START + 2 $WM_CAP_SET_CALLBACK_ERRORW = $WM_CAP_UNICODE_START + 2 $WM_CAP_SET_CALLBACK_FRAME = $WM_CAP_START + 5 $WM_CAP_SET_CALLBACK_STATUSA = $WM_CAP_START + 3 $WM_CAP_SET_CALLBACK_STATUSW = $WM_CAP_UNICODE_START + 3 $WM_CAP_SET_CALLBACK_VIDEOSTREAM = $WM_CAP_START + 6 $WM_CAP_SET_CALLBACK_WAVESTREAM = $WM_CAP_START + 7 $WM_CAP_SET_CALLBACK_YIELD = $WM_CAP_START + 4 $WM_CAP_SET_MCI_DEVICEA = $WM_CAP_START + 66 $WM_CAP_SET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 66 $WM_CAP_SET_OVERLAY = $WM_CAP_START + 51 $WM_CAP_SET_PREVIEW = $WM_CAP_START + 50 $WM_CAP_SET_PREVIEWRATE = $WM_CAP_START + 52 $WM_CAP_SET_SCALE = $WM_CAP_START + 53 $WM_CAP_SET_SCROLL = $WM_CAP_START + 55 $WM_CAP_SET_SEQUENCE_SETUP = $WM_CAP_START + 64 $WM_CAP_SET_USER_DATA = $WM_CAP_START + 9 $WM_CAP_SET_VIDEOFORMAT = $WM_CAP_START + 45 $WM_CAP_SINGLE_FRAME = $WM_CAP_START + 72 $WM_CAP_SINGLE_FRAME_CLOSE = $WM_CAP_START + 71 $WM_CAP_SINGLE_FRAME_OPEN = $WM_CAP_START + 70 $WM_CAP_STOP = $WM_CAP_START + 68 $cap = "" $avi = "" $user = "" $snapfile = @ScriptDir & "\snapshot.bmp" ;~ ########################################################## ;~ Function Name : _WebcamInit() ;~ Description : Starts the webcam image capturing session ;~ Author : L|M|TER ;~ ########################################################## Func _WebcamInit() $avi = DllOpen("avicap32.dll") $user = DllOpen("user32.dll") EndFunc ;==>_WebcamInit ;~ ########################################################## ;~ Function Name : _Webcam($gui,$h,$w,$l,$t) ;~ Description : Creates a webcam preview window ;~ Parameter(s): ;~ $gui - The gui where the webcam window should be created ;~ $h - The height of the webcam window ;~ $w - The width of the webcam window ;~ $l - The left position of the webcam window ;~ $t - The top position of the webcam window ;~ NOTE : All parameters required ! ;~ Author : L|M|TER ;~ ########################################################## Func _Webcam($gui, $w, $h, $l, $t) $cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD, $WS_VISIBLE), "int", $l, "int", $t, "int", $w, "int", $h, "hwnd", $gui, "int", 1) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", 0, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_SCALE, "int", 1, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_OVERLAY, "int", 1, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEW, "int", 1, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEWRATE, "int", 1, "int", 0) EndFunc ;==>_Webcam ;~ ########################################################## ;~ Function Name : _WebcamStop() ;~ Description : Closes the webcam image capturing session ;~ Author : L|M|TER ;~ ########################################################## Func _WebcamStop() DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_END, "int", 0, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_DISCONNECT, "int", 0, "int", 0) DllClose($user) DllClose($avi) EndFunc ;==>_WebcamStop ;~ ########################################################## ;~ Function Name : _WebcamSnapShot($file) ;~ Description : Takes a snapshot ;~ Parameter(s): ;~ $file (Optional) - The path to the file where the snapshot will be saved (Default : @ScriptDir & "\snapshot.bmp") ;~ Author : L|M|TER ;~ ########################################################## Func _WebcamSnapShot($Dest = $snapfile, $AddTimeStamp = false) $RandomFileName = Random(9000, 99999, 1) & ".bmp" DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_GRAB_FRAME_NOSTOP, "int", 0, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_FILE_SAVEDIBA, "int", 0, "str", $RandomFileName) _ConvertImage($RandomFileName, $Dest, $AddTimeStamp) FileDelete($RandomFileName) EndFunc ;==>_WebcamSnapShot ;~ ########################################################## ;~ Function Name : _ConvertImage($file) (Handles Timestamping as well) ;~ Description : Converts image ;~ Parameter(s): ;~ $Src - The path to the file where the snapshot was saved in BMP ;~ $Dest - Destination file path with preferred extension ;~ $AddTimeStamp - Bool add timestamp ;~ Author : BinaryBrother (Internal use only) ;~ ########################################################## Func _ConvertImage($Src, $Dest, $AddTimeStamp = False) _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($Src) If $AddTimeStamp Then $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage) $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, 16, 1) $tLayout = _GDIPlus_RectFCreate(500, 415, 150, 100) _GDIPlus_GraphicsDrawStringEx($hGraphic, _NowDate() & @CRLF & _NowTime(), $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) EndIf _GDIPlus_ImageSaveToFile($hImage, $Dest) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() EndFunc ;==>_ConvertImageWebcam.au31 point -
Hi All, Based on the script provided here and TCP Server/Client UDP (Event-Driven) provided in another thread, I created a version of a remote webcam viewer with the ability to control from client such as changing capture source from either webcam or desktopchange refresh rate of browser from either 1s, 3s (default) or 5spause and unpause captureclose the program remotelyJust run Server.au3 from the PC that you wish to monitor. Run Client.au3 from another PC and specify the IP of the PC running Server.au3 via Tray Menu. Just point your client browser to h**p://Server-IP:6969 to view. You need TCP.au3 (event-driven) for this to work. Thanks.. Server.au3 Client.au3 TCP.au31 point
-
Yes, you misunderstood. No problem. The third param is GdipLoadImageFromFile. There is no such function in Gdiplus. But the Bitmap class had a method "FromFile".0 points
-
Thanks Celtic88. When I compile to exe from your code (for example: WebcamSnap.exe). When I run WebcamSnap on Windows 10, screen in form is green colour. Why? How do you give me more code ? Pls. WebcamSnap_Ask_4rum.au30 points