"ToggleFullScreenMode" - not executed in a timely manner

Problem:
Run Time Command “ToggleFullScreenMode” must be executed at the beginning of the script.
But, in fact, this command is always executed most recently.
Various tricks with “eval” and “time.sleep” do not help to solve the problem …
At the same time, the “refresh” and “viewFit” commands are executed correctly and in a timely manner.
Any ideas?

MEL:

...

if (!`optionVar -q "workspacesInFullScreenUIMode"`)
    {
    showWindow MayaWindow ;
    setFocus "MayaWindow" ;
    setFocus "modelPanel4" ;
    evalDeferred -en "ToggleFullScreenMode" ;
    viewFit -all -an 1  -p "modelPanel4" ;
    refresh -cv -f ;
    }
...

OR

Python:

import maya.cmds as cmds
...

if cmds.optionVar(q = "workspacesInFullScreenUIMode") == 0:
    cmds.showWindow('MayaWindow') 
    cmds.setFocus('MayaWindow')
    cmds.setFocus('modelPanel4')    
    cmds.evalDeferred('mel.eval(\'ToggleFullScreenMode\')', en = True)
    cmds.viewFit(all = True, an = 1, p = "modelPanel4")
    cmds.refresh(currentView = True, force = True)

...

It’s becuase you are using evalDeferred. executing later is exactly what evalDeferred does.

I’ve only ever used evalDeferred in userSetup scripts that require Maya cmds or pymel to be loaded before they can execute. Is this a userSetup script?

If eval deferred is necessary because ToggleFullScreenMode is a runtime command, just hunt down the mel a script it uses and see if you can adapt that code.

a search of C:/Program Files/Autodesk/<maya_version>/scripts/startup/defaultRunTimeCommands.mel
reveals that it calls the toggleMainWindowFullScreenMode mel command.
the mel command whatIs will return the mel file that has the script:

whatIs("toggleMainWindowFullScreenMode")
// Result: Mel procedure found in: C:/Program Files/Autodesk/<maya_version>/scripts/startup/toggleMainWindowFullScreenMode.mel //
1 Like

Спасибо Вам за то, что уделили свое время этой проблеме.
Я ранее уже неоднократноизучал текст скрипта “toggleMainWindowFullScreenMode.mel”
Моей ошибкой было то, что я предполагал, что command “evalDeferred” указывает приоритет выполнения в общем потоке, а не в очереди простоя!
I mistakenly suggested that the “Evaldeferred” is the same “EVAL”, but with additional flags.
I mistakenly assumed that the “evaluateNext (en)” flag is: “Specified that the command to be executed should be ran with the highest priority” (Quoted from the Mayan help).
But, in fact (of course!), this flag sets the highest priority for commands in the “Maya is idle” queue, ideally queued up next.
Linguistic misunderstanding on my part (English is not my native or spoken language)

The problem turned out to be (exactly the same!) in the Maya runtime command script - “toggleMainWindowFullScreenMode.mel”, str 28:

evalDeferred("toggleMainWindowFullScreenModeDefer " + $inFullScreenMode + " " + $parentControl);

It was enough to correct the “evalDeferred” command in the Maya-script to the usual “eval” for the script to start executing “correctly” …

My script is meant to be used by other people.
Therefore (because of the extra eight letters!), I will have to transfer the entire implementation of the “ToggleFullScreenMode” command to my script. :frowning:

Thanks again!