 		}
 		else
 		{
+		Critical
+		ReplaceSystemCursor(,"IDC_WAIT")
+			if (Instr(PrgPaths, "Wrye Bash.exe"))
+			{
+			;proc := "Wrye Bash.exe"
+			temp := 0
+			fTemp := 0
+				while (fTemp < 2)
+				{
+				fTemp := 0
+					for proc in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process")
+					{
+						strTemp := proc.Name
+
+						if (InStr(strTemp, "Wrye Bash.exe"))
+						{
+						fTemp++
+							if (proc.ProcessId != PrgPIDtmp)
+							{
+							temp := proc.ProcessId
+							}
+						}
+					}
+				sleep 500
+				}
+			PrgPIDtmp := temp
+			WinWait, ahk_pid %PrgPIDtmp%,, 20000
+			;msgbox % "PrgPIDtmp " PrgPIDtmp " proc.Name " proc.Name " strTemp " strTemp " proc.ProcessId " proc.ProcessId " fTemp " fTemp
+			}
+			else
+			{
 			; wait for a window
-			if (PrgPIDtmp)
-			WinWait, ahk_pid %PrgPIDtmp%,, 10000
+				if (Instr(PrgPaths, "-editor -notimeout"))
+				{
+				temp := 0
+					while (!temp)
+					{
+						for proc in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process")
+						{
+						strTemp := proc.Name
+
+							if (InStr(strTemp, "TESConstructionSet.exe"))
+							temp := proc.ProcessId
+						}
+					sleep 500
+					}
+				PrgPIDtmp := temp
+				WinWait, ahk_pid %PrgPIDtmp%,, 20000
+sleep 6000
+
+/*
+WinGet, winIDs, List, TES Construction Set
+Loop, %winIDs%
+{
+OutputVar1 := OutputVar := winIDs%A_Index%
+WinGetClass, OutputVar, % "ahk_id" OutputVar
+WinGetTitle, OutputVar1, % "ahk_id" OutputVar1
+StrTemp := "Window " winIDs%A_Index% " Class " OutputVar " Title " OutputVar1 "`n"
+}
+
+OutputVar := winIDs%A_Index%
+winGet, fTemp, PID, TES Construction Set
+msgbox % StrTemp . "`nCS Pid :" fTemp " PrgPIDtmp: " PrgPIDtmp
+ReplaceSystemCursor()
+return
+
+WinGet, firstPIDhWnd, ID, ahk_pid %PrgPIDtmp%
+hWndArray := []
+hWndArray := WinEnum(firstPIDhWnd)
+fTemp := 1
+while (hWndArray[fTemp])
+{
+WinGetClass, OutputVar, % "ahk_id" hWndArray[fTemp]
+WinGetTitle, OutputVar1, % "ahk_id" hWndArray[fTemp]
+StrTemp := "Window " hWndArray[fTemp] " Class " OutputVar " Title " OutputVar1 "`n"
+fTemp++
+}
+*/
+
+				}
+				else
+				{
+				if (PrgPIDtmp)
+				WinWait, ahk_pid %PrgPIDtmp%,, 1000
+				}
+			}
 		}
 
 

	}
	else
	{
		if (InStr(inputStr, A_Space))
		{
			Loop, Parse, inputStr, %A_Space%
			{
			strTemp .= A_Space . A_LoopField
			strTemp2 := A_LoopField 
			}
		strTemp := StrReplace(strTemp, strTemp2, chr(34) . strTemp2 . chr(34))
		}
	}

return % (strTemp)? strTemp: inputStr

				WinClose, ahk_pid %PrgPIDtmp%
				sleep 220
				;Try again
				
				Process, Exist, %PrgPIDtmp%
					if (ErrorLevel)
					{
