Jump to content

VLC Mover -- moves VLC to different monitor when playing certain files

Recommended Posts

I made this application at the behest of another user because it sounded like a really cool idea.

I've been using it for a little over 7 months and I really like it.


After Compiling:

If you want to use it as a pass through you'll need to name the script Vlc.exe and the original vlc.exe to Vlc_Orig.exe.

On first run it will create a settings.ini with default settings and pop up the settings dialog

Running VLC.exe again only runs the script passes on the new commandline and exits the script

the previous script stays running...

Once you close the VLC window after a few seconds a pop up will appear F1- Help, F4 - settings, ESC - Quit without saving

WindowName=VLC media player
WindowTextFallback=VLC (Direct3D output)
CloseOnInactive=0 ;1 - Closes the vlc_orig.exe when the video ends
MaximizeOnActivate=0 ;1 - Maximizes window when video is detected
IgnoreFilesLessThanMB=0 ;0-1000x?? - Passthrough Ignores files less than this
ActiveWindowCoords=0 ;- moves window to this position on video stop 0 ignores or format 0,0,1000,1000 => x,y,w,h
InactiveWindowCoords=0 ;- moves window to this position on video stop 0 ignores or format 0,0,1000,1000 => x,y,w,h
ExecOnActive= ;execute this file when video is detected
ExecOnInactive= ;execute this file when when video stops
KeysOnActivate=f ;-keys to press when video is detected
KeysOnInactive= ;-keys to press when video stops
FileTypes=mp4,avi,mkv,wmv ;-Comma separated list of valid video files
WindowName=VLC media player ;
WindowText_Fallback=VLC (Direct3D output) ;if valid ext not found fallback to looking for windowname and this text


If you don't want to use it as a pass through you'll probably need to change it a bit to do what you want



#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

Global $gsINI_PATH = @AppDataDir & "\" & @ScriptName & "_PassThrough.ini" ;Needs to be in @AppDataDir to have write access
Global Const $gsINI_SEC = "Config"
If FileExists(@ScriptDir & "\" & @ScriptName & "_PassThrough.ini") Then
    $gsINI_PATH = @ScriptDir & "\" & @ScriptName & "_PassThrough.ini"
EndIf ;Override with ini file in script directory, probably not writeable though

Global Const $GUI_EVENT_CLOSE = -0x3

Global Const $giACTWAIT = 5 ;wait #seconds for window to become active

Global Enum $ge_bClose = 0, $ge_bMaximize, $ge_iMinSize, $ge_iKeyDelay, $ge_iKeyDnDelay, $ge_sExecute, _
        $ge_sActCoord, $ge_sInACoord, $ge_sActExec, $ge_sInAExec, $ge_sSendKeysAct, $ge_sSendKeysInA, _
        $ge_sFileTypes, $ge_sWndName, $ge_sWndFbTxt, $ge_LASTCFG

Global Const $gaIniKeys[$ge_LASTCFG] = ["CloseOnInactive", "MaximizeOnActivate", "IgnoreFilesLessThanMB", "KeyDelayMS", _
        "KeyDownDelayMS", "ExecName", "ActiveWindowCoords", "InactiveWindowCoords", "ExecOnActive", "ExecOnInactive", _
        "KeysOnActivate", "KeysOnInactive", "FileTypes", "WindowName", "WindowTextFallback"]

Global $g_aCfg[$ge_LASTCFG] ;Holds settings for the program

$g_aCfg[$ge_bClose] = (Cfg_Read($ge_bClose, 0) = 0 ? False : True)
$g_aCfg[$ge_bMaximize] = (Cfg_Read($ge_bMaximize, 0) = 0 ? False : True)

$g_aCfg[$ge_iMinSize] = Cfg_Read($ge_iMinSize, "0") ;Mb
$g_aCfg[$ge_iKeyDelay] = Cfg_Read($ge_iKeyDelay, 100)
$g_aCfg[$ge_iKeyDnDelay] = Cfg_Read($ge_iKeyDnDelay, 50)

$g_aCfg[$ge_sExecute] = Cfg_Read($ge_sExecute, StringTrimRight(@ScriptName, 4) & "_Orig.exe")

$g_aCfg[$ge_sActCoord] = Cfg_Read($ge_sActCoord, "0")
$g_aCfg[$ge_sInACoord] = Cfg_Read($ge_sInACoord, "0")

$g_aCfg[$ge_sSendKeysAct] = Cfg_Read($ge_sSendKeysAct, "f") ;(#Win)(+Shift)(arrow)(f)ull screen
$g_aCfg[$ge_sSendKeysInA] = Cfg_Read($ge_sSendKeysInA, "")

$g_aCfg[$ge_sActExec] = Cfg_Read($ge_sActExec, "")
$g_aCfg[$ge_sInAExec] = Cfg_Read($ge_sInAExec, "")

$g_aCfg[$ge_sFileTypes] = Cfg_Read($ge_sFileTypes, "mp4,avi,mkv,wmv") ;What files should be intercepted?
$g_aCfg[$ge_sWndName] = Cfg_Read($ge_sWndName, "VLC media player")
$g_aCfg[$ge_sWndFbTxt] = Cfg_Read($ge_sWndFbTxt, "VLC (Direct3D output)")

Global $gsMatchFileTypes = BuildFileTypes($g_aCfg[$ge_sFileTypes])
Global $gsMatchWnd = "[REGEXPTITLE:(?i)(" & $gsMatchFileTypes & ")(.*" & $g_aCfg[$ge_sWndName] & ")]"
Global $gsMatchWnd_Fb = "[REGEXPTITLE:(?i)(.*" & $g_aCfg[$ge_sWndName] & ")]" ;Fallback Matching
Global $gaWndPosAct = GetRectFromString($g_aCfg[$ge_sActCoord])
Global $gaWndPosInact = GetRectFromString($g_aCfg[$ge_sInACoord])

Global $gbActivated = False
Global $gPID = 0, $gsErr = "", $ghWndApp

Func _Create_Message($sMessage)
    Local $iMsg = WinAPI_RegisterWindowMessage($sMessage)
    If $iMsg = 0 Then $gsErr &= "IPC Message Creation Failure " & $sMessage & @CRLF
    Return $iMsg
EndFunc   ;==>_Create_Message

Func _Create_MessageHandler($iMsg, $sFunction)
    If $iMsg <> 0 Then
        Opt("GUIOnEventMode", 1)
        GUICreate(@ScriptName & "_IPC", 0, 0, 0, 0, 0, 0) ; create a top level window
        GUIRegisterMsg($iMsg, $sFunction)
EndFunc   ;==>_Create_MessageHandler

Func _Exit()
    ;sets hotkeys and saves settings
    HotKeySet("{F4}", Settings_GUI)
    HotKeySet("{F1}", _Help)
    HotKeySet("{ESC}", _Exit_Now)
    ToolTip("Pass Through F1 - Help, F4 - Settings, ESC - Quit without saving", 0, 0)
    ToolTip("", 0, 0)
EndFunc   ;==>_Exit

Func _Exit_Now()
EndFunc   ;==>_Exit_Now

Func _Help()
    MsgBox(0, "Pass Through", "Settings stored in:" & @CRLF & $gsINI_PATH & _
            @CRLF & @CRLF & _
            "Invoked: " & @ScriptDir & "\" & $g_aCfg[$ge_sExecute] & " " & $CmdLineRaw & _
            @CRLF & "FileTypes: " & $gsMatchFileTypes & @CRLF & _
            "Errors:" & $gsErr & @CRLF)
EndFunc   ;==>_Help

Func _IsCompiled() ;wakillon
    Return @Compiled
EndFunc   ;==>_IsCompiled

Func _Main()
    If Not FileExists($gsINI_PATH) Then ;FIRST RUN

    Opt("SendKeyDelay", $g_aCfg[$ge_iKeyDelay])
    Opt("SendKeyDownDelay", $g_aCfg[$ge_iKeyDnDelay])

    If _IsCompiled() Then
        Local $iActMsg = _Create_Message("@ScriptFullPath" & "_msg")
        _Create_MessageHandler($iActMsg, "Activated_Ext")


        $ghWndApp = WaitActive_Wnd($gaWndPosAct, $g_aCfg[$ge_sSendKeysAct])
    Until (WaitNotExists_Wnd($ghWndApp, $gaWndPosInact, $g_aCfg[$ge_sSendKeysInA]) Or $g_aCfg[$ge_bClose])

    If $g_aCfg[$ge_bClose] And WinExists($ghWndApp) Then WinClose($ghWndApp)
EndFunc   ;==>_Main

Func _Singleton_NOCHILD($sOccurrenceName, $iFlag = 0) ;Valik
    Local Const $ERROR_ALREADY_EXISTS = 183
    Local $aHandle = DllCall("kernel32.dll", "handle", "CreateMutexW", "struct*", 0, "bool", 1, "wstr", $sOccurrenceName)
    If @error Then Return SetError(@error, @extended, 0)
    Local $aLastError = DllCall("kernel32.dll", "dword", "GetLastError")
    If @error Then Return SetError(@error, @extended, 0)
    If $aLastError[0] = $ERROR_ALREADY_EXISTS Then
        If BitAND($iFlag, 1) Then
            DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $aHandle[0])
            If @error Then Return SetError(@error, @extended, 0)
            Return SetError($aLastError[0], $aLastError[0], 0)
            Exit -1
    Return $aHandle[0]
EndFunc   ;==>_Singleton_NOCHILD
Func Activated_Ext() ;($hWnd, $iMsg, $wParam, $lParam)
    ;Message Posted from other instances
    ;call this to notify of an active file
    $gbActivated = True
EndFunc   ;==>Activated_Ext

Func ArrayToStr($aArray)
    ;returns single dimension array as comma delimited string
    ;on error returns 0
    Local $sRet = ""
    Local $iCt = UBound($aArray) - 1
    If $iCt < 0 Then Return SetError(1, 0, 0)
    For $i = 0 To $iCt
        $sRet &= $aArray[$i] & ","
    $sRet = StringTrimRight($sRet, 1) ;Remove the trailing ','
    Return $sRet
EndFunc   ;==>ArrayToStr

Func BuildFileTypes($sTypes)
    ;Build a regex string of file extensions from a comma separated one
    ;matches partial filenames too
    ;"txt,exe,.com,.avi,test.mp3" => ".*\.txt,.*\.exe,.*\.com,.*\.avi,.*test\.mp3"
    ;('\' escapes the '.')
    Local $sTmp, $sRet = ""
    Local $aExt = StringRegExp($sTypes, "(\w+?\.\w+)|\w+", 3)
    For $i = 0 To UBound($aExt) - 1
        $sTmp = $aExt[$i]
        If StringInStr($sTmp, ".") = 0 Then $sTmp = "." & $sTmp
        $sRet &= ".*" & StringReplace($sTmp, ".", "\.") & "|"
    $sRet = StringTrimRight($sRet, 1) ;Remove the trailing '|'
    Return $sRet
EndFunc   ;==>BuildFileTypes

Func Cfg_Read($iSetting, $sDefault)
    Return IniRead($gsINI_PATH, $gsINI_SEC, $gaIniKeys[$iSetting], $sDefault)
EndFunc   ;==>Cfg_Read

Func Cfg_Write($iSetting, $sValue)
    If Not _IsCompiled() Then
        ConsoleWrite($gaIniKeys[$iSetting] & " = " & $sValue & @CRLF)
        IniWrite($gsINI_PATH, $gsINI_SEC, $gaIniKeys[$iSetting], $sValue)
EndFunc   ;==>Cfg_Write

Func Execute_App($sPath)
    If FileExists( $sPath) Then
        Run(Chr(34) & $sPath & Chr(34), "")

Func GetRectFromString($sCoords)
    ;takes rect passed in string 'x, y, w, h' converts to array
    ;Returns [x, y, w, h] if string is valid or 0 if invalid
    ;You should check if return is an array with IsArray()
    Return StringRegExp($sCoords, "(\d+)\D+(\d+)\D+(\d+)\D+(\d+)", 1)
EndFunc   ;==>GetRectFromString

Func RunPassThrough($iActMsg = 0)
    ;calls the original file passing through commandline arguments
    Local $sPath = @ScriptDir & "\" & $g_aCfg[$ge_sExecute]
    Local $sSwitches = $CmdLineRaw
    ;MsgBox(0, "Pass Through", $sPath & @CRLF & $sSwitches)

    $gPID = Run(Chr(34) & $sPath & Chr(34) & " " & $sSwitches, "") ; Run

    If $gPID Then RunSingleInstance($iActMsg)

    Sleep(1000) ;Wait a moment for the file to load
EndFunc   ;==>RunPassThrough

Func RunSingleInstance($iActMsg)
    Local Const $iSZMB = (1024 * 1024)
    Local Const $HWND_BROADCAST = 0xFFFF
    If _Singleton_NOCHILD(@ScriptName, 1) = 0 Then
        If $CmdLine[0] > 1 And FileExists($CmdLine[2]) Then
            If $g_aCfg[$ge_iMinSize] And FileGetSize($CmdLine[2]) < ($g_aCfg[$ge_iMinSize] * $iSZMB) Then
                ;;;If file is less than $g_aCfg[$ge_iMinSize] Megabytes treat it like an inactive file
            ElseIf $iActMsg <> 0 Then ; Update script by posting a message from this (new) instance
                If StringRegExp($CmdLine[2], $gsMatchFileTypes) Then
                    WinAPI_PostMessage($HWND_BROADCAST, $iActMsg, 0, 0)
        _Exit_Now() ;single instance of script ONLY
EndFunc   ;==>RunSingleInstance

Func Settings_GUI()
    Opt("GUIOnEventMode", 0)
    Local Const $GUI_ENABLE = 0x40
    Local Const $GUI_DISABLE = 0x80
    Local Const $GUI_CHECKED = 0x1
    Local Const $GUI_SHOW = 16
    Local $nMsg

    Local Enum $eS_KeySend = 0, $eS_Coords, $eS_SetWHelper, $eS_Exec, $eS_LAST
    Local $aCtlText[$eS_LAST] = ["Send Keys", "Coordinates (x, y, w, h)", "Set With Helper", "Execute"]
    Local $aActivCtls[$eS_LAST] ;Holds handles for the Active State Controls
    Local $aInactCtls[$eS_LAST] ;Holds handles for the Inactive State Controls

    Local $hForm1_1 = GUICreate("Pass Through Settings", 287, 245, 192, 124)

    GUICtrlCreateLabel($aCtlText[$eS_Exec], 8, 2, 74, 17)
    Local $hI_Exec = GUICtrlCreateInput($g_aCfg[$ge_sExecute], 100, 0, 180, 20)
    GUICtrlCreateLabel("Win Text FB", 8, 30, 74, 17)
    Local $hI_FbTxt = GUICtrlCreateInput($g_aCfg[$ge_sWndFbTxt], 100, 27, 180, 20)

    Local $hC_IClose = GUICtrlCreateCheckbox("Close on Inactive", 8, 50, 100, 17)
    GUICtrlSetState($hC_IClose, $g_aCfg[$ge_bClose] ? 1 : 4)
    GUICtrlCreateTab(8, 75, 275, 140)

    If GUICtrlCreateTabItem("Activated Settings") Then
        GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
        GUICtrlCreateLabel("File Extensions", 10, 103, 74, 17)
        Local $hI_FTyp = GUICtrlCreateInput($g_aCfg[$ge_sFileTypes], 128, 100, 150, 20)

        GUICtrlCreateLabel($aCtlText[$eS_KeySend], 10, 126, 55, 20)
        $aActivCtls[$eS_KeySend] = GUICtrlCreateInput($g_aCfg[$ge_sSendKeysAct], 128, 122, 150, 20)

        GUICtrlCreateLabel($aCtlText[$eS_Exec], 10, 148, 55, 20)
        $aActivCtls[$eS_Exec] = GUICtrlCreateInput($g_aCfg[$ge_sActExec], 128, 144, 150, 20)

        GUICtrlCreateLabel($aCtlText[$eS_Coords], 10, 169, 111, 20)
        $aActivCtls[$eS_SetWHelper] = GUICtrlCreateButton($aCtlText[$eS_SetWHelper], 128, 190, 150, 17)
        $aActivCtls[$eS_Coords] = GUICtrlCreateInput(ArrayToStr($gaWndPosAct), 128, 166, 150, 20)

        Local $hC_AMaxm = GUICtrlCreateCheckbox("Maximize", 10, 189, 89, 17)
        GUICtrlSetState($hC_AMaxm, $g_aCfg[$ge_bMaximize] ? 1 : 4)

    If GUICtrlCreateTabItem("Inactivated Settings") Then
        GUICtrlCreateLabel($aCtlText[$eS_KeySend], 10, 103, 55, 20)
        $aInactCtls[$eS_KeySend] = GUICtrlCreateInput($g_aCfg[$ge_sSendKeysInA], 128, 100, 150, 20)

        GUICtrlCreateLabel($aCtlText[$eS_Exec], 10, 126, 55, 20)
        $aInactCtls[$eS_Exec] = GUICtrlCreateInput($g_aCfg[$ge_sInAExec], 128, 122, 150, 20)

        GUICtrlCreateLabel($aCtlText[$eS_Coords], 10, 148, 111, 20)
        $aInactCtls[$eS_SetWHelper] = GUICtrlCreateButton($aCtlText[$eS_SetWHelper], 128, 169, 150, 17)
        $aInactCtls[$eS_Coords] = GUICtrlCreateInput(ArrayToStr($gaWndPosInact), 128, 145, 150, 20)
    GUICtrlCreateTabItem("") ; end tabitem definition

    Local $hB_Cancel = GUICtrlCreateButton("Cancel", 8, 215, 49, 17)
    Local $hB_Save = GUICtrlCreateButton("Save", 71, 215, 49, 17)
    GUISetState(@SW_SHOW, $hForm1_1)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $hB_Cancel
            Case $GUI_EVENT_CLOSE
            Case $aActivCtls[$eS_SetWHelper] ;Pops-up window to make setting coords easier
                GUICtrlSetState($aActivCtls[$eS_SetWHelper], $GUI_DISABLE)

                GUICtrlSetData($aActivCtls[$eS_Coords], Settings_PosHelper("Active Pos", _
                GUICtrlSetState($aActivCtls[$eS_SetWHelper], $GUI_ENABLE)

            Case $aInactCtls[$eS_SetWHelper] ;Pops-up window to make setting coords easier
                GUICtrlSetState($aInactCtls[$eS_SetWHelper], $GUI_DISABLE)

                GUICtrlSetData($aInactCtls[$eS_Coords], Settings_PosHelper("Inactive Pos", _
                GUICtrlSetState($aInactCtls[$eS_SetWHelper], $GUI_ENABLE)

            Case $hB_Save
                $g_aCfg[$ge_sExecute] = GUICtrlRead($hI_Exec)
                $g_aCfg[$ge_sWndFbTxt] = GUICtrlRead($hI_FbTxt)

                $g_aCfg[$ge_bClose] = (BitAND(GUICtrlRead($hC_IClose), $GUI_CHECKED) = $GUI_CHECKED) ? 1 : 0

                $g_aCfg[$ge_sFileTypes] = GUICtrlRead($hI_FTyp)
                $g_aCfg[$ge_sSendKeysAct] = GUICtrlRead($aActivCtls[$eS_KeySend])
                $g_aCfg[$ge_sActExec] = GUICtrlRead($aActivCtls[$eS_Exec])

                $g_aCfg[$ge_sActCoord] = GUICtrlRead($aActivCtls[$eS_Coords])
                $gaWndPosAct = GetRectFromString($g_aCfg[$ge_sActCoord])

                $g_aCfg[$ge_bMaximize] = (BitAND(GUICtrlRead($hC_AMaxm), $GUI_CHECKED) = $GUI_CHECKED) ? 1 : 0

                $g_aCfg[$ge_sSendKeysInA] = GUICtrlRead($aInactCtls[$eS_KeySend])
                $g_aCfg[$ge_sInAExec] = GUICtrlRead($aInactCtls[$eS_Exec])

                $g_aCfg[$ge_sInACoord] = GUICtrlRead($aInactCtls[$eS_Coords])
                $gaWndPosInact = GetRectFromString($g_aCfg[$ge_sInACoord])


    Return ;
EndFunc   ;==>Settings_GUI

Func Settings_PosHelper($sTitle, $sRect)
    ;Pops-up window to make setting coords easier
    ;sRect is a string format 'x, y, w, h' OR '0'
    ;Returns new sRect in same format
    Local Const $WS_OVERLAPPEDWINDOW = 0x00CF0000
    Local $nMsg
    Local $hForm1_2 = GUICreate($sTitle, 0, 0, -1, -1, $WS_OVERLAPPEDWINDOW)
    WndMoveArray($hForm1_2, GetRectFromString($sRect))

    Local $hB_Set = GUICtrlCreateButton("Set", 0, 0, 50, 17)
    GUISetState(@SW_SHOW, $hForm1_2)
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $hB_Set
                $sRect = ArrayToStr(WinGetPos($hForm1_2))
            Case $GUI_EVENT_CLOSE
    Return $sRect ;
EndFunc   ;==>Settings_PosHelper

Func Settings_Save()
    Local $vVal ;
    If Not _IsCompiled() Then ConsoleWrite("SETTINGS_SAVE:" & @CRLF)
    For $i = 0 To $ge_LASTCFG - 1
        $vVal = $g_aCfg[$i]
        If IsBool($vVal) Then
            Cfg_Write($i, $vVal ? 1 : 0)
        ElseIf IsArray($vVal) Then
            Cfg_Write($i, ArrayToStr($vVal))
            Cfg_Write($i, $vVal)
EndFunc   ;==>Settings_Save

Func WinAPI_PostMessage($hWnd, $iMsg, $wParam, $lParam)
    Local $aResult = DllCall("user32.dll", "bool", "PostMessage", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0]
EndFunc   ;==>WinAPI_PostMessage

Func WinAPI_RegisterWindowMessage($sMessage)
    Local $aResult = DllCall("user32.dll", "uint", "RegisterWindowMessageW", "wstr", $sMessage)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult[0]
EndFunc   ;==>WinAPI_RegisterWindowMessage

Func WaitActive_Wnd($aRect, $sKeys)
    ; Loops waiting for a trigger from vlc window either filename(s)
    ; in the title or window name and text
    ; if PID is defined and doesn't exist closes script
    ; Returns window handle
    Local $hWnd
        $hWnd = WndTryActivate($gsMatchWnd, "") ; Wait for active window

        If $hWnd = 0 Then ;Fallback
            $hWnd = WndTryActivate($gsMatchWnd_Fb, $g_aCfg[$ge_sWndFbTxt])
            If $hWnd <> 0 Then ExitLoop
            If $gPID And Not ProcessExists($gPID) And Not WinExists($gsMatchWnd) Then Exit
    Until ($hWnd <> 0)

    WndMoveArray($hWnd, $aRect)
    WndSendKeys($hWnd, $sKeys)

    If $g_aCfg[$ge_bMaximize] Then WinSetState($hWnd, "", @SW_MAXIMIZE)

    Return $hWnd
EndFunc   ;==>WaitActive_Wnd

Func WaitNotExists_Wnd($hWnd, $aRect, $sKeys)
    ;Returns False if Title Does Not exist but $hWnd DOES exist
    ;Returns True if $hWnd + $title DOES NOT exist
        $gbActivated = False
    Until (Not $gbActivated) ;can be overidden by message posted from another instance

    If WinExists($hWnd) Then
        WndSendKeys($hWnd, $sKeys)

        If $g_aCfg[$ge_bMaximize] Then WinSetState($hWnd, "", @SW_RESTORE)

        WndMoveArray($hWnd, $aRect)
        Return False
    Return True
EndFunc   ;==>WaitNotExists_Wnd

Func WndMoveArray($hWnd, $aC)
    ;Moves $hWnd to coords specified by array
    If UBound($aC) >= 4 Then
        WinMove($hWnd, "", $aC[0], $aC[1], $aC[2], $aC[3])
EndFunc   ;==>WndMoveArray

Func WndSendKeys($hWnd, $sKeys)
    If $sKeys <> "" Then
        ControlSend($hWnd, "", 0, $sKeys)
EndFunc   ;==>WndSendKeys

Func WndTryActivate($Title, $Text = "")
    ;attemps to activate a window / waits $giACTWAIT seconds for window to become active
    WinActivate($Title, $Text)
    Local $hWnd = WinWaitActive($Title, $Text, $giACTWAIT) ; Wait for active window for number of seconds
    Return $hWnd
EndFunc   ;==>WndTryActivate



Edited by Bilgus
Posted an older version of the script
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Seminko
      all I want to do is control VLC player without it being the active window.
      I tried this, but that only works if VLC is the active window:
      $VLC = WinGetHandle("[CLASS:QWidget]") ControlSend("","",$VLC,"{SPACE}") Strange thing is I tried similar thing with AutoHotkey and it works like a charm so there has to be a way.
      (I checked the VLC UDF but as far as I see it does not interacts with VLC itself, rather it opens "a new VLC" using InternetExplorer. This is not what I want to do.)
      EDIT: for some reason this works. Can someone explain why?
      HotKeySet("{F5}", "Pause") $VLC = WinGetHandle("[CLASS:QWidget]") While 1 Sleep(100) WEnd Func Pause() ControlSend("","",$VLC,"{SPACE}") EndFunc EDIT2: huh, did some testing and if I run the script and use F5 without VLC not being active first, it will not work even when I make VLC active. However, when I run the script make VLC active, press F5 then i works like it should, VLC can be minimized, made not active. Why?
      EDIT3: when using Ctrl+V it only works when the window is active, despite what I wrote in EDIT2. This is mingboggling
      Func Pause() ControlSend("","",$VLC,"^v") EndFunc  
    • By marcoauto
      I Have a GUI with 2 VLC instance inside. I use VLC.au3 for receive the rtp streams
      I can watch the videos and listen the audio streams.
      Is there a way to read each stream audio volume value? I would like to show near the video stream the audiometers
      I saw some scripts to show audio meters, but only with mp3 or wav files
      This is my script:
      #include <GDIPlus.au3> #include "VLC.au3" Global $vlc128, $vlc129 Global $video_path128 = "128.m3u8" Global $video_path129 = "129.m3u8" _VLCErrorHandlerRegister() $g_hGUI = GUICreate("VLC", 200, 298, 192, 124) GUISetState() Global $Graphic = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) $vlc128 = _GUICtrlVLC_Create(10,10,180,144) $vlc129 = _GUICtrlVLC_Create(10,154,180,144) _GUICtrlVLC_Clear($vlc128) _GUICtrlVLC_Play($vlc128, _GUICtrlVLC_Add($vlc128, $video_path128)) _GUICtrlVLC_SetVolume($vlc128,50) ;set the vlc volume to zero _GUICtrlVLC_Clear($vlc129) _GUICtrlVLC_Play($vlc129, _GUICtrlVLC_Add($vlc129, $video_path129)) _GUICtrlVLC_SetVolume($vlc129,100) ;set the vlc volume to max Do Until False * Not Sleep(100000) ;do nothing, just sleep 128.m3u8 file:
      #EXTINF:321,Example Artist - Example title
      and 129.m3u8 file:
      #EXTINF:321,Example Artist - Example title
    • By vvb
      Hi All,

      I am trying to automate the installation and configuration of the latest version of VLC, V2.0.2.

      The automation of the GUI installation has no issues. However, when the script starts VLC for the first time, it gets presented a Privacy and Network Access Policy QWidget which has two QCheckBox and a non-standard button. I want to uncheck the QCheckBoxes and then click on the non-standard button but non of the standard commands work. In fact, the AutoIt Window Info is only able to pick up the widget title and nothing else.

      I can only get around it by sending: tab + space + tab + space + tab + space to perform the unchecking and clicking.

      Anyone know another way of doing this?


      Edit: Admins can delete this. Googling autoit+qcheckbox returned no results but autoit+qwidget did.

      Edit: Solved by exporting an existing config file and then after installation, copied the pre-canned config file over
  • Create New...