Jump to content
Sign in to follow this  
FireFox

IP Camera stream + record

Recommended Posts

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 :

Yay, it's me.


Xm5u5DQ.jpg


Attachment :

IP Camera.au3

IP Camera.au3 (Previous: 34 downloads)
 
Enjoy, I'm watching U !

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Thank you. I was implementing some improvements (add more than one camera & settings) but I'm busy with another program.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Thanks for the awesome script! I have modified it to give the option to toggle between multiple cameras and also display 2 at once! works great - except the second camera has approximately 7 second delay. Any ideas how I can fix that?

Thanks again for the great script!

 

#RequireAdmin
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3>
#include <Misc.au3>
#include <ButtonConstants.au3>
#include <Constants.au3>
#include <StaticConstants.au3>
#include <GDIPlus.au3>

Opt("GUIOnEventMode", 1)

Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1 + 2)
TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "_Exit")

TraySetToolTip(StringReplace(@ScriptName, ".exe", ""))

TraySetState(1)

Global $script_name = "Camera"
Global $script_version = $script_name & " v" & FileGetVersion(@ScriptName, "FileVersion")
Global $msg_normal = 262144, $msg_prompt = 262148, $msg_retry = 262150, $msg_error = 262160

Global $x_position, $y_position
Global $toggle_button, $always_on_top

Global Const $STM_SETIMAGE = 0x0172

Global $blGUIMinimized = False

Global $title_A, $camera_selection_A, $default_camera_A
Global $bRecvtmp_A = Binary(""), $bStream_A = $bRecvtmp_A
Global $iImgLen_A = 0, $iStreamLen_A = 0, $iWritten_A = 0, $iEOH_A = 0, $iContLenPos_A = 0, $pBuffer_A = 0
Global Const $iContLengthLen_A = StringLen("Content-Length: ")
Global $sStream_A = "", $sTrim2ContLen_A = ""
Global $hBMP_A = 0, $hHBITMAP2_A = 0, $GUI = 0, $pPic_A = 0, $hPic_A = 0
Global $iSocket_A, $iIPAddress_A, $iPort = 80

Global $title_B, $camera_combo_B, $set_default_button_B, $camera_selection_B, $default_camera_B
Global $bRecvtmp_B = Binary(""), $bStream_B = $bRecvtmp_B
Global $iImgLen_B = 0, $iStreamLen_B = 0, $iWritten_B = 0, $iEOH_B = 0, $iContLenPos_B = 0, $pBuffer_B = 0
Global Const $iContLengthLen_B = StringLen("Content-Length: ")
Global $sStream_B = "", $sTrim2ContLen_B = ""
Global $hBMP_B = 0, $hHBITMAP2_B = 0, $pPic_B = 0, $hPic_B = 0
Global $iSocket_B, $iIPAddress_B

$default_cameras = ReadSettings()

$array = StringSplit($default_cameras, "|")

$default_camera_A = $array[1]
$default_camera_B = $array[2]

If $always_on_top = "True" Then
$GUI = GUICreate($script_version, 320, 310, $x_position, $y_position, $GUI_SS_DEFAULT_GUI, $WS_EX_TOPMOST)
Else
$GUI = GUICreate($script_version, 320, 310, $x_position, $y_position, $GUI_SS_DEFAULT_GUI)
EndIf

$combo_selections = "Room 1|Room 2|Room 3|Room 4"

$camera_combo_A = GUICtrlCreateCombo("", 3, 3, 95, 15, $CBS_DROPDOWNLIST)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKSIZE))
GUICtrlSetData(-1, $combo_selections, $default_camera_A)
GUICtrlSetOnEvent(-1, "SetCamera_A")

$set_default_button_A = GUICtrlCreateButton("Set As Default", 3, 25, 95, 15)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKSIZE))
GUICtrlSetOnEvent(-1, "SetDefault_A")
GUICtrlSetFont(-1, 7)
GUICtrlSetTip(-1, "Set current camera as default")

$always_on_top_checkbox = GUICtrlCreateCheckbox("Always on Top", 242, 5, 77, 12)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKTOP, $GUI_DOCKSIZE))
GUICtrlSetOnEvent(-1, "SetTopMost")
GUICtrlSetFont(-1, 7)
GUICtrlSetTip(-1, "Set this window to be on top of all other windows")

If $always_on_top = "True" Then
GUICtrlSetState(-1, $GUI_CHECKED)
EndIf

$title_A = GUICtrlCreateLabel("", 0, 50, 320, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKSIZE))
GUICtrlSetBkColor(-1, 0x004E98)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 9, 600)

TCPStartup()

SetCamera_A()

$toggle_button = GUICtrlCreateButton(">>", 297, 30, 20, 15)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKTOP, $GUI_DOCKSIZE))
GUICtrlSetOnEvent(-1, "Toggle_GUI")
GUICtrlSetTip(-1, "Add an additional camera")

$pPic_A = GUICtrlCreatePic("", 0, 70, 320, 240, $SS_BITMAP)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKSIZE))
GUICtrlSetState($pPic_A, $GUI_DISABLE)
$hPic_A = GUICtrlGetHandle($pPic_A)

If $default_camera_B <> "NONE" Then
Toggle_GUI()
EndIf

GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND")

GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)

GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

GUISetState()

_GDIPlus_Startup()

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch

;1st camera
$bRecvtmp_A = TCPRecv($iSocket_A, 4096, 1) ;4kb
If @error Then ContinueLoop

If Not BinaryLen($bRecvtmp_A) Then ContinueLoop
$bStream_A &= $bRecvtmp_A

If $iImgLen_A = 0 Then
$sStream_A = BinaryToString($bStream_A)

$iContLenPos_A = StringInStr($sStream_A, "Content-Length: ", 2)
$iEOH_A = StringInStr($sStream_A, @CRLF & @CRLF, 2, 1, $iContLenPos_A)

If $iEOH_A = 0 Or $iContLenPos_A = 0 Then ContinueLoop

$sTrim2ContLen_A = StringTrimLeft($sStream_A, $iContLenPos_A + $iContLengthLen_A - 1)

$iImgLen_A = Number(StringLeft($sTrim2ContLen_A, StringInStr($sTrim2ContLen_A, @CR, 2) - 1))

$bStream_A = BinaryMid($bStream_A, $iEOH_A + 4)
EndIf

If $iImgLen_A = 0 Then ContinueLoop

$iStreamLen_A = BinaryLen($bStream_A)
If $iStreamLen_A < $iImgLen_A Then ContinueLoop

If Not $blGUIMinimized Then
$hBMP_A = Load_BMP_From_Mem($bStream_A)

$hHBITMAP2_A = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBMP_A)

_WinAPI_DeleteObject(_SendMessage($hPic_A, $STM_SETIMAGE, 0, $hHBITMAP2_A))

_GDIPlus_ImageDispose($hBMP_A)
_WinAPI_DeleteObject($hHBITMAP2_A)
EndIf

$iImgLen_A = 0

;2nd camera
$bRecvtmp_B = TCPRecv($iSocket_B, 4096, 1) ;4kb
If @error Then ContinueLoop

If Not BinaryLen($bRecvtmp_ B) Then ContinueLoop
$bStream_B &= $bRecvtmp_B

If $iImgLen_B = 0 Then
$sStream_B = BinaryToString($bStream_ B)

$iContLenPos_B = StringInStr($sStream_B, "Content-Length: ", 2)
$iEOH_B = StringInStr($sStream_B, @CRLF & @CRLF, 2, 1, $iContLenPos_ B)

If $iEOH_B = 0 Or $iContLenPos_B = 0 Then ContinueLoop

$sTrim2ContLen_B = StringTrimLeft($sStream_B, $iContLenPos_B + $iContLengthLen_B - 1)

$iImgLen_B = Number(StringLeft($sTrim2ContLen_B, StringInStr($sTrim2ContLen_B, @CR, 2) - 1))

$bStream_B = BinaryMid($bStream_B, $iEOH_B + 4)
EndIf

If $iImgLen_B = 0 Then ContinueLoop

$iStreamLen_B = BinaryLen($bStream_ B)
If $iStreamLen_B < $iImgLen_B Then ContinueLoop

If Not $blGUIMinimized Then
$hBMP_B = Load_BMP_From_Mem($bStream_ B)

$hHBITMAP2_B = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBMP_ B)

_WinAPI_DeleteObject(_SendMessage($hPic_B, $STM_SETIMAGE, 0, $hHBITMAP2_ B))

_GDIPlus_ImageDispose($hBMP_ B)
_WinAPI_DeleteObject($hHBITMAP2_ B)
EndIf

$iImgLen_B = 0
WEnd

Func Toggle_GUI()

$window_position = WinGetPos($GUI)

$window_x_position = $window_position[0]
$window_y_position = $window_position[1]
$window_width = $window_position[2]
$window_height = $window_position[3]

If $window_width = 326 Then
$camera_selection_A = GUICtrlRead($camera_combo_A)

If $camera_selection_A = "" Then
MsgBox($msg_error, $script_name, "Please select a primary view camera first.")
Return
EndIf

GUICtrlSetData($toggle_button, "<<")

WinMove($GUI, "", $window_x_position, $window_y_position, 646, $window_height)

$camera_combo_B = GUICtrlCreateCombo("", 320, 3, 95, 15, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, $combo_selections, $default_camera_ B)
GUICtrlSetOnEvent(-1, "SetCamera_B")

$set_default_button_B = GUICtrlCreateButton("Set As Default", 320, 25, 95, 15)
GUICtrlSetOnEvent(-1, "SetDefault_B")
GUICtrlSetFont(-1, 7)
GUICtrlSetTip(-1, "Set current camera as default")

$title_B = GUICtrlCreateLabel("", 320, 50, 320, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetBkColor(-1, 0x004E98)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 9, 600)

$pPic_B = GUICtrlCreatePic("", 320, 70, 320, 240, $SS_BITMAP)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKSIZE))
GUICtrlSetState($pPic_B, $GUI_DISABLE)
$hPic_B = GUICtrlGetHandle($pPic_ B)

SetCamera_B()
EndIf

If $window_width = 646 Then
GUICtrlSetData($toggle_button, ">>")

WinMove($GUI, "", $window_x_position, $window_y_position, 326, $window_height)

GUICtrlDelete($camera_combo_ B)
GUICtrlDelete($set_default_button_ B)
GUICtrlDelete($title_ B)
GUICtrlDelete($pPic_ B)

RegRead("HKLM\Software\Camera", "Default_B")

If Not @error Then
$prompt = MsgBox($msg_prompt, $script_name, "Remove 2nd camera default?")

If $prompt = 6 Then
RegDelete("HKLM\Software\Camera", "Default_B")

$default_camera_B = ""
EndIf
EndIf
EndIf

EndFunc ;==>Toggle_GUI

Func ReadSettings()

$ExtendedWidth = _WinAPI_GetSystemMetrics(78)
$ExtendedHeight = _WinAPI_GetSystemMetrics(79)

$always_on_top = RegRead("HKLM\Software\Camera", "TopMost")
$default_camera_A = RegRead("HKLM\Software\Camera", "Default_A")

If @error Then
$default_camera_A = RegRead("HKLM\Software\Camera", "Default")
If @error Then
$default_camera_A = "NONE"
Else
RegDelete("HKLM\Software\Camera", "Default")
RegWrite("HKLM\Software\Camera", "Default_A", "REG_SZ", $default_camera_A)
EndIf
EndIf

$default_camera_B = RegRead("HKLM\Software\Camera", "Default_B")

If @error Then
$default_camera_B = "NONE"
EndIf

$x_position = RegRead("HKLM\Software\Camera", "X_Position")

If $x_position = "" Then
$x_position = "0"
EndIf

If $x_position < 0 Then
$x_position = "0"
EndIf

If $x_position > $ExtendedWidth - 150 Then
$x_position = "0"
EndIf

$y_position = RegRead("HKLM\Software\Camera", "Y_Position")

If $y_position = "" Then
$y_position = "0"
EndIf

If $y_position > 800 Then
$y_position = "0"
EndIf

If @DesktopHeight = $ExtendedHeight Then
If $y_position < 0 Then
$y_position = "0"
EndIf
EndIf

If @DesktopHeight <> $ExtendedHeight Then
$y_topmost_coordinate = @DesktopHeight - $ExtendedHeight
If $y_position < $y_topmost_coordinate Then
$y_position = $y_topmost_coordinate
EndIf
EndIf

Return $default_camera_A & "|" & $default_camera_B

EndFunc ;==>ReadSettings

Func SetTopMost()

If BitAND(GUICtrlRead($always_on_top_checkbox), $GUI_CHECKED) Then
$topmost = True
WinSetOnTop($script_version, "", 1)
EndIf

If BitAND(GUICtrlRead($always_on_top_checkbox), $GUI_UNCHECKED) Then
$topmost = False
WinSetOnTop($script_version, "", 0)
EndIf

RegWrite("HKLM\Software\Camera", "TopMost", "REG_SZ", $topmost)

EndFunc ;==>SetTopMost

Func SetDefault_A()

$default_camera_A = GUICtrlRead($camera_combo_A)

If $default_camera_A = "" Then
MsgBox($msg_error, $script_name, "Please make a selection first.")
Return
EndIf

RegWrite("HKLM\Software\Camera", "Default_A", "REG_SZ", $default_camera_A)

MsgBox(262144, $script_version, $default_camera_A & " has been set as default.")

EndFunc ;==>SetDefault_A

Func SetDefault_B()

$default_camera_B = GUICtrlRead($camera_combo_ B)

If $default_camera_B = "" Then
MsgBox($msg_error, $script_name, "Please make a selection first.")
Return
EndIf

RegWrite("HKLM\Software\Camera", "Default_B", "REG_SZ", $default_camera_ B)

MsgBox(262144, $script_version, $default_camera_B & " has been set as default.")

EndFunc ;==>SetDefault_B

Func SetPosition()

$position_array = WinGetPos($script_version, "")

$x_position = $position_array[0]
$y_position = $position_array[1]

RegWrite("HKLM\Software\Camera", "X_Position", "REG_SZ", $x_position)
RegWrite("HKLM\Software\Camera", "Y_Position", "REG_SZ", $y_position)

EndFunc ;==>SetPosition

Func SetCamera_A()

$camera_selection_A = GUICtrlRead($camera_combo_A)

If $camera_selection_A = "" Then
MsgBox($msg_normal, $script_name, "Please select a camera from the dropdown and Set As Default.")
Return
EndIf

Select
Case $camera_selection_A = "Room 1"
$iIPAddress_A = "192.168.1.20"
Case $camera_selection_A = "Room 2"
$iIPAddress_A = "192.168.1.30"
Case $camera_selection_A = "Room 3"
$iIPAddress_A = "192.168.1.40"
Case $camera_selection_A = "Room 4"
$iIPAddress_A = "192.168.1.50"
EndSelect

$iSocket_A = TCPConnect($iIPAddress_A, $iPort)
If @error Then
MsgBox($msg_error, $script_name, "Could not connect to " & $camera_selection_A)
Return
EndIf

$shtauth = "cm9vdDpjYXBpdGFs" ;base64 - root:capital

TCPSend($iSocket_A, _
"GET /-wvhttp-01-/GetOneShot?image_size=320x240&frame_count=0 HTTP/1.1" & @CRLF & _
"Host: " & $iIPAddress_A & ":" & $iPort & @CRLF & _
"Connection: keep-alive" & @CRLF & _
"Authorization: Basic " & $shtauth & @CRLF & @CRLF)

GUICtrlSetData($title_A, $camera_selection_A)

EndFunc ;==>SetCamera_A

Func SetCamera_B()

$camera_selection_B = GUICtrlRead($camera_combo_ B)

If $camera_selection_B = "" Then
Return
EndIf

Select
Case $camera_selection_B = "Room 1"
$iIPAddress_B = "192.168.1.20"
Case $camera_selection_B = "Room 2"
$iIPAddress_B = "192.168.1.30"
Case $camera_selection_B = "Room 3"
$iIPAddress_B = "192.168.1.40"
Case $camera_selection_B = "Room 4"
$iIPAddress_B = "192.168.1.50"
EndSelect

$iSocket_B = TCPConnect($iIPAddress_B, $iPort)
If @error Then
MsgBox($msg_error, $script_name, "Could not connect to " & $camera_selection_ B)
Return
EndIf

$shtauth = "cm9vdDpjYXBpdGFs" ;base64 - root:capital

TCPSend($iSocket_B, _
"GET /-wvhttp-01-/GetOneShot?image_size=320x240&frame_count=0 HTTP/1.1" & @CRLF & _
"Host: " & $iIPAddress_B & ":" & $iPort & @CRLF & _
"Connection: keep-alive" & @CRLF & _
"Authorization: Basic " & $shtauth & @CRLF & @CRLF)

GUICtrlSetData($title_B, $camera_selection_ B)

EndFunc ;==>SetCamera_B

Func Debug($variable1 = "", $variable2 = "", $variable3 = "")

If IsArray($variable1) Then
_ArrayDisplay($variable1)
Else
If $variable2 <> "" Then
$variable1 &= @CRLF & $variable2
EndIf

If $variable3 <> "" Then
$variable1 &= @CRLF & $variable3
EndIf

ClipPut($variable1)
MsgBox($msg_normal, "Debug", $variable1)
EndIf

EndFunc ;==>Debug

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($mem_image)
;author: UEZ
;Additional Code: thanks to progandy for the MemGlobalAlloc and tVARIANT lines
If Not IsBinary($mem_image) Then Return SetError(1, 0, 0)

Local Const $memBitmap = Binary($mem_image)
Local Const $len = BinaryLen($memBitmap)
Local Const $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE)
Local Const $pData = _MemGlobalLock($hData)
Local $tMem = DllStructCreate("byte[" & $len & "]", $pData)

DllStructSetData($tMem, 1, $memBitmap)
_MemGlobalUnlock($hData)

Local $hStream = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0)
$hStream = $hStream[3]

Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0)
$hBitmap = $hBitmap[2]
Local Const $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr")
DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _
"dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT))
$tMem = 0
Return $hBitmap
EndFunc ;==>Load_BMP_From_Mem

Func _Exit()
TCPCloseSocket($iSocket_A)
TCPCloseSocket($iSocket_ B)
TCPShutdown()
SetPosition()
Exit
EndFunc ;==>_Exit
Edited by gcue

Share this post


Link to post
Share on other sites

I will take a look at it when I will have the time to test it in real conditions.

I might have told you (this means maybe nothing in english...) I created a script to display up to 4 cameras, however I was too lazy to finish it BUT I have to, so someday I will post it.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

nice! and no delay between any of them?

id appreciate any help =)

thanks again for the cool script 8)

Share this post


Link to post
Share on other sites

nice! and no delay between any of them?

I don't know. But I'm sure there won't be any delay :P

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

i think it might have to do with these lines in the while loop....

$bRecvtmp_A = TCPRecv($iSocket_A, 4096, 1) ;4kb
If @error Then ContinueLoop

$bRecvtmp_B = TCPRecv($iSocket_B, 4096, 1) ;4kb
If @error Then ContinueLoop

The original code does an exitloop instead of continueloop but exitloop exits the script gracefully. continueloop crashes it.

This seems to be the issue not sure yet tho

Share this post


Link to post
Share on other sites

It's wrong indeed.

 

If nothing is received on the socket A, all the script of for the camera B will be paused.

;Instead of
...
If Not BinaryLen($bRecvtmp_A) Then ContinueLoop
$bStream_A &= $bRecvtmp_A
...
 
;do
...
If BinaryLen($bRecvtmp_A) > 0 Then
    $bStream_A &= $bRecvtmp_A
    ;process camera A
    ...
EndIf
 
;socket B + process camera B
Br, FireFox. Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

cool - i wrapped the IF statement around the entire processing of camera_A (in the while loop)

does this look like it will fix the crashes?

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch

;1st camera
$bRecvtmp_A = TCPRecv($iSocket_A, 4096, 1) ;4kb
If @error Then ContinueLoop

If BinaryLen($bRecvtmp_A) > 0 Then
$bStream_A &= $bRecvtmp_A

If $iImgLen_A = 0 Then
$sStream_A = BinaryToString($bStream_A)

$iContLenPos_A = StringInStr($sStream_A, "Content-Length: ", 2)
$iEOH_A = StringInStr($sStream_A, @CRLF & @CRLF, 2, 1, $iContLenPos_A)

If $iEOH_A = 0 Or $iContLenPos_A = 0 Then ContinueLoop

$sTrim2ContLen_A = StringTrimLeft($sStream_A, $iContLenPos_A + $iContLengthLen_A - 1)

$iImgLen_A = Number(StringLeft($sTrim2ContLen_A, StringInStr($sTrim2ContLen_A, @CR, 2) - 1))

$bStream_A = BinaryMid($bStream_A, $iEOH_A + 4)
EndIf

If $iImgLen_A = 0 Then ContinueLoop

$iStreamLen_A = BinaryLen($bStream_A)
If $iStreamLen_A < $iImgLen_A Then ContinueLoop

If Not $blGUIMinimized Then
$hBMP_A = Load_BMP_From_Mem($bStream_A)

$hHBITMAP2_A = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBMP_A)

_WinAPI_DeleteObject(_SendMessage($hPic_A, $STM_SETIMAGE, 0, $hHBITMAP2_A))

_GDIPlus_ImageDispose($hBMP_A)
_WinAPI_DeleteObject($hHBITMAP2_A)
EndIf

$iImgLen_A = 0
EndIf

;2nd camera
$bRecvtmp_B = TCPRecv($iSocket_B, 4096, 1) ;4kb
If @error Then ContinueLoop

If Not BinaryLen($bRecvtmp_ B) Then ContinueLoop
$bStream_B &= $bRecvtmp_B

If $iImgLen_B = 0 Then
$sStream_B = BinaryToString($bStream_ B)

$iContLenPos_B = StringInStr($sStream_B, "Content-Length: ", 2)
$iEOH_B = StringInStr($sStream_B, @CRLF & @CRLF, 2, 1, $iContLenPos_ B)

If $iEOH_B = 0 Or $iContLenPos_B = 0 Then ContinueLoop

$sTrim2ContLen_B = StringTrimLeft($sStream_B, $iContLenPos_B + $iContLengthLen_B - 1)

$iImgLen_B = Number(StringLeft($sTrim2ContLen_B, StringInStr($sTrim2ContLen_B, @CR, 2) - 1))

$bStream_B = BinaryMid($bStream_B, $iEOH_B + 4)
EndIf

If $iImgLen_B = 0 Then ContinueLoop

$iStreamLen_B = BinaryLen($bStream_ B)
If $iStreamLen_B < $iImgLen_B Then ContinueLoop

If Not $blGUIMinimized Then
$hBMP_B = Load_BMP_From_Mem($bStream_ B)

$hHBITMAP2_B = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBMP_ B)

_WinAPI_DeleteObject(_SendMessage($hPic_B, $STM_SETIMAGE, 0, $hHBITMAP2_ B))

_GDIPlus_ImageDispose($hBMP_ B)
_WinAPI_DeleteObject($hHBITMAP2_ B)
EndIf

$iImgLen_B = 0
WEnd

Share this post


Link to post
Share on other sites

did i wrap the if statement correctly?

does it seem like it will fix the crashes?

thanks again for your help firefox!

Share this post


Link to post
Share on other sites

did i wrap the if statement correctly?

does it seem like it will fix the crashes?

I will take a look at it later.

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

wasnt sure if you meant i should also make the same change to camera_B

testing it now to see if it crashes...

sorry to be a bother with this - i have a bunch of users using this and its crashing for all of them - *sigh*

thanks soooo much for your help!!!

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch

;1st camera
$bRecvtmp_A = TCPRecv($iSocket_A, 4096, 1) ;4kb
If @error Then ContinueLoop

If BinaryLen($bRecvtmp_A) > 0 Then
$bStream_A &= $bRecvtmp_A

If $iImgLen_A = 0 Then
$sStream_A = BinaryToString($bStream_A)

$iContLenPos_A = StringInStr($sStream_A, "Content-Length: ", 2)
$iEOH_A = StringInStr($sStream_A, @CRLF & @CRLF, 2, 1, $iContLenPos_A)

If $iEOH_A = 0 Or $iContLenPos_A = 0 Then ContinueLoop

$sTrim2ContLen_A = StringTrimLeft($sStream_A, $iContLenPos_A + $iContLengthLen_A - 1)

$iImgLen_A = Number(StringLeft($sTrim2ContLen_A, StringInStr($sTrim2ContLen_A, @CR, 2) - 1))

$bStream_A = BinaryMid($bStream_A, $iEOH_A + 4)
EndIf

If $iImgLen_A = 0 Then ContinueLoop

$iStreamLen_A = BinaryLen($bStream_A)
If $iStreamLen_A < $iImgLen_A Then ContinueLoop

If Not $blGUIMinimized Then
$hBMP_A = Load_BMP_From_Mem($bStream_A)

$hHBITMAP2_A = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBMP_A)

_WinAPI_DeleteObject(_SendMessage($hPic_A, $STM_SETIMAGE, 0, $hHBITMAP2_A))

_GDIPlus_ImageDispose($hBMP_A)
_WinAPI_DeleteObject($hHBITMAP2_A)
EndIf

$iImgLen_A = 0
EndIf

;2nd camera
$bRecvtmp_B = TCPRecv($iSocket_B, 4096, 1) ;4kb
If @error Then ContinueLoop

If BinaryLen($bRecvtmp_ B) > 0 Then
$bStream_B &= $bRecvtmp_B

If $iImgLen_B = 0 Then
$sStream_B = BinaryToString($bStream_ B)

$iContLenPos_B = StringInStr($sStream_B, "Content-Length: ", 2)
$iEOH_B = StringInStr($sStream_B, @CRLF & @CRLF, 2, 1, $iContLenPos_ B)

If $iEOH_B = 0 Or $iContLenPos_B = 0 Then ContinueLoop

$sTrim2ContLen_B = StringTrimLeft($sStream_B, $iContLenPos_B + $iContLengthLen_B - 1)

$iImgLen_B = Number(StringLeft($sTrim2ContLen_B, StringInStr($sTrim2ContLen_B, @CR, 2) - 1))

$bStream_B = BinaryMid($bStream_B, $iEOH_B + 4)
EndIf

If $iImgLen_B = 0 Then ContinueLoop

$iStreamLen_B = BinaryLen($bStream_ B)
If $iStreamLen_B < $iImgLen_B Then ContinueLoop

If Not $blGUIMinimized Then
$hBMP_B = Load_BMP_From_Mem($bStream_ B)

$hHBITMAP2_B = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBMP_ B)

_WinAPI_DeleteObject(_SendMessage($hPic_B, $STM_SETIMAGE, 0, $hHBITMAP2_ B))

_GDIPlus_ImageDispose($hBMP_ B)
_WinAPI_DeleteObject($hHBITMAP2_ B)
EndIf

$iImgLen_B = 0
EndIf
WEnd

Share this post


Link to post
Share on other sites

Bumping the thread won't make me look at the problem earlier that I can.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

actually i didnt mean to bump it just letting you know what im trying and what worked/didnt work

sorry if you thought the latter.

:-/

Share this post


Link to post
Share on other sites

I haven't tested it, but try this loop:

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
 
    ;1st camera
    $bRecvtmp_A = TCPRecv($iSocket_A, 4096, 1) ;4kb
 
    If @error = 0 And BinaryLen($bRecvtmp_A) > 0 Then
        $bStream_A &= $bRecvtmp_A
 
        If $iImgLen_A = 0 Then
            $sStream_A = BinaryToString($bStream_A)
 
            $iContLenPos_A = StringInStr($sStream_A, "Content-Length: ", 2)
            $iEOH_A = StringInStr($sStream_A, @CRLF & @CRLF, 2, 1, $iContLenPos_A)
 
            If $iEOH_A > 0 And $iContLenPos_A > 0 Then
                $sTrim2ContLen_A = StringTrimLeft($sStream_A, $iContLenPos_A + $iContLengthLen_A - 1)
 
                $iImgLen_A = Number(StringLeft($sTrim2ContLen_A, StringInStr($sTrim2ContLen_A, @CR, 2) - 1))
 
                $bStream_A = BinaryMid($bStream_A, $iEOH_A + 4)
            EndIf
        EndIf
 
        If $iImgLen_A > 0 Then
            $iStreamLen_A = BinaryLen($bStream_A)
            If $iStreamLen_A >= $iImgLen_A Then
                If Not $blGUIMinimized Then
                    $hBMP_A = Load_BMP_From_Mem($bStream_A)
 
                    $hHBITMAP2_A = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBMP_A)
 
                    _WinAPI_DeleteObject(_SendMessage($hPic_A, $STM_SETIMAGE, 0, $hHBITMAP2_A))
 
                    _GDIPlus_ImageDispose($hBMP_A)
                    _WinAPI_DeleteObject($hHBITMAP2_A)
                EndIf
 
                $iImgLen_A = 0
            EndIf
        EndIf
    EndIf
 
    ;2nd camera
    $bRecvtmp_B = TCPRecv($iSocket_B, 4096, 1) ;4kb
 
    If @error = 0 And BinaryLen($bRecvtmp_B) > 0 Then
        $bStream_B &= $bRecvtmp_B
 
        If $iImgLen_B = 0 Then
            $sStream_B = BinaryToString($bStream_B)
 
            $iContLenPos_B = StringInStr($sStream_B, "Content-Length: ", 2)
            $iEOH_B = StringInStr($sStream_B, @CRLF & @CRLF, 2, 1, $iContLenPos_B)
 
            If $iEOH_B > 0 And $iContLenPos_B > 0 Then
                $sTrim2ContLen_B = StringTrimLeft($sStream_B, $iContLenPos_B + $iContLengthLen_B - 1)
 
                $iImgLen_B = Number(StringLeft($sTrim2ContLen_B, StringInStr($sTrim2ContLen_B, @CR, 2) - 1))
 
                $bStream_B = BinaryMid($bStream_B, $iEOH_B + 4)
            EndIf
        EndIf
 
        If $iImgLen_B > 0 Then
            $iStreamLen_B = BinaryLen($bStream_B)
            If $iStreamLen_B >= $iImgLen_B Then
                If Not $blGUIMinimized Then
                    $hBMP_B = Load_BMP_From_Mem($bStream_B)
 
                    $hHBITMAP2_B = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBMP_B)
 
                    _WinAPI_DeleteObject(_SendMessage($hPic_B, $STM_SETIMAGE, 0, $hHBITMAP2_B))
 
                    _GDIPlus_ImageDispose($hBMP_B)
                    _WinAPI_DeleteObject($hHBITMAP2_B)
                EndIf
 
                $iImgLen_B = 0
            EndIf
        EndIf
    EndIf
WEnd
Br, FireFox.

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By pboom
      Attached is a full Controller for SONY Cameras using the VISCA protocol, written in AutoIt. Everything required to build a EXE file is included.
      I wrote this software because I couldn't find decent control software for these cameras, I tried at least a dozen packages. So in my mind, anyway, it is better than anything else out there.
      The software will also controls several other pieces of AV equipment. The software is very specific to my application but should be easy to adapt and would make a good starting point for someone else trying to roll there own Audio Video control program.
      It features the following;
      Unlimited number of presets Macros to combine recall of presets Supports JoyStick control Supports up to 7 cameras in Daisy chain configuration. Unique Pan Tilt control pad provides variable speed control by dragging Mouse on pad, makes the cameras easy to control. Web Server allows Macros to be activated from OBS Studio Modular structure should make the code adaptable to other camera control protocols. Modular structure should make additional hardware support easy to add or remove. Will show errors during start up if hardware is not present but it will run. Serial ports configured with included INI file. Joystick response can be adjusted through settings in the INI file. Lots of documentation on how things are setup in the various source modules. Built in web server allows control from OBS Studio. Lots more documentation available wiring instructions, protocol documents for hardware etc. but that would exceed file upload size. PM me if you are interested.
      And thanks to everyone on this forum that provided the many libraries and bits of software used to make this project work. I couldn't have done it without the many contributors to this forum. I did my best to give the appropriate credit in each module.
       
      GeorgeController.zip Operation Instructions.pdf

    • By mLipok
      In the past there was many questions about how to: "Automatic file upload using without user interaction"

      https://www.autoitscript.com/forum/topic/92907-ie-8-input-namenomfic-typefile-idnomfic/
      https://www.autoitscript.com/forum/topic/116899-cant-automate-input-typefile-tag-in-ie/?tab=comments#comment-815478
      https://www.autoitscript.com/forum/topic/14883-input-typefile/
      https://www.autoitscript.com/forum/topic/188708-how-to-set-the-value-of-an-input-typefile-element/
      https://www.autoitscript.com/forum/topic/91513-how-can-i-auto-set-file-path-for-input-file-in-ie/
      https://www.autoitscript.com/forum/topic/116899-cant-automate-input-typefile-tag-in-ie/
      https://www.autoitscript.com/forum/topic/169190-how-to-script-file-upload-button/
      https://www.autoitscript.com/forum/topic/145327-how-to-deal-with-ie-window-for-upload-a-fileinput-typefile/
      https://www.autoitscript.com/forum/topic/140482-internet-explorer-input-file-problem/
       
      I found solution here: 
      https://stackoverflow.com/questions/33253517/upload-a-file-via-input-input-in-html-form-with-vba
      and:
      https://www.motobit.com/tips/detpg_uploadvbsie/
      And I translate this code to AutoIt3 code:
      ; Upload file using http protocol And multipart/form-data ; v1.01 ; 2001 Antonin Foller, PSTRUH Software Global $oErrorHandler = ObjEvent("AutoIt.Error", _ErrFunc) do_vbsUpload() Func do_vbsUpload() #cs ; We need at least two arguments (File & URL) ConsoleWrite('- ' & @ScriptLineNumber & @CRLF) If $CmdLine[0] < 2 Then InfoEcho() ConsoleWrite('- ' & @ScriptLineNumber & @CRLF) ; Are some required objects missing? If StringInStr(CheckRequirements(), "Error") > 0 Then InfoEcho() ConsoleWrite('- ' & @ScriptLineNumber & @CRLF) Local $s_FileName, $s_DestURL, $s_FieldName $s_FieldName = "FileField" ; Default field name For $i_argCounter = 1 To $CmdLine[0] ConsoleWrite('+ '& $i_argCounter& ' >> ' & $CmdLine[$i_argCounter] & @CRLF) Select Case $i_argCounter = 1 ;~ $s_FileName = $CmdLine[$i_argCounter] $s_FileName = @ScriptFullPath Case $i_argCounter = 2 $s_DestURL = $CmdLine[$i_argCounter] Case $i_argCounter = 3 $s_FieldName = $CmdLine[$i_argCounter] EndSelect Next UploadFile($s_DestURL, $s_FileName, $s_FieldName) #ce UploadFile('http://www.dobeash.com/test.html', @ScriptFullPath, 'fileExample') EndFunc ;==>do_vbsUpload ; ******************* upload - begin ; Upload file using input type=file Func UploadFile($s_DestURL, $s_FileName, $s_FieldName) ; Boundary of fields. ; Be sure this string is Not In the source file Const $Boundary = "---------------------------0123456789012" ; Get source file As a binary data. Local $d_FileContents = GetFile($s_FileName) ; Build multipart/form-data document Local $s_FormData = BuildFormData($d_FileContents, $Boundary, $s_FileName, $s_FieldName) ; Post the data To the destination URL IEPostBinaryRequest($s_DestURL, $s_FormData, $Boundary) EndFunc ;==>UploadFile ; Build multipart/form-data document with file contents And header info Func BuildFormData($d_FileContents, $Boundary, $s_FileName, $s_FieldName) Const $s_ContentType = "application/upload" ; The two parts around file contents In the multipart-form data. Local $s_Pre = "--" & $Boundary & @CRLF & mpFields($s_FieldName, $s_FileName, $s_ContentType) Local $s_Po = @CRLF & "--" & $Boundary & "--" & @CRLF ; Build form data using recordset binary field Const $i_adLongVarBinary = 205 Local $oRS = ObjCreate("ADODB.Recordset") ; https://docs.microsoft.com/en-us/sql/ado/reference/ado-api/append-method-ado?view=sql-server-ver15 $oRS.Fields.Append("b", $i_adLongVarBinary, StringLen($s_Pre) + BinaryLen($d_FileContents) + StringLen($s_Po)) $oRS.Open() $oRS.AddNew() ; Convert Pre string value To a binary data Local $i_LenData = StringLen($s_Pre) $oRS("b").AppendChunk(StringToMB($s_Pre) & StringToBinary(Chr(0))) $s_Pre = $oRS("b").GetChunk($i_LenData) $oRS("b") = "" ; Convert Po string value To a binary data $i_LenData = StringLen($s_Po) $oRS("b").AppendChunk(StringToMB($s_Po) & StringToBinary(Chr(0))) $s_Po = $oRS("b").GetChunk($i_LenData) $oRS("b") = "" ; Join Pre & $d_FileContents & Po binary data $oRS("b").AppendChunk($s_Pre) $oRS("b").AppendChunk($d_FileContents) $oRS("b").AppendChunk($s_Po) $oRS.Update() Local $s_FormData = $oRS("b") $oRS.Close() Return $s_FormData EndFunc ;==>BuildFormData ; sends multipart/form-data To the URL using IE Func IEPostBinaryRequest($s_URL, $s_FormData, $Boundary) ; Create InternetExplorer Local $oIE = ObjCreate("InternetExplorer.Application") ; You can uncoment Next line To see form results $oIE.Visible = True ; Send the form data To $s_URL As POST multipart/form-data request $oIE.Navigate($s_URL, '', '', $s_FormData, _ "Content-Type: multipart/form-data; boundary=" & $Boundary & @CRLF) While $oIE.Busy Wait(1, "Upload To " & $s_URL) WEnd ; Get a result of the script which has received upload ;~ On Error Resume Next Local $s_IE_InnerHTML = $oIE.Document.body.innerHTML MsgBox(0, 'TEST #' & @CRLF & @ScriptLineNumber, $s_IE_InnerHTML) $oIE.Quit() Return $s_IE_InnerHTML EndFunc ;==>IEPostBinaryRequest ; Infrormations In form field header. Func mpFields($s_FieldName, $s_FileName, $s_ContentType) Local $s_MPTemplate = _ ; template For multipart header 'Content-Disposition: form-data; name="{field}";' & _ 'FileName="{file}"' & @CRLF & _ 'Content-Type: {ct}' & @CRLF & @CRLF & _ '' Local $s_Out $s_Out = StringReplace($s_MPTemplate, "{field}", $s_FieldName) $s_Out = StringReplace($s_Out, "{file}", $s_FileName) $s_Out = StringReplace($s_Out, "{ct}", $s_ContentType) Return $s_Out EndFunc ;==>mpFields Func Wait($i_Seconds, $s_Message) MsgBox(64, '', $s_Message, $i_Seconds) EndFunc ;==>Wait ; Returns file contents As a binary data Func GetFile($s_FileName) Local $oStream = ObjCreate("ADODB.Stream") $oStream.Type = 1 ; Binary $oStream.Open() $oStream.LoadFromFile($s_FileName) Local $d_GetFile = $oStream.Read() $oStream.Close() Return $d_GetFile EndFunc ;==>GetFile ; Converts OLE string To multibyte string Func StringToMB($S) Local $I, $B For $I = 1 To StringLen($S) $B &= StringToBinary(Asc(StringMid($S, $I, 1))) Next Return $B EndFunc ;==>StringToMB ; ******************* upload - end ; ******************* Support ; Basic script info Func InfoEcho() Local $sMsg = _ "Upload file using http And multipart/form-data" & @CRLF & _ "Copyright (C) 2001 Antonin Foller, PSTRUH Software" & @CRLF & _ "use" & @CRLF & _ "[cscript|wscript] fupload.vbs file $s_URL [fieldname]" & @CRLF & _ " file ... Local file To upload" & @CRLF & _ " $s_URL ... $s_URL which can accept uploaded data" & @CRLF & _ " fieldname ... Name of the source form field." & @CRLF & _ @CRLF & CheckRequirements() & @CRLF & _ "" ConsoleWrite('! ' & $sMsg & @CRLF) EndFunc ;==>InfoEcho ; Checks If all of required objects are installed Func CheckRequirements() Local $sMsg = _ "This script requires some objects installed To run properly." & @CRLF & _ CheckOneObject("ADODB.Recordset") & @CRLF & _ CheckOneObject("ADODB.Stream") & @CRLF & _ CheckOneObject("InternetExplorer.Application") & @CRLF & _ "" Return $sMsg ; $sMsgBox $sMsg EndFunc ;==>CheckRequirements ; Checks If the one object is installed. Func CheckOneObject($sClassName) Local $sMsg ObjCreate($sClassName) If @error = 0 Then $sMsg = "OK" Else $sMsg = "Error:" & @error EndIf Return $sClassName & " - " & $sMsg EndFunc ;==>CheckOneObject ; ******************* Support - end ; User's COM error function. Will be called if COM error occurs Func _ErrFunc(ByRef $oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc  
      But I miss something and the code not works as intendend.
      Please join and contribute, in solving this issue, as this will be handy for entire community.
      @mLipok
       
      btw.
      I think that this may be realated to ChrB() which I simply translate to StringToBinary()
      Especialy this :
      StringToBinary(Chr(0))) could be the main issue.
      But for now I'm tired and going to sleep.
      Hope maybe tomorrow somebody solve this issue.
       
    • By Colduction
      Hi again guys!, i had COVID-19 for twice and i couldn't check the forum since 3 or 4 months ago till now! i hope you will get better if you're fighting for beat COVID-19

      I have two question, first is about extracting all of the IP Address from an IP Ranges, for e.g: 192.168.1.1-192.255.255.255 (Start and End are variable and will be defined by the user) and for second one, i have a friend that he is Python programmer, he made a IP Parser that it can support large txt files (1TB) and it can parse all of them under 10min and it also supports low-end PCs that have 1 GB RAM!

      The list that his program parses are:
      #1765497 192.168.1.1 8082 #1765496 192.168.1.1 8084 #1965493 192.168.1.1 8089 #9565495 192.168.1.1 8086 #2565492 192.168.1.1 8081 and it converts very very fast to this:
      192.168.1.1:8082 192.168.1.1:8084 192.168.1.1:8089 192.168.1.1:8086 192.168.1.1:8081 I wonder how to do this via AutoIt, if you can help me in this way, i will be happy✌❤

      Thanks for your helps.

      FIRST_QUESTION_TEST.au3
    • By argumentum
      In the ZIP is the code and the compiled script.
      This is yet another ping the LAN utility.
      Is quite fast, as gathering the info. is forked.
      The Save Note, saves a note for the given MAC ( you may find it handy )
      The Save MACs, saves the listview to an INI file that can be later use for the WakeOnLAN
      Right click will bring a context menu to do stuff. DClick will refresh the Ping.
      That's it. Comes in handy to have in the USB toolbox  
    • By RestrictedUser
      Hello Guys and AutoIt Scriptwriters!🎉❤️
      I've created a script to notify to me if RDP main IP changed then send a message via Telegram bot to me
      But some of my RDP's Main IP are @IPAddress1 or @IPAddress3 or Public IP Address...
      I want to detect automatically the IP that windows client can run RDP to remotely control
      This image can help you that what i say, there are three RDP with specified IP, i want to run script in these RDP's then capture those IP's changes then notify me via Telegram bot

×
×
  • Create New...