public void BeginShow() { //First, capture and save a screenshot for blur effects byte[] screenshot = GetScreenshotOfWindow(); NativeJs nsjs = new NativeJs(); //Convert this into a string we can pass into an image string base64Screenshot = "data:image/png;base64, " + Convert.ToBase64String(screenshot); //Start animation on JS side var activeWindow = GetActiveWindow(); bool isArkActive = false; if (activeWindow != null) { isArkActive = activeWindow.ProcessName == "ShooterGame"; } //If Ark is active, show the window. If not, tell the user to start it. if (isArkActive) { BrowserYo.ExecuteScriptAsync("BeginShow('" + base64Screenshot + "');"); //Also, press the tab key in Ark to open the console. nsjs.pressKey("Tab"); //Set the process StaticVars.arkWindow = activeWindow; } else { isShown = true; StaticVars.allowShowHideNow = true; BrowserYo.ExecuteScriptAsync("ShowArkNotInForegroundWarning();"); } }
public void BeginHide() { //Start animation on JS side BrowserYo.ExecuteScriptAsync("BeginHide();"); //Get rid of the console in Ark. NativeJs nsjs = new NativeJs(); nsjs.setArkActive(); Thread.Sleep(100); nsjs.pressKey("Escape"); }
public MainWindow() { InitializeComponent(); StaticVars.browser = BrowserYo; //Set screen to fill MainWebWindow.WindowState = WindowState.Maximized; //Register the hotkeys var key = new HotKey( (ModifierKeys.None), Key.OemTilde, this, delegate { if (StaticVars.allowShowHideNow) { StaticVars.allowShowHideNow = false; if (isShown) { BeginHide(); } else { BeginShow(); } isShown = !isShown; } } ); //Load dinosaurs StaticVars.dinos = RpTools.DeserializeObject <ArkDino[]>(File.ReadAllText("dinodata.json")); //Init browser BrowserYo.Address = AppDomain.CurrentDomain.BaseDirectory + @"browser\index.html"; CefSharpSettings.LegacyJavascriptBindingEnabled = true; BrowserYo.RegisterAsyncJsObject("boundAsync", new NativeJs()); //Allow StaticVars.allowShowHideNow = true; }