How can I make it a key press would move my mouse cursor?
Is that possible? I figured out how to register a key press and recognize if it's an arrow, but I'm not sure if it's possible to use that input to move a mouse
Thanks in advance!
The CGWarpMouseCursorPosition method should do what you want. Apple Docs
CGPoint target = CGPointMake(10, 50);
// where 10 is x and 50 is y
CGWarpMouseCursorPosition(target);
When the user presses one of the arrow keys, have this run in a loop until the key is no longer depressed.
Related
I'm having problem with my work in blender, im using the latest version of the blende 2.78a.
But when i try to move my object and hit the x key then enter a value (2.50) it doesn't work.
Any help please =)
Did you first selected the object with right mousbutton and pressed the G key for moving the object?
If it still not works I have some other suggestions for you:
select the model, go to the panel on the right, press the "Object data" button (with the orange Cube on it) and then enter the numbers at "Location"
make sure you enter the numbers with a . not a , !!! (i also made this mistake)
press N to open an new propertiespanel on the right of the 3d-view and
look at the "Location"s; are the locks behind the coordinates blocked?
if so just click to unlock the positions
I want to use AutoHotKey to disable Alt+F4 when they are pressed within 0.05 seconds of each other. Otherwise, I'd like it to work as normal.
Explanation:
My Lenovo Yoga 2 Pro has alternate functions for the function keys.
For example: "F3" is mapped to volume+, "F4" is mapped to "close active window"
There are two modes:
Old-school mode: F3 just acts as F3, and you must hold Fn+F3 key to activate volume+
New-school mode: Pressing F3 activates volume+, and Fn+F3 will do the normal F3.
In either mode, I run the risk of closing my active window when I go to use volume+ because they are too close, which is very problematic. Note that AutoHotKey cannot detect the Fn key, thus I cannot use that to solve my issue.
The image below shows the AutoHotKey Key History tool. In New-school mode, I typed "asdf" and then pressed "F4" which is "close active window". You can see this actually simulates ALT+F4, and there is a very short duration between ALT and F4...
I'm thinking that I could disable this "close active window" function by having AutoHotKey interrupt an ALT+F4 combo when there is less than 0.05 seconds between the two keys. Can this be done?
Edit:
In response to Blauhirn's code, here is the original, edited for a shorter wait duration, (from 50 to 10). It works most of the time, though 1/10 times the window is still cosed:
~alt::
hotkey, alt, off
hotkey, !F4, doNothing, on
sleep, 10
hotkey, !F4, doNothing, off
while(getKeyState("alt"))
sleep, 1
hotkey, alt, on
return
doNothing:
return
Here is a change I thought would fix my focus issue by sending a 2nd Alt when the "close active window" was detected:
doNothing:
send {LAlt}
return
However, the 2nd Alt is not sent. It IS sent when the delay is above 40ish, however I find that is way too long, and in turn it interferes with my manual use of Alt+F4.
Have you tried using simply
F4::return
? Maybe this will override the Lenovo action for F4
Other than that, here are the two approaches I can think of:
Disabling the ALT+F4 standard win hotkey by default. Adding a custom hotkey for a delayed F4
!F4:: ; by default:
doNothing: ; this is a label (see GoSub)
return ; == do nothing
~alt:: ; alt was pressed
sleep, 50 ; wait 50 milliseconds
if(!getKeyState("alt")) ; if alt is NOT pressed down anymore, exit
return
else ; (else is actually unnecessary here)
hotkey, !F4, close ; Add new AltF4-hotkey
return
close:
winclose, A ; close the Active window
return
~alt up:: ; alt is being released
hotkey, !F4, doNothing ; remove the new AltF4 hotkey and go back to custom standard behaviour: do nothing.
return
it still triggers Alt, which usually leaves me in the menu of the active window (File, Edit, View, etc), or if typing within a textarea (such is this), it will remove typing focus.
well yes. If you decide to keep the lenovo keys, I don't think there is a way to prevent it. As you suggested, sending ALT again should solve the problem
using Input, after ALT has been pressed. Input blocks user input for a configurable time, as long as the V option is used.
(3. disabling your Lenovo Yoga 2 Pro special keys. If you need the F3 function, you can do that in AutoHotkey e.g. using send {volume_up}
I have two nsbuttons in my interface builder.For all of these three nsbuttons I have set Key Equilant to "Return" key.And also I set nextkey view to all of these buttons.
I have 3 different actions for all of these three buttons and connections has made properly.
If I use mouse click appropriate actions are getting executed.
After running the Application,initially my first button has focus,presses return key, 1st button's action is executed.Next I pressed tab key,focussed has changed to 2nd button,pressed return key but 1st button's action is executed.Again I pressed tab key,focussed has changed to 3rd button,pressed return key still 1st button's action is executed.
What I am missing here.Why the appropiate action is not happenning on pressing Return key over nsbutton even focus is highlighted.
It sounds like you're using keyboard navigation to switch between buttons and activate the selected one. In that case, the Return key would normally correspond to pressing the selected button. However, since you've assigned Return as a shortcut for one or more of the buttons, the responder chain searches for and finds a button with a matching key equivalent, so that button's message is sent instead.
Try clearing the key equivalent for all three of your buttons. I think that'll give the behavior you're looking for.
If you're not using keyboard navigation, it's not clear why the tab button has any effect. Nevertheless, if you're trying to do something like make the default button cycle from one button to the next, you'll need to change the keyboard equivalent each time a button is pressed. I wouldn't recommend that generally -- I don't think users would like to have the default button change from one moment to the next. If you must though, here's some code:
- (IBAction)nextButton:(NSButton*)sender
{
int tag = [sender tag];
NSView *superview = [sender superview];
if ([sender.keyEquivalent isEqualToString:#"\r"]) {
NSButton *nextButton = [superview viewWithTag:(tag % 3) + 1];
nextButton.keyEquivalent = #"\r";
sender.keyEquivalent = #"";
}
}
This assumes that you've got three buttons, and each is configured with the nextButton: method as its action. Also, the buttons have tags 1, 2, and 3 respectively. The idea here is that when the default button (i.e. the one with the return key as its equivalent) is selected, it sets the next button's key equivalent to Return and sets its own equivalent to nothing.
You can obviously change the way the code works -- you may want each button to call a different action, for example. In that case, just have each action call a common method that does the same job as the code above.
The lesson here is that if you set the same key equivalent for several buttons, the first one to be found will be "pressed". If you want the key equivalent to change, you need to change the equivalent set for your various buttons.
I'm not sure what you mean about the focus changing when you press the tab key -- I don't see this behavior (I've set up the initial first responder and next key connections). All three buttons are blue, but only the first one pulsates, no matter what keys I press. After experimenting a bit, I found that the button that is at the top of the list (in the window's object list) is the one whose action is performed on clicking return.
I can't find any documentation on this, but I don't think you can set the same key equivalent for multiple buttons in the same window.
I am developing a cad software using GDI+ (c++/Cli and framework 3.5). When user wants to move a line I want to use arrow keys. Presently I am using Number Keys 4,6,8 and 3 for left right, up and down and 7,9, 1 and 3 for diagonal. How to get diagonal using Arrow keys?
Assuming you have Num Lock on, you could still use the 7, 9, 1, and 3 keys as diagonal arrows.
The 7 is the home key
The 9 is the page up key
The 1 is the end key
The 3 is the page down key
You would have to intercept those 4 keystrokes, and perform the diagonal move line function.
Try handling both keyup and keydown events instead of keypress. Accumulate the directions on keydown, move on keyup.
I am trying to select an entire line of text on a web page (in a table) using Sikuli. The easiest way to select the text is to "triple-click" on it. Is there a way to triple-click in Sikuli?
Thanks!
GregH,
I got the following to work for me:
click(img.png)
mouseDown(Button.LEFT)
mouseUp(Button.LEFT)
wait(0.01)
mouseDown(Button.LEFT)
mouseUp(Button.LEFT)
This allowed me triple click on a button, link, or whatever I needed to click on.
This works for me:
def tripleClick(PSMRL):
hover(PSMRL)
for x in xrange(3):
mouseDown(Button.LEFT)
mouseUp()
quick fix solution would be to check out the mouse settings in control panel and you can lower the time between clicks required to register successive clicks needed to perform the 'triple click' action
Have you tried low level mouse functions? Something like this should work:
for x in xrange(3):
region.mouseDown()
region.mouseUp()
Depending on what is being clicked, sometimes, the click type is the same as multiple clicks in succession. Meaning, if what needs to be clicked doesn't have to be double/triple-clicked very fast, then you can just use a sequence of single clicks. 2 clicks = double-click, 3 clicks = triple click. I know that 2 clicks will simulate a double-click on Windows desktop (not sure about things like games, etc.)
I've seldom heard of a triple-click action though.
So, have you tried using 3 clicks to simulate triple-click to see if that works or not?
I f you use .click() will be good enough.
.click() is the left mouse button, .rightClick() is the right mouse button.
For example:
image1 = ("image1.png")
def multiClick(nTime):
imageLoc = find(image1)
for n in xrange(nTime):
imageLoc.click()
# Click 3 times.
multiClick(3)