Sign in to follow this  
Followers 0
E1M1

Is there better way to sync 2 exes?

4 posts in this topic

Hello, I would like to know if there's better to synchronize these 2 exes? I want to synchronize film.exe and film2.exe at the moment I use following method: I run both exe(s), and these exe files are waiting until window titled "start" pops up and then they start playing video. Problem is thet this method is too slow, I need some other method to sync these 2 windows and I need to decrease time diference between these 2 movies, with current method time diference is about 200 - 300 ms but I need to geth that time diference between these 2 films less than 50 ms but better if time diference between 2 films is near to zero.

film.exe

#include-once

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

#Region Test
;~ Opt('MustDeclareVars', 0); no required
Dim $myIE_Obj
_IEErrorHandlerRegister (); optional error handler
Global $movie = "p.avi"
;~ Global $MyGUI = GUICreate("none", @DesktopWidth, @DesktopHeight,0,0,$WS_POPUP)
Global $MyGUI = GUICreate("trans", @DesktopWidth, @DesktopHeight,0,0,$WS_POPUP)
GUISetBkColor(0x000000)
Global $oIE = _GUICtrl_CreateWMPlayer($movie, 0, 0, @DesktopWidth, @DesktopHeight)
GUISetState (@SW_SHOW, $MyGUI)
WinSetTrans($MyGUI,"",128)
;~ WinSetState("none","",@SW_MINIMIZE)
WinSetState("trans","",@SW_MINIMIZE)
While 1
    If WinExists("start") Then
        _IEAction ($myIE_Obj, "refresh")
        ExitLoop
    EndIf
WEnd
Global $playerOBJ = _IEGetObjById($oIE, "objWMPlayer")
    While 1
Sleep(40)
If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
Wend
$oIE = ""
#EndRegion Test

;===================================================================================================
; Function: _GUICtrl_CreateWMPlayer
; Purpose: Embed Windows Media Player and play one file or one playlist only.
; Notes: PARAM NAME="url" is ReadOnly
; Authors: squirrely1
; borderless IE embed example: GaryFrost
; Kudos - Kåre Johansson, CFire
; References:
; http://msdn2.microsoft.com/en-us/library/ms930698.aspx
; media/media_playerref.asp' class='bbc_url' title='External link' rel='external'>http://www.w3schools.com/media/media_playerref.asp
; clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6 - wmplayer latest installed version
; clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95 - wmp 6.4
;===================================================================================================





Func _GUICtrl_CreateWMPlayer($movieURL, $playerLeft, $playerTop, $playerWidth, $playerHeight, _
$insetBorders = 0, $fullscreenMode = False, $showControls = true, $enableContextMenu = True, _
$LoopMode = True, $playCount = 1, $playVolume = 100, $playBalance = 0, $enableFullScreenControls = True)

If $fullscreenMode Then
$fullscreenMode = "true"
Else
$fullscreenMode = "false"
EndIf
If $showControls Then
$showControls = "true"
Else
$showControls = "false"
EndIf
If $enableContextMenu Then
$enableContextMenu = "true"
Else
$enableContextMenu = "false"
EndIf
If $LoopMode Then
$playCount = 999
EndIf
If $enableFullScreenControls Then
$enableFullScreenControls = "true"
Else
$enableFullScreenControls = "false"
EndIf

Global $myIE_Obj = _IECreateEmbedded ()
Global $GUIActiveX = GUICtrlCreateObj($myIE_Obj, $playerLeft, $playerTop, $playerWidth, $playerHeight)
_IENavigate($myIE_Obj, "about:blank")
Global $htmlWMP
$htmlWMP = '' _
& @CR & '<body style="margin:0;padding:0">' _
& @CR & '<OBJECT' _
& @CR & 'ID="objWMPlayer"' _
& @CR & 'STYLE="margin:0;padding:0"' _
& @CR & 'HSPACE="0"' _
& @CR & 'VSPACE="0"' _
& @CR & 'BORDER="0"' _
& @CR & 'WIDTH="' & $playerWidth & '"' _
& @CR & 'HEIGHT="' & $playerHeight & '"' _
& @CR & 'CLASSID="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6"' _
& @CR & 'STANDBY="Loading Windows Media Player components..."' _
& @CR & 'TYPE="application/x-oleobject">' _
& @CR & '<PARAM NAME="allowHideControls" VALUE="true">' _
& @CR & '<PARAM NAME="autoStart" VALUE="true">' _
& @CR & '<PARAM NAME="audioStream" VALUE="false">' _
& @CR & '<PARAM NAME="autoSize" VALUE="true">' _
& @CR & '<PARAM NAME="balance" VALUE="' & $playBalance & '"><!-- -100 to 100 -->' _
& @CR & '<!-- <PARAM NAME="bufferingTime" VALUE="5"><!-- seconds -->' _
& @CR & '<PARAM NAME="clickToPlay" VALUE="false"><!-- has no effect -->' _
& @CR & '<PARAM NAME="currentPosition" VALUE="0"><!-- start position within video, in seconds -->' _
& @CR & '<PARAM NAME="enableContextMenu" VALUE="' & $enableContextMenu & '">' _
& @CR & '<PARAM NAME="enableFullScreenControls" VALUE="' & $enableFullScreenControls & '">' _
& @CR & '<PARAM NAME="enabled" VALUE="true"><!-- whether controls are enabled -->' _
& @CR & '<PARAM NAME="fullScreen" VALUE="' & $fullscreenMode & '">' _
& @CR & '<PARAM NAME="mute" VALUE="false">' _
& @CR & '<PARAM NAME="playCount" VALUE="' & $playCount & '">' _
& @CR & '<!-- <PARAM NAME="previewMode" VALUE="true"> -->' _
& @CR & '<PARAM NAME="rate" VALUE="1"><!-- play speed of -.5 to 2 increments of .1 -->' _
& @CR & '<PARAM NAME="sendPlayStateChangeEvents" VALUE="false">' _
& @CR & '<PARAM NAME="showCaptioning" VALUE="false">' _
& @CR & '<PARAM NAME="showControls" VALUE="' & $showControls & '">' _
& @CR & '<PARAM NAME="showGotoBar" VALUE="false">' _
& @CR & '<PARAM NAME="showPositionControls" VALUE="true"><!-- uiMode must = "full" -->' _
& @CR & '<PARAM NAME="showStatusBar" VALUE="false"><!-- has no effect -->' _
& @CR & '<PARAM NAME="showDisplay" VALUE="true"><!-- has no effect - reportedly shows filename -->' _
& @CR & '<PARAM NAME="stretchToFit" VALUE="true">' _
& @CR & '<PARAM NAME="uiMode" VALUE="none"><!-- invisible, none, mini, full -->' _
& @CR & '<PARAM NAME="url" VALUE="' & $movieURL & '">' _
& @CR & '<!-- <PARAM NAME="videoBorderWidth" VALUE="0"> -->' _
& @CR & '<PARAM NAME="volume" VALUE="' & $playVolume & '"><!-- volume percent setting of wmplayer.exe -->' _
& @CR & '<PARAM NAME="windowlessVideo" VALUE="false"><!-- must be the default (false) for function to work in wmp 9.0, otherwise might renders video directly in the client area -->' _
& @CR & '</OBJECT>' _
& @CR & '</body>'
_IEDocWriteHTML ($myIE_Obj, $htmlWMP)
_IEAction ($myIE_Obj, "refresh")
$myIE_Obj.document.body.scroll = "no"
$myIE_Obj.document.body.style.border = $insetBorders
Return $myIE_Obj
EndFunc ;==>_GUICtrl_CreateWMPlayer

film2.exe

#include-once

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

#Region Test
;~ Opt('MustDeclareVars', 0); no required
Dim $myIE_Obj
_IEErrorHandlerRegister (); optional error handler
Global $movie = "p.avi"
Global $MyGUI = GUICreate("none", @DesktopWidth, @DesktopHeight,0,0,$WS_POPUP)
;~ Global $MyGUI = GUICreate("trans", @DesktopWidth, @DesktopHeight,0,0,$WS_POPUP)
GUISetBkColor(0x000000)
Global $oIE = _GUICtrl_CreateWMPlayer($movie, 0, 0, @DesktopWidth, @DesktopHeight)
GUISetState (@SW_SHOW, $MyGUI)
;~ WinSetTrans($MyGUI,"",128)
WinSetState("none","",@SW_MINIMIZE)
;~ WinSetState("trans","",@SW_MINIMIZE)
While 1
    If WinExists("start") Then
        _IEAction ($myIE_Obj, "refresh")
        ExitLoop
    EndIf
WEnd
Global $playerOBJ = _IEGetObjById($oIE, "objWMPlayer")
    While 1
Sleep(40)
If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
Wend
$oIE = ""
#EndRegion Test

;===================================================================================================
; Function: _GUICtrl_CreateWMPlayer
; Purpose: Embed Windows Media Player and play one file or one playlist only.
; Notes: PARAM NAME="url" is ReadOnly
; Authors: squirrely1
; borderless IE embed example: GaryFrost
; Kudos - Kåre Johansson, CFire
; References:
; http://msdn2.microsoft.com/en-us/library/ms930698.aspx
; media/media_playerref.asp' class='bbc_url' title='External link' rel='external'>http://www.w3schools.com/media/media_playerref.asp
; clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6 - wmplayer latest installed version
; clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95 - wmp 6.4
;===================================================================================================





Func _GUICtrl_CreateWMPlayer($movieURL, $playerLeft, $playerTop, $playerWidth, $playerHeight, _
$insetBorders = 0, $fullscreenMode = False, $showControls = true, $enableContextMenu = True, _
$LoopMode = True, $playCount = 1, $playVolume = 100, $playBalance = 0, $enableFullScreenControls = True)

If $fullscreenMode Then
$fullscreenMode = "true"
Else
$fullscreenMode = "false"
EndIf
If $showControls Then
$showControls = "true"
Else
$showControls = "false"
EndIf
If $enableContextMenu Then
$enableContextMenu = "true"
Else
$enableContextMenu = "false"
EndIf
If $LoopMode Then
$playCount = 999
EndIf
If $enableFullScreenControls Then
$enableFullScreenControls = "true"
Else
$enableFullScreenControls = "false"
EndIf

Global $myIE_Obj = _IECreateEmbedded ()
Global $GUIActiveX = GUICtrlCreateObj($myIE_Obj, $playerLeft, $playerTop, $playerWidth, $playerHeight)
_IENavigate($myIE_Obj, "about:blank")
Global $htmlWMP
$htmlWMP = '' _
& @CR & '<body style="margin:0;padding:0">' _
& @CR & '<OBJECT' _
& @CR & 'ID="objWMPlayer"' _
& @CR & 'STYLE="margin:0;padding:0"' _
& @CR & 'HSPACE="0"' _
& @CR & 'VSPACE="0"' _
& @CR & 'BORDER="0"' _
& @CR & 'WIDTH="' & $playerWidth & '"' _
& @CR & 'HEIGHT="' & $playerHeight & '"' _
& @CR & 'CLASSID="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6"' _
& @CR & 'STANDBY="Loading Windows Media Player components..."' _
& @CR & 'TYPE="application/x-oleobject">' _
& @CR & '<PARAM NAME="allowHideControls" VALUE="true">' _
& @CR & '<PARAM NAME="autoStart" VALUE="true">' _
& @CR & '<PARAM NAME="audioStream" VALUE="false">' _
& @CR & '<PARAM NAME="autoSize" VALUE="true">' _
& @CR & '<PARAM NAME="balance" VALUE="' & $playBalance & '"><!-- -100 to 100 -->' _
& @CR & '<!-- <PARAM NAME="bufferingTime" VALUE="5"><!-- seconds -->' _
& @CR & '<PARAM NAME="clickToPlay" VALUE="false"><!-- has no effect -->' _
& @CR & '<PARAM NAME="currentPosition" VALUE="0"><!-- start position within video, in seconds -->' _
& @CR & '<PARAM NAME="enableContextMenu" VALUE="' & $enableContextMenu & '">' _
& @CR & '<PARAM NAME="enableFullScreenControls" VALUE="' & $enableFullScreenControls & '">' _
& @CR & '<PARAM NAME="enabled" VALUE="true"><!-- whether controls are enabled -->' _
& @CR & '<PARAM NAME="fullScreen" VALUE="' & $fullscreenMode & '">' _
& @CR & '<PARAM NAME="mute" VALUE="false">' _
& @CR & '<PARAM NAME="playCount" VALUE="' & $playCount & '">' _
& @CR & '<!-- <PARAM NAME="previewMode" VALUE="true"> -->' _
& @CR & '<PARAM NAME="rate" VALUE="1"><!-- play speed of -.5 to 2 increments of .1 -->' _
& @CR & '<PARAM NAME="sendPlayStateChangeEvents" VALUE="false">' _
& @CR & '<PARAM NAME="showCaptioning" VALUE="false">' _
& @CR & '<PARAM NAME="showControls" VALUE="' & $showControls & '">' _
& @CR & '<PARAM NAME="showGotoBar" VALUE="false">' _
& @CR & '<PARAM NAME="showPositionControls" VALUE="true"><!-- uiMode must = "full" -->' _
& @CR & '<PARAM NAME="showStatusBar" VALUE="false"><!-- has no effect -->' _
& @CR & '<PARAM NAME="showDisplay" VALUE="true"><!-- has no effect - reportedly shows filename -->' _
& @CR & '<PARAM NAME="stretchToFit" VALUE="true">' _
& @CR & '<PARAM NAME="uiMode" VALUE="none"><!-- invisible, none, mini, full -->' _
& @CR & '<PARAM NAME="url" VALUE="' & $movieURL & '">' _
& @CR & '<!-- <PARAM NAME="videoBorderWidth" VALUE="0"> -->' _
& @CR & '<PARAM NAME="volume" VALUE="' & $playVolume & '"><!-- volume percent setting of wmplayer.exe -->' _
& @CR & '<PARAM NAME="windowlessVideo" VALUE="false"><!-- must be the default (false) for function to work in wmp 9.0, otherwise might renders video directly in the client area -->' _
& @CR & '</OBJECT>' _
& @CR & '</body>'
_IEDocWriteHTML ($myIE_Obj, $htmlWMP)
_IEAction ($myIE_Obj, "refresh")
$myIE_Obj.document.body.scroll = "no"
$myIE_Obj.document.body.style.border = $insetBorders
Return $myIE_Obj
EndFunc ;==>_GUICtrl_CreateWMPlayer

start.exe

WinMove("trans","",3,0)
$form1 = GUICreate("start",0,0,0,0)
GUISetState(@SW_SHOW)
sleep(1000)
Exit

edited

Share this post


Link to post
Share on other sites



I may be missing something obvious but I don't believe that you can control precisely how the OS will multitask two programs (eventually identical and accessing the same file). I mean that even if your two programs are given a common start semaphore, they certainly can't start exactly at the same time, except possibly if they are launched on distinct cores (but you don't control that, do you?). Then the fact that film players need to buffer data somehow implies that in practice one will start buffering before the other, but after that the second one will read the film (very same) data from OS disk cache (most likely). There are also certainly race conditions for display, sound output, etc.

In short I don't believe you can control that much system-level details that precisely from AutoIt without a lot of low-level understanding and interaction with system or driver-level monitoring and such things that AutoIt isn't really tailored for doing.

Others may have better ideas.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

But can I make that script read film from stream? and then what software I could use to stream that video, I mean If it works like network radio but with video then it might help, I could somehow prodcast black video and so that these exe files can start showing film and then I can make video streaming software stearm film, sh it would be like 1 file that way these exe files don't have to buffer again when new file gets streamed.

In other words I could play video from http://localhost:8080/video.avi. but howdo I organize that trick?


edited

Share this post


Link to post
Share on other sites

But can I make that script read film from stream? and then what software I could use to stream that video, I mean If it works like network radio but with video then it might help, I could somehow prodcast black video and so that these exe files can start showing film and then I can make video streaming software stearm film, sh it would be like 1 file that way these exe files don't have to buffer again when new file gets streamed.

In other words I could play video from http://localhost:8080/video.avi. but howdo I organize that trick?

Maybe VCL is worth investigating since it has a netsync option from synchronising from one stream, though that's the extent of my knowledge.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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  
Followers 0