c# - Send virtual mouse clicks that are ignored by GetAsyncKeyState()? -


I'm experimenting and searching all day, and can not figure out how to do this for my life.

Actually what I am doing:

  // while physically holding the left mouse button ... while (GetAsyncKeyState (0x01)! = 0) { // left mouse button literally down (obviously the first loop is already below) mouse_event (2, 0, 0, 0, 0); Thread.Sleep (100); // Left mouse button works-up mouse_Event (4, 0, 0, 0, 0); }   

Now, while-loop stops, because I actually pick up the button, so what I am asking is the mouse_events / gateSyncCestat (or optional for some parameters). , So I can manipulate major states without affecting the real states. For example, I'm able to do this in AutoHot using Send {LButton up} GetKeyState ("LButton", "P") .

Any thoughts?

contains the LLMHF_INJECTED and LLMHF_LOWER_IL_INJECTED flags Perhaps you should take a look at this.

The code given below is an empty form with timer, configured to be "on" and calls "TimerOnTick" every second.

When you click, the output is "497, 361, 0" when the timer click output "497, 361, 1"

  Using the system; Using System.Diagnostics; Using System.Runtime.InteropServices; Using System.Threading; Using System.Windows.Forms; Namespace Syracuse {Public Partial Class Form 1: Form {Personal Constant WH_MOUSE_LL = 14; Private stable Low LevelMouseProgram _proc = Hookcollback; Private Static IntPtr _hookID = IntPtr.Zero; Public Form 1 () {Initialization (); } Secure Override Zero OnLoad (EventArgs e) {base.OnLoad (e); _hookID = SetHook (_proc); } Secure Override Zero OnClosed (EventArgs e) {base.OnClosed (E); UnhookWindowsHookEx (_hookID); } Private Zero TimerOntic (Object Sender, EventAggas E) {// Left mouse button literally down (apparently already loop first already) Mouse_Event (2, 0, 0, 0, UIITPT.Jero); Thread.Sleep (100); // Left mouse button Virtual Up Mouse_Event (4, 0, 0, 0, UIINTPP.Jero); } Private Static IntPtr HookCallback (Integer nCode, IntPtr wParam, IntPtr lParam) {if (nCode> = 0 & amp; amp; MouseMessages.WM_LBUTTONDOWN == (MouseMessages) wParam) {var hookStruct = (MSLLHOOKSTRUCT) Marshal.PtrToStructure (LParam, typef (MSLLHOOKSTRUCT)); Console. Light Line (Hookstruckt.PT.X + "," + Hookstruct.pa ++ "," + Hookstrat.flags ");} Make Todo OnMouseUpExtensive, On-MouseDownExchange Wicked MSLLHKICTITAR provide information. Return CallNextHookEx (Using the curfrocess = Process.GetCurrentProcess () on the Personal Static IntPtr SetHook (LowLevelMouseProc proc) {} (curmodule = curProcess.MainModule) {return SetWindowsHookEx (WH_MOUSE_LL Process (_HookID, ncode, wParam, lParam) , GetModuleHandle (curModule.ModuleName), 0);}} Personal Representative IntPtr LowLevelMousePro C (int nCode, IntPtr wParam, IntPtr lParam); #region Enum & Private Enum Mouse Message creation {WM_LBUTTONDOWN = 0x0201, WM_LBUTTONUP = 0x0202, WM_MOUSEMOVE = 0x0200, WM_MOUSEWHEEL = 0x020A, WM_RBUTTONDOWN = 0x0204, WM_RBUTTONUP = 0x0205} [Strat Layout (LayoutCind.Secicensual)] Personal Structure MSLLHOOKSTRUCT {Public Issue Point; Public UIT MoodyData; Public UIT Flags; Public Time Time; Public IntPtr dwExtraInfo;} [Structure Layouts (LayoutCind. Sequic]] private stunt POINT {public int x; Public uncertainty; } #endregion #region Extern [DllImport ("user32.dll", charset = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] Public static extern zero mouse_event (uint dwFlags, uint dx, uint dv, uint cButtons, UIntPtr dwExtraInfo); [DllImport ("user32.dll", Charset = Charset.auto, Setlist error = true)] Private static extern IntPtr CallNextHookEx (IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam); [DllImport ("kernel32.dll", Charset = CharSet.Auto, SetLastError = true)) Private static extern IntPtr GetModuleHandle (string lpModuleName); [DllImport ("user32.dll", charset = CharSet.Auto, SetLastError = true)] Private Static Execution IntPtr SetWindowsHookEx (integer idHook, LowLevelMouseProc lpfn, IntPtr hmod, uint dwThreadId); [DllImport ( "user32.dll", charset = charset. Auto, Setlast error = true)] [return: Marshall AS (unmanaged type. Bowl)] private static bool Akstrn Anhukvindo Hukaks (Intpitr Acacke); #endregion}}    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -