{
	"robotiqProcessInfo": {
		"id": "",
		"organizationName": "",
		"organizationId": "",
		"name": "pero",
		"description": "",
		"author": "",
		"version": "",
		"createdOn": "",
		"lastModified": ""
	},
	"steps": [
		{
			"children": [
				{
					"stepType": "ScriptStep",
					"id": "e8bd8bbb-2c14-1110-53eb-05771da23ed7",
					"expression": "string ffmpegFolderPath = (string)VR[\"startVideoLogFFmpegFolderPath\"];\r\nstring processName = (string)VR[\"startVideoLogProcessName\"];\r\nstring videoStoragePath = (string)VR[\"startVideoLogVideoStoragePath\"];\r\nint numberOfVideosToKeepInHistory = (int)VR[\"startVideoLogNumberOfVideosToKeepInHistory\"];\r\n\r\n//If directory doesn't exist it will be created - if it does it will do nothing\r\nSystem.IO.Directory.CreateDirectory(videoStoragePath);\r\n\r\nif (Directory.Exists(videoStoragePath))\r\n{\r\n    //order files in directory by newest first and delete all but the 3 newest files\r\n    foreach (var fi in new DirectoryInfo(videoStoragePath).GetFiles().OrderByDescending(x => x.LastWriteTime).Skip(numberOfVideosToKeepInHistory))\r\n        fi.Delete();\r\n\r\n    string DateString = DateTime.Now.ToString(\"ddMMyyyy_hhmmss\");\r\n\r\n    try\r\n    {\r\n        Process process = new Process();\r\n        string command = string.Format(@\"-hide_banner -loglevel error -y -rtbufsize 50M -f gdigrab -framerate 10 -probesize 50M -draw_mouse 1 -thread_queue_size 4096 -i desktop -c:v libx264 -r 10 -bufsize 5M -preset ultrafast -tune zerolatency -crf 38 -pix_fmt yuv420p \"\"{0}/{1}_video_log_{2}.mp4\"\"\",videoStoragePath,processName,DateString);\r\n        //Console.WriteLine(\"command: \"+command);\r\n        process.StartInfo.FileName = System.IO.Path.Combine(ffmpegFolderPath,\"ffmpeg\");\r\n        //Console.WriteLine(\"process.StartInfo.FileName: \"+process.StartInfo.FileName);\r\n        process.StartInfo.UseShellExecute = true;\r\n        process.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;\r\n        process.StartInfo.Arguments = command;\r\n        process.Start();\r\n    }\r\n    catch (Exception e)\r\n    {\r\n        Console.WriteLine(\"exception: \"+e);\r\n    }\r\n}\r\n\r\n\r\n\r\n\r\n",
					"name": "Start FFMPEG recording"
				},
				{
					"stepType": "ScriptStep",
					"id": "9cf56af4-5d87-49b5-e51f-a27a1f170996",
					"expression": "[DllImport(\"user32.dll\")]\r\n[return: MarshalAs(UnmanagedType.Bool)]\r\nstatic extern bool SetForegroundWindow(IntPtr hWnd);\r\n\r\n\r\nvoid Main()\r\n{\r\n    string targetProcessName = \"Robotiq.ScriptExecutor\";\r\n        \r\n    // Retrieve all processes with the specified name\r\n    Process[] processes = Process.GetProcessesByName(targetProcessName);\r\n    \r\n    foreach (Process process in processes)\r\n    {\r\n        // Assuming we're only interested in processes with a main window\r\n        if (process.MainWindowHandle != IntPtr.Zero)\r\n        {\r\n            // Bring the process's main window to the foreground\r\n            SetForegroundWindow(process.MainWindowHandle);\r\n            \r\n            // Bring the process's main window to the foreground\r\n            if (SetForegroundWindow(process.MainWindowHandle))\r\n            {\r\n                // Ensure the window has time to become active\r\n                Thread.Sleep(5000); // Adjust the sleep time as necessary\r\n                \r\n                // Simulate pressing the \"Enter\" key\r\n                SendKeys.SendWait(\"{ENTER}\");\r\n\r\n                // Since we've found, activated, and sent keys to the window, we can stop searching\r\n                break;\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\nMain();",
					"name": "Switch Back to Executor"
				}
			],
			"stepType": "DefineFunction",
			"outParamNames": [],
			"paramNames": [
				{
					"name": "startVideoLogFFmpegFolderPath",
					"variableType": 3
				},
				{
					"name": "startVideoLogProcessName",
					"variableType": 3
				},
				{
					"name": "startVideoLogNumberOfVideosToKeepInHistory",
					"variableType": 0
				},
				{
					"name": "startVideoLogVideoStoragePath",
					"variableType": 3
				}
			],
			"functionName": "demo/StartVideoLog",
			"name": "StartVideoLog",
			"paramNames[0]": "startVideoLogFFmpegFolderPath",
			"paramNames[1]": "startVideoLogProcessName",
			"paramNames[2]": "startVideoLogNumberOfVideosToKeepInHistory",
			"paramNames[3]": "startVideoLogVideoStoragePath",
			"paramNames[4]": "configExcelSheetName",
			"paramNames[5]": "processName",
			"id": "784dd5d5-2987-70bf-b9f0-7682d33ff28d",
			"outParamNames[0]": "startVideoLogSuccessFlag",
			"outParamNames[1]": "startVideoLogErrorMsg"
		}
	]
}