public void PreviousSong() { WinNative.keybd_event(0xB1, 0, 1, 0); //keybd_event(0xB1, 0, 0, IntPtr.Zero); StartCoroutine(UpdateSongText()); }
private Vector2 HandleMouseMove(Vector2 pos) { //Vector2 newPos; if (isClicking && !hasClicked && !IsMouseOutsideClickRadius(pos)) { } else { if (Math.Abs((pos.x - mousePos.x) * Time.deltaTime) > mouseMovingFastThreshold || Math.Abs((pos.y - mousePos.y) * Time.deltaTime) > mouseMovingFastThreshold) { //Debug.Log("Moving fast smoothness"); mousePosSmoothed = Vector2.Lerp(mousePosSmoothed, pos, movingFastSmoothness * 15f); } else { //Debug.Log("Moving slow smoothness"); mousePosSmoothed = Vector2.Lerp(mousePosSmoothed, pos, movingSlowSmoothness * 5f); } //curMousePos = result.windowCoord; } mousePos = pos; mousePoint = new Point((int)mousePosSmoothed.x, (int)mousePosSmoothed.y); WinNative.SetCursorPos(mousePoint.X, mousePoint.Y); return(mousePosSmoothed); }
public static WinNative.MonitorInfoEx FetchMonitorInfo(IntPtr handle) { WinNative.MonitorInfoEx info = new WinNative.MonitorInfoEx(); info.cbSize = (int)Marshal.SizeOf(info); WinNative.GetMonitorInfo(handle, ref info); return(info); }
public static void FocusActiveGame() { //if (!DPSettings.config.returnFocusWhenBarClosed) return; if (activePID == 0 || activeProcess == null) { return; } //Debug.Log("Focusing game...."); IntPtr[] gameHandles = WinNative.GetProcessWindows(activePID); foreach (IntPtr handle in gameHandles) { if (handle == IntPtr.Zero) { WinNative.ShowWindow(handle, ShowWindowCommands.Restore); } WinNative.SetForegroundWindow(handle); } }
public void TogglePlay() { WinNative.keybd_event(0xB3, 0, 1, 0); //keybd_event(0xB3, 0, 0, IntPtr.Zero); StartCoroutine(UpdateSongText()); }
/* * public static void Test(UwcWindow window) { * * //Screen currentScreen = Screen.FromHandle(window.handle); * * * var monitor = WinNative.MonitorFromWindow(window.handle, WinNative.MONITOR_DEFAULTTONEAREST); * * if (monitor != IntPtr.Zero) { * * var monitorInfo = new NativeMonitorInfo(); * //Win32Stuff.GetMonitorInfo( monitor, monitorInfo ); * * * * var left = monitorInfo.Work.Left; * var top = monitorInfo.Work.Top; * var width = ( monitorInfo.Work.Right - monitorInfo.Work.Left ); * var height = ( monitorInfo.Work.Bottom - monitorInfo.Work.Top ); * * * Debug.Log(left); * Debug.Log(top); * * Debug.Log(width); * Debug.Log(height); * } * * * * * * } */ public static void RefreshWindowList() { var windows = WinNative.FindWindowsWithSize(); var processes = Process.GetProcesses(); foreach (Process p in processes) { if (p.Handle == IntPtr.Zero || p.ProcessName == "explorer") { continue; } activeProcesses.Add(p); } return; windowPtrs.Clear(); var count = 0; foreach (var w in windows) { windowPtrs.Add(w); //Win32Stuff.WINDOWINFO winInfo = new Win32Stuff.WINDOWINFO(); //bool success = Win32Stuff.GetWindowInfo(w, ref winInfo); //if (title.Length <= 0) continue; //var copy = 0; //var found = false; //while (!found) //{ // try // { // realWindows.Add(copy == 0 ? title : string.Format("{0} ({1})", title, copy), w); // // found = true; // } // catch (ArgumentException) // { // copy++; // } //} //_titles.Add(copy == 0 ? title : string.Format("{0} ({1})", title, copy)); //Debug.Log(String.Format("{0}", success)); count++; } Debug.Log("Found " + count + " windows"); }
public static IEnumerator UpdateWeirdOffset(UDDMonitor monitor, UwcWindow window) { WinNative.SetCursorPos(0, 0); WinNative.SetWindowPos(window.handle, 0, 0, 0, 0, 0, SetWindowPosFlags.SWP_NOSIZE); int size = Marshal.SizeOf(typeof(RECT)); WinNative.SetThreadDpiAwarenessContext(PROCESS_DPI_AWARENESS.PROCESS_PER_MONITOR_DPI_AWARE); RECT rect = new RECT(); RECT frame = new RECT(); WinNative.GetWindowRect(window.handle, ref rect); WinNative.DwmGetWindowAttribute(window.handle, DWMWINDOWATTRIBUTE.ExtendedFrameBounds, out frame, size); //rect should be `0, 0, 1280, 1024` //frame should be `7, 0, 1273, 1017` RECT border = new RECT(); border.Left = frame.Left - rect.Left; border.Top = frame.Top - rect.Top; border.Right = rect.Right - frame.Right; border.Bottom = rect.Bottom - frame.Bottom; Debug.Log(border.Left); yield return(new WaitForSeconds(0.1f)); WinNative.MoveOverWindow(window.handle, new Point(0, 0), true); WinNative.POINT curCursorPos = new WinNative.POINT(); WinNative.GetCursorPos(ref curCursorPos); //window.weirdOffset = Math.Abs(curCursorPos.x); yield break; while (true) { RECT yay = new RECT(); WinNative.GetWindowRect(window.handle, ref yay); Debug.Log(yay.Left); yield return(null); } //Debug.Log(window.weirdOffset); }
public void Minimize() { if (SteamVRManager.isWearingHeadset && startupScreenDPApp.dpMain.overlay.shouldRender) { TheBarManager.I.MinimizeApp(startupScreenDPApp.appKey); } else { WinNative.ShowWindow(WinNative.GetForegroundWindow(), ShowWindowCommands.Minimize); } }
private void HandleKeyPress(KButton kButton, bool down) { /*if (DPSettings.config.focusGameWhenNotInteracting) { * if (DPDesktopOverlay.primaryWindowDP != null && DPDesktopOverlay.primaryWindowDP.isTargetingWindow) { * WinNative.SetForegroundWindow(DPDesktopOverlay.primaryWindowDP.window.handle); * } * }*/ if (DPDesktopOverlay.primaryWindowDP != null && DPDesktopOverlay.primaryWindowDP.isTargetingWindow) { WinNative.SetForegroundWindow(DPDesktopOverlay.primaryWindowDP.window.handle); } if (kButton.isShift) { OnShiftChanged(down); } Char potentialChar = Char.MinValue; if (kButton.isPersistent && down) { //if (kButton.key == KeysEx.VK_SPACE) currentString = ""; //if (kButton.key == KeysEx.VK_BACK) currentString = currentString.Remove(currentString.Length - 1, 1); } else if (down) { potentialChar = kButton.mainChar[0]; if (isShiftDown) { potentialChar = kButton.shiftChar[0]; } else if (isAltDown) { potentialChar = kButton.altChar[0]; } currentString += potentialChar; } activeDP.onKeyboardInput?.Invoke((Keys)kButton.key, potentialChar, down); //UpdatePredicitions(); if (down && activeDP != null) { activeDP.RequestRendering(); } }
/// <summary> /// Used internally for making a new overlay. /// </summary> /// <param name="window"></param> /// <returns>The created overlay</returns> public DPDesktopOverlay NewDPWindowOverlay(UwcWindow window) { if (window == null) { return(null); } int index = GetValidOverlayIndex(); if (DemoManager.isDemo) { if (DPDesktopOverlay.overlays.Count >= 3) { return(null); } } DPDesktopOverlay dpWindow = Instantiate(dpRenderWindowPF, _overlaysHolderTransform).GetComponentInChildren <DPDesktopOverlay>(); dpWindow.PreInitialize(); string key = "DPWindow-" + index; dpWindow.dpAppParent.appKey = key; //dpWindow.InitWindow(window); if (WinNative.IsIconic(window.handle)) { WinNative.ShowWindow(window.handle, ShowWindowCommands.Restore); } //WinNative.SetForegroundWindow(window.handle); dpWindow.SetTargetCapture(window); dpWindow.dpAppParent.iconTex = window.iconTexture; overlays.Add(dpWindow); TheBarManager.I.AddLoadedApp(dpWindow.dpAppParent); //OverlayInteractionManager.I.StartPreviewDrag(key); //TheBarManager.I.LaunchAppToMainSnap(key); Debug.Log(dpWindow.overlay.handle + " : " + dpWindow.overlay.overlayKey + " : " + dpWindow.window.handle); return(dpWindow); }
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e) { isMouseDown = true; base.OnMouseDown(e); appCanvas.Resize(e.X, -e.Y); IntPtr hwnd = this.Handle; IntPtr hdc = WinNative.GetDC(hwnd); //canvas paint, clear bg appCanvas.RenderTo(hdc); WinNative.ReleaseDC(hwnd, hdc); }
public void HandleScrollEvent(DPInteractor interactor, float delta) { uint newDelta = 0; if (delta > DPSettings.config.joystickDeadzone || delta < -DPSettings.config.joystickDeadzone) { //newDelta = (int) (delta * 0.3f * Time.deltaTime * 144f); newDelta = (uint)(delta * 120 * Time.deltaTime * 10); //if (isTargetingWindow) CursorInteraction.CursorSendInput(window.handle, CursorInteraction.SimulationMode.ScrollV, mousePoint, newDelta); WinNative.mouse_event(0x0800, 0, 0, newDelta, 0); } }
public static void RefreshAllWindows() { //First, focus all them so the game isn't on top of any: foreach (DPOverlayBase dpBase in OverlayManager.I.overlays) { if (dpBase is DPDesktopOverlay desktopDP) { //renderDP.ToggleWindowMonitorCapture(renderDP.isPrimary); desktopDP.UpdateOverlayUVs(); if (desktopDP.isTargetingWindow && desktopDP.isPrimary) { WinNative.SetForegroundWindow(desktopDP.window.handle); } } } }
public static RECT GetExtensionSizeForWindow(UwcWindow window) { int size = Marshal.SizeOf(typeof(RECT)); WinNative.SetThreadDpiAwarenessContext(PROCESS_DPI_AWARENESS.PROCESS_PER_MONITOR_DPI_AWARE); RECT rect = new RECT(); RECT frame = new RECT(); WinNative.GetWindowRect(window.handle, ref rect); WinNative.DwmGetWindowAttribute(window.handle, DWMWINDOWATTRIBUTE.ExtendedFrameBounds, out frame, size); RECT border = new RECT(); border.Left = frame.Left - rect.Left; border.Top = frame.Top - rect.Top; border.Right = rect.Right - frame.Right; border.Bottom = rect.Bottom - frame.Bottom; return(border); }
private IEnumerator ForcePrimaryOnTop() { yield return(new WaitForSeconds(1f)); float i = 0; while (i < 10) { if (DPDesktopOverlay.primaryWindowDP != null && DPDesktopOverlay.primaryWindowDP.isTargetingWindow) { /*if (DPDesktopOverlay.primaryWindowDP.window.isIconic) { * WinNative.ShowWindow(DPDesktopOverlay.primaryWindowDP.window.handle, ShowWindowCommands.Restore); * }*/ WinNative.SetForegroundWindow(DPDesktopOverlay.primaryWindowDP.window.handle); } i += 1; yield return(new WaitForSeconds(1f)); } }
private void HandleMinimizeAtStartup() { if (DPSettings.config.minimizeAtStartup) { int currentPID = System.Diagnostics.Process.GetCurrentProcess().Id; WinNative.EnumWindows(delegate(IntPtr wnd, IntPtr param) { int returnVal = WinNative.GetWindowThreadProcessId(wnd, out int procid); //We found it if (procid == currentPID) { WinNative.ShowWindow(wnd, ShowWindowCommands.Minimize); return(false); } return(true); }, IntPtr.Zero); } }
public IEnumerator AddWindowCaptureAppIcon(UwcWindow window) { window.PopulateFriendlyTitle(); string key = window.GetAppKey(); //Check if the app already exists foreach (AppIcon temp in apps) { if (temp.appKey == key) { yield break; } } window.RequestCaptureIcon(); yield return(new WaitForSeconds(0.3f)); StartMenuAppSer appSer = new StartMenuAppSer { appKey = key, appTitle = window.friendlyTitle, filePath = WinNative.GetFilePath(window.handle), isCustomApp = false, isFavorite = false, }; DPSettings.config.startMenu.apps.Add(appSer); _customAppManager.CacheAppIcon(appSer.appKey, window.iconTexture); yield return(new WaitForSeconds(0.2f)); LoadApps(false); SaveLoaded(); }
private void OnInteractedWith(bool interacting) { if (!loaded) { return; } //Debug.Log("Interaction state: " + interacting); isInteractingVirtually = interacting; if (interacting && isTargetingWindow) { if (isTargetingWindow && window.isIconic) { WinNative.ShowWindow(window.handle, ShowWindowCommands.Restore); } WinNative.SetForegroundWindow(window.handle); if (primaryWindowDP != this) { //Clear the previous if (primaryWindowDP != null) { primaryWindowDP.isPrimary = false; //if (primaryWindowDP.isTargetingWindow) { //} primaryWindowDP.RequestRendering(); //primaryWindowDP.UpdateOverlayUVs(); } //StartCoroutine(C_Lock()); primaryWindowDP = this; isPrimary = true; UDDManager.instance.gameObject.SetActive(false); UDDManager.instance.gameObject.SetActive(true); //UpdateOverlayUVs(); } } //Update the title if (interacting) { if (!isTargetingWindow) { dpAppParent.title = monitor.name; } else { dpAppParent.title = window.title; } } //This only runs when the bar is closed and the config option is enabled if (DPSettings.config.focusGameWhenNotInteracting && !interacting) { GamingManager.FocusActiveGame(); } }
public static void FitWindowOnMonitor(UDDMonitor monitor, UwcWindow window, bool resize = false, int widthRatio = 0, int heightRatio = 0, float maxWidthFill = 0.9f, float maxHeightFill = 1f) { //IntPtr monitorHandle = WinNative.MonitorFromWindow(handle, WinNative.MONITOR_DEFAULTTONEAREST); //WinNative.MonitorInfoEx monitorInfo = FetchMonitorInfo(handle); WinNative.SetForegroundWindow(window.handle); //WM_GETMINMAXINFO //WinNative.SendMessage(window.handle, 0x0024, ) if (monitor == null) { Debug.LogError("Monitor was null!"); return; } int potentialWidth = 0, potentialHeight = 0; if (resize) { bool found = false; int i = 0; while (!found && i < 3000) { potentialWidth += widthRatio; potentialHeight += heightRatio; if (potentialWidth > monitor.workingArea.Width * maxWidthFill) { found = true; } if (potentialHeight > monitor.workingArea.Height * maxHeightFill) { found = true; } //Fallback: i++; } } RECT border = GetExtensionSizeForWindow(window); int xPos = monitor.left + monitor.workingArea.Left - border.Left; int yPos = monitor.top + monitor.workingArea.Top; if (resize) { //int xPos = monitor.workingArea.Left; //int yPos = monitor.workingArea.Top; potentialWidth += border.Left + border.Right; potentialHeight += border.Bottom; WinNative.SetWindowPos(window.handle, 0, xPos, yPos, potentialWidth, potentialHeight, SetWindowPosFlags.SWP_NOSENDCHANGING | SetWindowPosFlags.SWP_SHOWWINDOW); } else { //int xPos = monitor.workingArea.Left - border.Left; //int yPos = monitor.workingArea.Top; //WinNative.SetWindowPos(window.handle, 0, xPos, yPos, 0, 0, SetWindowPosFlags.SWP_NOSENDCHANGING | SetWindowPosFlags.SWP_SHOWWINDOW | SetWindowPosFlags.SWP_NOSIZE); } }
private IEnumerator C_JoinDiscord() { //Clipboard.SetText("https://discord.gg/adVEQmY"); Process.Start("https://discord.gg/adVEQmY"); yield break; UwcWindow discordWindow = null; DPDesktopOverlay discordDP = null; DPApp discordDPApp = null; //See if discord is opened already foreach (DPDesktopOverlay desktopDP in DPDesktopOverlay.overlays) { if (desktopDP.isTargetingWindow && desktopDP.window.title.EndsWith("- Discord")) { discordDP = desktopDP; discordWindow = desktopDP.window; break; } } //If the overlay isn't already opened, we try to spawn a new one if (discordWindow == null) { //See if discord is opened foreach (UwcWindow window in UwcManager.windows.Values) { if (window.title.EndsWith("- Discord")) { discordWindow = window; discordDP = OverlayManager.I.NewDPWindowOverlay(discordWindow); break; } } } //TODO: Launch discord //if (discordWindow == null || discordDP == null) { Process.Start("https://discord.gg/adVEQmY"); yield break; //} //Find the DPApp foreach (DPApp app in TheBarManager.openApps.Values) { if (app.dpMain == discordDP) { discordDPApp = app; break; } } if (discordWindow.isIconic) { WinNative.ShowWindow(discordWindow.handle, ShowWindowCommands.Restore); } TheBarManager.I.LaunchAppToMainSnap(discordDPApp.appKey); WinNative.SetForegroundWindow(discordWindow.handle); yield return(new WaitForSeconds(0.2f)); yield return(new WaitForSeconds(0.2f)); //const int WM_KEYDOWN = 0x100; //const int WM_KEYUP = 0x101; //WinNative.PostMessageSafe(discordWindow.handle, WM_KEYDOWN, (int)KeysEx.VK_LCONTROL, 0); //WinNative.PostMessageSafe(discordWindow.handle, WM_KEYDOWN, (int)KeysEx.VK_LSHIFT, 0); //WinNative.PostMessageSafe(discordWindow.handle, WM_KEYDOWN, (int)KeysEx.VK_N, 0); InputSimulator inputSimulator = new InputSimulator(); //inputSimulator.Keyboard.KeyDown(VirtualKeyCode.CONTROL); inputSimulator.Keyboard.ModifiedKeyStroke(new[] { VirtualKeyCode.LCONTROL, VirtualKeyCode.LSHIFT }, new[] { VirtualKeyCode.VK_N }); yield return(new WaitForSeconds(0.2f)); inputSimulator.Keyboard.KeyPress(VirtualKeyCode.TAB); inputSimulator.Keyboard.KeyPress(VirtualKeyCode.TAB); inputSimulator.Keyboard.KeyPress(VirtualKeyCode.TAB); inputSimulator.Keyboard.KeyPress(VirtualKeyCode.RETURN); yield return(new WaitForSeconds(0.2f)); inputSimulator.Keyboard.TextEntry("https://discord.gg/adVEQmY"); /*//Tab 3 times to the join server button: * WinNative.PostMessageSafe(discordWindow.handle, WM_KEYDOWN, (int)KeysEx.VK_TAB, 0); * WinNative.PostMessageSafe(discordWindow.handle, WM_KEYDOWN, (int)KeysEx.VK_TAB, 0); * WinNative.PostMessageSafe(discordWindow.handle, WM_KEYDOWN, (int)KeysEx.VK_TAB, 0); * * yield return null; * * //Enter * WinNative.PostMessageSafe(discordWindow.handle, WM_KEYDOWN, (int)KeysEx.VK_RETURN, 0); * * yield return new WaitForSeconds(0.2f); * * //Paste in the join link * WinNative.PostMessageSafe(discordWindow.handle, WM_KEYDOWN, (int)KeysEx.VK_LCONTROL, 0); * WinNative.PostMessageSafe(discordWindow.handle, WM_KEYDOWN, (int)KeysEx.VK_V, 0); * yield return null; * WinNative.PostMessageSafe(discordWindow.handle, WM_KEYUP, (int)KeysEx.VK_V, 0); * WinNative.PostMessageSafe(discordWindow.handle, WM_KEYUP, (int)KeysEx.VK_LCONTROL, 0); * * yield return null; * * //Enter to join: * WinNative.PostMessageSafe(discordWindow.handle, WM_KEYDOWN, (int)KeysEx.VK_RETURN, 0);*/ }
/// <summary> /// Gets the current state of a DPApp and puts it in a serializable form /// </summary> /// <param name="dpApp">The DPApp to get the state of</param> /// <returns></returns> public static DPAppSerialized GetState(DPApp dpApp) { var dpBase = dpApp.dpMain; DPAppSerialized state = new DPAppSerialized() { isVisible = dpApp.isVisible, isMinimized = dpApp.isMinimized, pos = dpBase.transform.localPosition, rot = dpBase.transform.localEulerAngles, width = dpBase.overlay.width, curvature = dpBase.overlay.curvature, trackedDevice = dpBase.overlay.trackedDevice, smoothAnchoringTrackedDevice = dpBase.smoothAnchoringTrackedDevice, snapAnchoringTrackedDevice = dpBase.snapAnchoringTrackedDevice, isAnchoredToTheBar = dpBase.isAnchoredToTheBar, useSmoothAnchoring = dpBase.useSmoothAnchoring, smoothAnchoringStrength = dpBase.smoothAnchoringStrength, useSnapAnchoring = dpBase.useSnapAnchoring, snapAnchoringDistance = dpBase.snapAnchoringDistance, isPinned = dpBase.isPinned, captureFPS = dpBase.fpsToCaptureAt, forceCaptureRate = dpBase.forceHighCaptureFramerate, opacity = dpBase.overlay.targetOpacity, useLookHiding = dpBase.useLookHiding, lookHidingStrength = dpBase.lookHidingStrength, lookHidingHideOpacity = dpBase.lookHidingOpacity, useDistanceHiding = dpBase.useDistanceHiding, distanceHidingDistance = dpBase.distanceHidingDistance, distanceHidingOpacity = dpBase.distanceHidingOpacity, useWindowCropping = dpBase.useWindowCropping, cropAmount = dpBase.cropAmount, useSBS = dpBase.overlay.useSBS, sbsCrossedMode = dpBase.overlay.sbsCrossedMode, useTouchInput = dpBase.useTouchInput, alwaysInteract = dpBase.alwaysInteract, alwaysInteractBlockInput = dpBase.alwaysInteractBlockInput, disableInteraction = dpBase.isInteractable, disableDragging = dpBase.isDraggable }; //If it's smooth/snap anchored, get the position of the target object instead if (state.useSmoothAnchoring) { state.pos = dpApp.dpMain.smoothAnchoringDummyObject.transform.localPosition; state.rot = dpApp.dpMain.smoothAnchoringDummyObject.transform.localEulerAngles; } else if (state.useSnapAnchoring) { state.pos = dpApp.dpMain.snapAnchoringDummyObject.transform.localPosition; state.rot = dpApp.dpMain.snapAnchoringDummyObject.transform.localEulerAngles; } //Special code if it's a desktop capture if (dpApp.isCapture && dpBase is DPDesktopOverlay desktopDP) { state.isCapture = true; if (desktopDP.isTargetingWindow) { //If the title is long enough, store the last characters if (desktopDP.window.title.Length > I.partialWindowTitleCharacters) { state.partialWindowTitle = desktopDP.window.title.Substring(desktopDP.window.title.Length - I.partialWindowTitleCharacters); } else { state.partialWindowTitle = desktopDP.window.title; } state.exePath = WinNative.GetFilePath(desktopDP.window.handle); } else { //Store the name of the display state.displayName = desktopDP.monitor.name; } } else { state.isCapture = false; } return(state); }
public void CheckForMouseClick(DPInteractor interactor, float triggerStrength) { //float triggerStrength = 0.0f; //_unitySteamVrHandler.handTriggerStrengths[activeControllerIndex]; //Debug.Log(triggerStrength); if (isClicking && !hasClicked) { mouseClickHoldTime += Time.deltaTime; } //Haptics //if (!triggeredRightClickHaptics && potentialClick && mouseClickHoldTime > rightClickHoldThreshold) { // //HapticsManager.SendHaptics(activeControllerIndex, 1, 0.7f); // triggeredRightClickHaptics = true; //} if (!isClicking && triggerStrength > triggerStartClickThreshold) { isClicking = true; startClickPos = mousePos; } if (isClicking && !hasClicked && triggerStrength > triggerDoClickThreshold) { potentialClick = true; } //Drag click if (!isDragging && !hasClicked && potentialClick) { isDragging = true; //Move the mouse back to the origin of the click: Point startPoint = new Point((int)startClickPos.x, (int)startClickPos.y); WinNative.SetCursorPos(startPoint.X, startPoint.Y); //WinNative.mouse_event(WinMouseEvents.WM_MOUSEMOVE); //Debug.Log("starting touch drag"); //left down at the origin //CursorInteraction.CursorSendInput(window.handle, // CursorInteraction.SimulationMode.LeftDown); if (useTouchInput) { TouchInject.BeginDragging(startPoint); } else { inputSimulator.Mouse.LeftButtonDown(); } onClickedOn?.Invoke(this); //Move back to where the user had the mouse //CursorInteraction.SetCursorPos(mousePoint.X, mousePoint.Y); } if (isDragging) { //Debug.Log(mousePoint.X); if (useTouchInput) { TouchInject.AddToActiveDrag(mousePoint); } } //End drag click if (isDragging && triggerStrength <= 0.1f) { /*CursorInteraction.CursorSendInput(window.handle, * CursorInteraction.SimulationMode.LeftUp, new Point(), * 0); * EndMouseClick();*/ //Debug.Log("ending drag"); //if (useTouchInput) { TouchInject.EndActiveDrag(); //} //else { inputSimulator.Mouse.LeftButtonUp(); //} EndMouseClick(); } //Right click (we have to check this first to see the mouse hold time) /*if (!isDragging && !hasClicked && potentialClick && * triggerStrength <= (triggerDoClickThreshold - triggerBackToClickThreshold) && * mouseClickHoldTime > rightClickHoldThreshold) { * CursorInteraction.CursorSendInput(selectedDPWindowOverlay.window.handle, * CursorInteraction.SimulationMode.RightClick, * new Point((int) curMousePos.x, (int) curMousePos.y), 0); * * hasClicked = true; * }*/ //Left click /*else if (!isDragging && !hasClicked && potentialClick && * triggerStrength <= (triggerDoClickThreshold - triggerBackToClickThreshold)) { * CursorInteraction.CursorSendInput(window.handle, CursorInteraction.SimulationMode.LeftClick, new Point(), 0); * * hasClicked = true; * }*/ //Allows to click again once the trigger is back below the inital threshold if (isClicking && triggerStrength <= triggerStartClickThreshold) { EndMouseClick(); } //TODO: clear click state when active controller changed }
public static UDDMonitor GetMonitor(UwcWindow window) { if (window.isIconic) { WinNative.ShowWindow(window.handle, ShowWindowCommands.ShowMaximized); } RECT rect = new RECT(); WinNative.GetWindowRect(window.handle, ref rect); UDDMonitor closestMonitor; int midX = 0, midY = 0; midX = window.rawX + (int)(window.rawWidth / 2f); midY = window.rawY + (int)(window.rawHeight / 2f); foreach (UDDMonitor monitor in monitors) { if (monitor.left > midX) { continue; } if (monitor.top > midY) { continue; } if (monitor.right <= midX) { continue; } if (monitor.bottom <= midY) { continue; } closestMonitor = monitor; return(closestMonitor); break; } //else, it failed, so return the biggest monitor: UDDMonitor biggestMonitor = null; foreach (UDDMonitor monitor in monitors) { if (biggestMonitor == null) { biggestMonitor = monitor; } if (monitor.width > biggestMonitor.width && monitor.height > biggestMonitor.height) { biggestMonitor = monitor; } } return(biggestMonitor); }
private IEnumerator FocusDelayed() { yield return(new WaitForSeconds(0.2f)); WinNative.SetForegroundWindow(activeProcess.MainWindowHandle); }