simulate

Simulate mouse click on a minimized window

自作多情 提交于 2019-12-25 03:55:27
问题 I am currently writing an application in C# that will recognize certain patterns on the screen and move to mouse to click on it. Currently, the application needs to have the focus and the mouse cursor moves, so the computer is unusable while the program is running. I would like to simulate a mouse click on a window but without actually moving the mouse on the screen. My goal would be to be able to simulate mouse click on a application that is minimized. Would that be easy to make in C#? 回答1:

How to simulate mouse click in a Directx game

早过忘川 提交于 2019-12-24 13:26:23
问题 I have a game written in Directx (not mine it's mmo game). The game window isn't active (not minimized, just it's behind other windows but if is possible it can be minimized also). I want to simulate mouse click on x, y position. Spy++ doesn't show anything in message when i'm clicking in game. For now i did just that: private void start_Click(object sender, EventArgs e) { IntPtr ActualWindow = GetActiveWindow(); ShowWindow(hWnd, ShowWindowCommands.Restore); //show game window Thread.Sleep(50

How to simulate caught and logged exceptions inside a method and create JUnit tests

我只是一个虾纸丫 提交于 2019-12-24 09:17:11
问题 I have to write JUnit test cases for existing code where I do not have the liberty / opportunity to re-write the actual code. In many of these classes, the methods catch an exception internally and just log it. And the exceptions are not based on any parameters which could be manipulated to attempt to throw the exception, but are thrown by the code inside the method - e.g. - the method may open a file and catch IOException and just log it. Basically, many of the methods just eat all the

How to generate target number of samples from a distribution under a rejection criterion

混江龙づ霸主 提交于 2019-12-24 08:04:29
问题 I'm trying rnbinom as below x<- rnbinom(500, mu = 4, size = .1) xtrunc <- x[x>0] then I just get 125 observations. However, I want to make 500 observations excluding 0 (zero) with same condition ( mu = 4, size =.1 ). 回答1: This does the job: N <- 500 ## target number of samples ## set seed for reproducibility set.seed(0) ## first try x <- rnbinom(N, mu = 4, size = .1) p_accept <- mean(success <- x > 0) ## estimated probability of accepting samples xtrunc <- x[success] ## estimated further

Simulate 'ENTER' Key Press Like Human Hit On Website [duplicate]

南楼画角 提交于 2019-12-24 04:33:05
问题 This question already has answers here : Enter key press event in JavaScript (18 answers) Closed 5 years ago . Is it possible in Javascript/JQuery ? I have a button on my website and I need to simulate human press key "Enter" when someone clicks the button. Example: I clicked button and then it automatically pressed Enter key. 回答1: I modified this code from the code in this answer, var onclick = function(){ var e = $.Event('keypress'); e.which = 13; // Character 'A' $(this).trigger(e); }; $(

Android - How to generate touch event from javascript?

邮差的信 提交于 2019-12-24 01:13:10
问题 Is it possible to generate a touch event in javascript that'll invoke the onTouchEvent() function in my android WebView? I tried with the following javascript code which generates both touchstart and touchend events, but my webview onTouchEvent() function does not get invoked. try{ var evt = document.createEvent('TouchEvent'); evt.initTouchEvent('touchstart', true, true); evt.view = window; evt.altKey = false; evt.ctrlKey = false; evt.shiftKey = false; evt.metaKey = false; this.dispatchEvent

How to get the handle of 3rd party application's button using c#?

梦想的初衷 提交于 2019-12-23 16:53:40
问题 I am trying to generate an click event in a third party application. As a start I tried to simulate a click in calculator. Here's the code" IntPtr hwnd = IntPtr.Zero; IntPtr hwndChild = IntPtr.Zero; //Get a handle for the Calculator Application main window hwnd = FindWindow(null, "Calculator"); hwndChild = FindWindowEx(hwnd, IntPtr.Zero, "Button", "1"); //send BN_CLICKED message SendMessage(hwndChild, BM_CLICK, IntPtr.Zero, IntPtr.Zero); But using this code I am not getting the handle of the

How to simulate mouse clicks?

独自空忆成欢 提交于 2019-12-22 13:51:20
问题 I was wondering how to create a sort of auto clicker using VB.NET. I would basicly have the click coordinates pre-defined and the clicks, which would have to be separated by delays I guess since I want more than one to happen periodically, would happen outside of the application window (I read this envolves extra system hooks?). The only code I have been able to find is related to clicks on the application window, which is not what I am looking for. In short: I want to click a button on the

C# Simulate VolumeMute press

半世苍凉 提交于 2019-12-22 06:49:39
问题 I got the following code to simulate volumemute keypress: [DllImport("coredll.dll", SetLastError = true)] static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo); byte VK_VOLUME_MUTE = 0xAD; const int KEYEVENTF_KEYUP = 0x2; const int KEYEVENTF_KEYDOWN = 0x0; private void button1_Click(object sender, EventArgs e) { keybd_event(VK_VOLUME_MUTE, 0, KEYEVENTF_KEYDOWN, 0); keybd_event(VK_VOLUME_MUTE, 0, KEYEVENTF_KEYUP, 0); } This code doesnt work. I know there's another

Simulate click on GMail div button with JS

為{幸葍}努か 提交于 2019-12-22 05:20:34
问题 I want to simulate click on GMail COMPOSE button using JS without JQuery. Here is button: <div class="T-I J-J5-Ji T-I-KE L3" role="button" tabindex="0" gh="cm" style="-webkit-user-select: none;">COMPOSE</div> Here is my js: var element = document.getElementsByClassName('T-I-KE')[0]; element.click(); Result: undefined in all browsers Image: http://i.imgur.com/4IX9DZX.png Already tried that: var event = document.createEvent("MouseEvent"); event.initEvent("click",true,true); var element=document