Sign in to follow this  
Followers 0
Garry

ControlClick with controls that change ID

3 posts in this topic

I am trying to automate the encoding of a video. I am trying to use ControlClick using the ID number. I am finding that ID number for controls in Premiere change frequently. So I modified my script to use MouseClick instead. This seems to work okay but I have one issue remaining. I want to compute the time it takes to perform the encoding for a benchmarking project. There is a control that changes from a "progress" one to a "complete" one when the encoding is finished. I tried using the controls CLASS since the title never changes in the WinWaitActive function. This method does not seem to work.

Are there any suggestions?

Thanks

CODE
ShellExecute("C:\Documents and Settings\gweil\My Documents\Adobe\Premiere Elements\4.0\ConvertVideo.prel")

WinWaitActive("Adobe Premiere Elements - C:\Documents and Settings\gweil\My Documents\Adobe\Premiere Elements\4.0\ConvertVideo.prel")

Sleep(100)

MouseClick("left", 1298, 71)

Sleep(1000)

MouseClick("left", 1351, 256)

Sleep(1000)

MouseClick("left", 1058, 186)

Send("{END}")

Send("+{HOME}")

Send("{DEL}")

Sleep(1000)

Send("ConvertedVideo.mpg")

$timeBegin = TimerInit ()

MouseClick("left", 1348, 707)

Sleep(1000)

WinWaitActive("Adobe Premiere Elements - C:\Documents and Settings\gweil\My Documents\Adobe\Premiere Elements\4.0\ConvertVideo.prel", "[class SC::Common::ConfirmationView]", "")

$dif = TimerDiff($timeBegin)

MsgBox(0,"Time to Encode",$dif)

WinClose("Adobe Premiere Elements - C:\Documents and Settings\gweil\My Documents\Adobe\Premiere Elements\4.0\ConvertVideo.prel", "")

Exit

Share this post


Link to post
Share on other sites



Look at using ControlCommand() to get the control state. Use the text of the control as the ControlID parameter as you know it does not change.

Here is a basic example of how you may try to do it. It is not tested as I do not have the program but it is the direction that I would attempt. ControlCommand() may even need to use the "IsEnabled" parameter instead depending on the programs presentation.

ShellExecute('"' & @MyDocumentsDir & '\Adobe\Premiere Elements\4.0\ConvertVideo.prel"')
_WinWaitActive('Adobe Premiere Elements -')
Sleep(100)
MouseClick('left', 1298, 71)
Sleep(1000)
MouseClick('left', 1351, 256)
Sleep(1000)
MouseClick('left', 1058, 186)
Send('{END}+{HOME}{DEL}')
Sleep(1000)
Send('ConvertedVideo.mpg')
$timeBegin = TimerInit()
MouseClick('left', 1348, 707)
Sleep(1000)
; wait for the button with the text of "complete" to become visible
While Not ControlCommand('Adobe Premiere Elements -', '', 'complete', 'IsVisible')
    Sleep(1000)
WEnd
$dif = TimerDiff($timeBegin)
MsgBox(0, 'Time to Encode', $dif)
WinClose('Adobe Premiere Elements -')

Exit

Func _WinWaitActve($title, $text = '')
    ; wait for the window
    WinWait($title, $text)
    ; activate the window
    WinActivate($title, $text)
    ; wait until the window is active
    WinWaitActive($title, $text)
EndFunc

:)

Share this post


Link to post
Share on other sites

Look at using ControlCommand() to get the control state. Use the text of the control as the ControlID parameter as you know it does not change.

Here is a basic example of how you may try to do it. It is not tested as I do not have the program but it is the direction that I would attempt. ControlCommand() may even need to use the "IsEnabled" parameter instead depending on the programs presentation.

ShellExecute('"' & @MyDocumentsDir & '\Adobe\Premiere Elements\4.0\ConvertVideo.prel"')
_WinWaitActive('Adobe Premiere Elements -')
Sleep(100)
MouseClick('left', 1298, 71)
Sleep(1000)
MouseClick('left', 1351, 256)
Sleep(1000)
MouseClick('left', 1058, 186)
Send('{END}+{HOME}{DEL}')
Sleep(1000)
Send('ConvertedVideo.mpg')
$timeBegin = TimerInit()
MouseClick('left', 1348, 707)
Sleep(1000)
; wait for the button with the text of "complete" to become visible
While Not ControlCommand('Adobe Premiere Elements -', '', 'complete', 'IsVisible')
    Sleep(1000)
WEnd
$dif = TimerDiff($timeBegin)
MsgBox(0, 'Time to Encode', $dif)
WinClose('Adobe Premiere Elements -')

Exit

Func _WinWaitActve($title, $text = '')
    ; wait for the window
    WinWait($title, $text)
    ; activate the window
    WinActivate($title, $text)
    ; wait until the window is active
    WinWaitActive($title, $text)
EndFunc

:)

I got it finally with your suggestion to use ControlCommand. Here is the final script:

CODE
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Install a custom error handler

If FileExists("C:\Documents and Settings\gweil\My Documents\ConvertedVideo.mpg") Then

FileDelete("C:\Documents and Settings\gweil\My Documents\ConvertedVideo.mpg")

EndIf

ShellExecute("C:\Documents and Settings\gweil\My Documents\Adobe\Premiere Elements\4.0\ConvertVideo.prel")

;Select Share Workspace

WinWaitActive("Adobe Premiere Elements - C:\Documents and Settings\gweil\My Documents\Adobe\Premiere Elements\4.0\ConvertVideo.prel")

Sleep(700)

MouseClick("left", 1298, 71)

Sleep(2000)

;Select MPEG custom preset output

MouseClick("left", 1351, 256)

Sleep(1000)

MouseClick("left", 1058, 186)

Send("{END}")

Send("+{HOME}")

Send("{DEL}")

Sleep(1000)

Send("ConvertedVideo.mpg")

$timeBegin = TimerInit ()

MouseClick("left", 1348, 707)

Sleep(1000)

$done = 0

Do

ControlCommand("Adobe Premiere Elements - C:\Documents and Settings\gweil\My Documents\Adobe\Premiere Elements\4.0\ConvertVideo.prel", "", 15000, "IsVisible", "")

If Not @error Then

Sleep(500)

$doneOrCancel = ControlGetText("Adobe Premiere Elements - C:\Documents and Settings\gweil\My Documents\Adobe\Premiere Elements\4.0\ConvertVideo.prel", "", 15000)

If StringInStr($doneOrCancel, "Done") == 0 Then

$done = 0

Else

$done = 1

EndIf

EndIf

Until $done

$milidif = TimerDiff($timeBegin)

$dif = $milidif / 1000

ControlClick("Adobe Premiere Elements - C:\Documents and Settings\gweil\My Documents\Adobe\Premiere Elements\4.0\ConvertVideo.prel", "", 15000)

WinClose("Adobe Premiere Elements - C:\Documents and Settings\gweil\My Documents\Adobe\Premiere Elements\4.0\ConvertVideo.prel", "")

MsgBox(0,"Time to Encode",$dif & " seconds")

Exit

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