cursor-position

How do I set the position of the mouse cursor from a Console app in C#?

流过昼夜 提交于 2019-12-05 07:57:06
I've found many articles on how to set the mouse position in a C# windows forms project - I want to do this in a console application. How can I set the absolute mouse position from a C# windows console application? Thanks! Hint: it's not Console.setCursorPosition, that only sets the position of the text cursor in the console. Inside your console application, add a reference to System.Windows.Forms.dll and use the other techniques you've read about. The choice of console vs windows exe only impacts the PE header (and maybe the default code template, but you can hack that trivially); you can

Snap to grid mouse locking up

徘徊边缘 提交于 2019-12-04 17:04:38
I am working on an application which draws a simple dot grid. I would like the mouse to snap between the points on the grid, eventually to draw lines on the grid. I have a method which takes in the current mouse location (X,Y) and calculates the nearest grid coordinate. When I create an event and attempt to move the mouse to the new coordinate the whole system becomes jerky. The mouse doesn't snap smoothly between grid points. I have copied a code sample below to illustrate what I am attempting to do. Does anyone have any advice they could offer me as to how I can eliminate the jumpiness

Building a pagination cursor

戏子无情 提交于 2019-12-04 07:16:54
I have activities that are stored in a graph database. Multiple activities are grouped and aggregated into 1 activity in some circumstances. A processed activity feed could look like this: Activity 1 Activity 2 Grouped Activity Activity 3 Activity 4 Activity 5 Activities have an updated timestamp and a unique id. The activities are ordered by their updated time and in the case of a grouped activity, the most recent updated time within its child activities is used. Activities can be inserted anywhere in the list (for example, if we start following someone, their past activities would be

Get cursor-position in contenteditable div

北慕城南 提交于 2019-12-04 02:09:51
问题 I found the following code here on SO to get the position of the cursor of a contenteditable div, however it always returns 0. The function that should retrieve the position: new function($) { $.fn.getCursorPosition = function() { var pos = 0; var input = $(this).get(0); // IE Support if (document.selection) { input.focus(); var sel = document.selection.createRange(); var selLen = document.selection.createRange().text.length; sel.moveStart('character', -input.value.length); pos = sel.text

Simulate mouse click in MSPaint

≯℡__Kan透↙ 提交于 2019-12-03 16:46:20
I have a console application which should paint a random picture in MSPaint (mouse down -> let the cursor randomly paint something -> mouse up. This is what I have so far (I added comments to the Main method for better understanding what I want to achieve): [DllImport("user32.dll", CallingConvention = CallingConvention.StdCall)] public static extern void mouse_event(long dwFlags, uint dx, uint dy, long cButtons, long dwExtraInfo); private const int MOUSEEVENTF_LEFTDOWN = 0x201; private const int MOUSEEVENTF_LEFTUP = 0x202; private const uint MK_LBUTTON = 0x0001; public delegate bool

Getting cursor position in a Textarea

旧巷老猫 提交于 2019-12-03 12:53:09
问题 I am trying to implement Autocomplete in a text area (similar to http://www.pengoworks.com/workshop/jquery/autocomplete.htm). What I am trying to do is when a user enters a specific set of characters (say insert:) they will get an AJAX filled div with possible selectable matches. In a regular text box, this is of course simple, but in a text area I need to be able to popup the div in the correct location on the screen based on the cursor. Can anyone provide any direction? Thanks, -M 回答1: You

Change cursor position in the contenteditable div after changing innerHTML

♀尐吖头ヾ 提交于 2019-12-03 09:19:07
问题 I have a simple contenteditable div with some text in it. On onkeyup event i want to replace whole content (innerHTML) of the div based on regex. For example, HTML: some text, more text and $even more text Function in which i plan to get all text with $ ($even in example above) and wrap it in span tag: div.onkeypress = function() { div.innerHTML.replace(/(some_regexp)/, "<span class='class'>$1</span>"); }; The problem is after such replacement cursor jumps to the start of the div. I want it

How to speed up the left and right arrow keys for editing text? [closed]

China☆狼群 提交于 2019-12-03 04:00:38
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Is it just me, or do other people find that the left and right arrow keys on MacOS are unusually slow for editing text? Compared to my Windows machines, positioning the cursor with left/right arrow keys seems to take twice as long on the Mac. The up/down arrows seem to be speedy enough, but left/right arrows

Getting cursor position in a Textarea

China☆狼群 提交于 2019-12-03 03:13:46
I am trying to implement Autocomplete in a text area (similar to http://www.pengoworks.com/workshop/jquery/autocomplete.htm ). What I am trying to do is when a user enters a specific set of characters (say insert:) they will get an AJAX filled div with possible selectable matches. In a regular text box, this is of course simple, but in a text area I need to be able to popup the div in the correct location on the screen based on the cursor. Can anyone provide any direction? Thanks, -M You can get the caret using document.selection.createRange(), and then examining it to reveal all the

How to speed up the left and right arrow keys for editing text? [closed]

情到浓时终转凉″ 提交于 2019-12-02 17:22:28
Is it just me, or do other people find that the left and right arrow keys on MacOS are unusually slow for editing text? Compared to my Windows machines, positioning the cursor with left/right arrow keys seems to take twice as long on the Mac. The up/down arrows seem to be speedy enough, but left/right arrows just crawl. I notice it the most in Terminal, editing recently used commands, and I'm noticing it right now while text in a browser form. Is there a Mac preference I can set to speed up the response to these keys? Vadim To change how fast a key repeats when holding it down , adjust this