Login / Register
▼
Binary Fortress
Binary Fortress Software
CheckCentral
ClipboardFusion
CloudShow
DisplayFusion
FileSeek
HashTools
LogFusion
Notepad Replacer
Online Base64 Decoder
Online Base64 Encoder
Online JSON Formatter
ShellSend
TrayStatus
VoiceBot
WallpaperFusion
Window Inspector
More Apps...
DisplayFusion
CheckCentral
CloudShow
ClipboardFusion
FileSeek
VoiceBot
WallpaperFusion
Home
▼
Download
Download
Change Log
Download Beta
Beta Change Log
License (EULA)
▼
Features
Features
Incredible Desktop Wallpaper
Monitor Configuration
Monitor Splitting
Powerful Functions
Triggers
Multi-Monitor Taskbars
Useful Windows 10 Tweaks
Useful Windows 8 Tweaks
Windows Lock Screen
Multi-Monitor Screen Savers
Monitor Fading
Window Snapping
Window Management
Mouse Management
Alt+Tab Handler
Window Position Profiles
Desktop Icon Profiles
Remote Control
Available in dozens of Languages
Easy Administration
Free vs Pro
Purchase
Screenshots
Languages
▼
Help
Help Guide
FAQ
Discussions
Contact Us
Find My License
Mailing Address
Advanced Settings
Scripted Functions (Macros)
Display
Fusion
WARNING: You currently have Javascript disabled!
This website will not function correctly without Javascript enabled.
Title
Message
OK
Confirm
Yes
No
Lock mouse cursor to current monitor except while hotkey is held down
Return to DisplayFusion Scripted Functions (Macros)
Description
This is an implementation of the requested feature on the forums of having the mouse cursor locked to the current monitor, except while a hotkey is held down.
This function combines the locking function with the unlocking function: Pressing and releasing this function's hotkey locks the mouse to the current monitor. It's then kept locked until you *press and hold down* the hotkey. While it's held down you can freely move between monitors. Once released, it gets locked again to the new current monitor.
Language
C# (.Net)
Minimum Version
9.3+
Created By
Venryx
Contributors
-
Date Created
Nov 9, 2018
Date Last Modified
Nov 9, 2018
Scripted Function (Macro) Code
Copy
Select All
Toggle Line Wrapping
using System; using System.Drawing; using System.Runtime.InteropServices; using System.Windows.Forms; using System.Threading; public static class DisplayFusionFunction { // update this value to match the hotkey you've assigned to this function -- ignoring ctrl, alt, etc. (I use Alt+A) static Keys hotkeyKey = Keys.A; [DllImport("user32")] static extern bool GetAsyncKeyState(int vKey); public static void Run(IntPtr windowHandle) { // if cursor is already unlocked by hotkey, don't start hotkey function again if (BFS.ScriptSettings.ReadValueBool("Cursor unlocked")) return; // unlock the mouse cursor since hotkey has been pressed down Cursor.Clip = Rectangle.Empty; BFS.ScriptSettings.WriteValueBool("Cursor unlocked", true); // wait until the hotkey is released while (GetAsyncKeyState((int)hotkeyKey)) { Thread.Sleep(10); } // then lock the mouse cursor again Cursor.Clip = BFS.Monitor.GetMonitorBoundsByMouseCursor(); BFS.ScriptSettings.WriteValueBool("Cursor unlocked", false); } }
Copyright © 2007-2021 Binary Fortress Software
•
News
•
Discussions
•
FAQ
•
Support
•
Privacy
•
ToS
•
Get DisplayFusion Merch