Remap hotkey without losing native hotkey functionality - native

I want the keyboard shortcut ctrl+tab to perform two functions:
ctrl+tab (its normal function, e.g., to switch tabs in a web browser)
ctrl+F6 (which can be used to switch between Microsoft Word documents, for example)
It doesn't need to be context-sensitive, i.e., it's okay to send both commands regardless of what program(s) I am using. The closest I have come is the following:
~^Tab::^F6
which performs both of the desired functions, but a "Tab" keystroke is also sent along with the hotkey. (This would wreak havoc on my Word documents!) I need to preserve the native ctrl+tab functionality without sending a Tab keystroke. Could someone please help?

Then just send both commands:
$^Tab::
Send, ^{F6}
sleep,50
Send, ^{Tab}
return
Just note that some programs might not like that.

Related

How to make my own keyboard layout?

Is it possible programatically change keyboard input anywhere , when the program is in tray?
Example.
When user type text in, say, Google Chrome then my program catch the key the user types, and change it to another symbol (in another language)?
A -> ❤
B -> 웃
C -> ✄
etc.
Is it possible? and if answer is YES, then how?
This sounds like a job for a custom keyboard layout.
After installing your keyboard layout, the user need only enable it in the “Language & Text” preference pane and then select it in the Input menu extra.
It's also possible to enable and select an input source (keyboard layouts being a kind of input source) programmatically.
You can do this a number of ways.
You could capture NSEvent key events and change them.
You could override keyDown: in your own view subclass.
And more.
Read up on the Cocoa Text System first
https://developer.apple.com/library/mac/documentation/TextFonts/Conceptual/CocoaTextArchitecture/Introduction/Introduction.html
You can use Quartz event taps to receive all key events first and modify them before allowing them to be processed (or substitute different events entirely). Note that the user will have to enable access by assistive devices in Universal Access preferences in order for event taps to see keyboard events.
You could create, install, and have the user select a custom keyboard layout. You can use the third-party Ukelele program to create and modify keyboard layouts. This doesn't involve code, necessarily. It's just a big state machine for translating key codes to characters.
You can probably accomplish something like this by implementing an input method, too. See the Input Method Kit.

how to click on WebArea from QTP ?

In My test I want to click on object of Type WebArea which opens a webelement popup includes some fields that i need to test.
the problem that the popup not open after I click on WebArea object through the code.
the code I use as below.
Browser("WW").page("assessment").WebArea("areaassessment").Click
nothing hapens after the above line excuted.
Look into the HTML of the WebArea and see what action is triggering the popup. Normally it has something like onclick='showPopup();', but in other cases it is onmousedown or onmouseup.
If this is the case, you have to setup QTP accordingly. There are multiple roads to walk here, one is to see how you advanced web settings are configured. Go to Tools>Options>Web>Advanced and look in the Run Settings.
Setting the Replay Type to Event will replay your scripts by events (by default mousedown, mouseup and then mouseclick) or by mouse (You'll see your mouse pointer moving in this mode, QTP will replay by sending WM_* messages through the Windows api for movement to the correct screenlocation and triggering the click).
Allthough it replays a bit faster, if Run only click is checked, it is better to uncheck this to trigger all events / messages.
Events can also be fired by the FireEvent method:
Browser("WW").page("assessment").WebArea("areaassessment").FireEvent("onclick")
or through the object native methods:
call Browser("WW").page("assessment").WebArea("areaassessment").Object.click()
call Browser("WW").page("assessment").WebArea("areaassessment").Object.FireEvent("onclick")
As #AutomateChaos said there is probably an event that QTP isn't simulating, one way to work around this is to do as #AutomateChaos suggests and simulate the needed event. A simpler way is to change to device replay (as I described here and here).

Copy text to an external program, click somewhere on the screen, then save a screenshot

I picked vb.net for this question since it's the only prgramming language I am fairly familair with, but if C++ or something else is more suited for this, I am willing to learn something new.
What I am trying to do is:
Retrieve text from database (this already works in vb.net) and copy it to clipboard
Switch primary screen to the external application I want to work with (example: word or open office)
Emulate key-press Enter
Paste text and hit Enter again
Emulate key-press Ctrl and then emulate a click on a pre-defined spot on the screen (like 500pixels from left, 740pixels from top).
Save screenshot, using a second value from the database as the filename (the naming part should be easy)
Emulate another click on another pre-defined spot
Repeat for next text in database.
I wouldn't know where to start, though. I guess the most important part of what I'm trying to achieve is; switching focus to an external application and emulate keypresses and mouse clicks on it.
use http://www.autohotkey.com/
write a console app to get the value from the database
1 - get autohotkey to run the console app and put the return into the clipboard
then continue as described in your list.

Cut and paste out of/ into text fields in a separate window doesn't work

I have a Macintosh Mozilla plugin which puts up a separate window for login information.
It seems to work fine, it gets keyboard events like typing and hitting
return to hit the default button. HOWEVER, it doesn't seem to get cut
and paste events. When I hit Cmd-v, the edit menu flashes, but nothing
happnes.
Is this a problem with my responder chain? Do I have to specially tell
Mozilla that I want these events? or am I likely to have some other
problem that I haven't even thought of?
It turns out the problem is that I'm using cocoa windows inside Mozilla, which isn't Cocoa... fail.

Binding key combinations to your application

How can I bind a key combination to my vb.net application? I know it has SOMETHING to do with the registry, but I have no earthly idea what or how to go about doing this. I want the user to be able to hit those keys when the app is open and have it execute my function, but not while the app is closed.
Thanks for the help!
If you are using a dialog, then you can put '&' into the text for some controls (buttons, checkboxes, radio buttons, etc) and this will cause Alt plus the next character in the text to be used as an accelerator/shortcut. i.e. "&Open" would activate the Open button if you press Alt+O. "Op&en" would activate if for Alt+e.
Beyond that, as Jason Irwin said, you need to add an event handler to your Form for KeyDown or KeyPress events, and then check if the keypress is the key combination you are interested in. This will only work if the user activates your form (clicks in it to give it the input focus. If they put it behind another window, it will not react to the key presses)
If you don't want to show a form, or want to react to keypresses when you're not the input-focus application, then it gets a bit more complicated (you either need to use a hidden form or a keyboard hook)
edit
OK, it looks like you want a keyboard hook. This looks like a good article.
It depends on what you are trying to do:
If you have a gui application and you want to handle key events then you can do that in a keydown eventhandler
If you want to do more low-level stuff and have an application that will intercept all key strokes (regardless of whether or not the application has focus/is visible) then you need to use pinvoke to hit the win32 apis. I suggest you read the following:
link text
Please let us know what you are trying to do so we can provide better feedback.
Using Google, I found this Keyhook example.
I've worked with keyhooks before, in Delphi WIN32, so I am a bit familiar with them. (Just not in C#.) If you add one to a DLL, all Hell might break loose since most virus scanners will recognise this as malware behaviour. (Especially if you use them in the wrong way, causing them to be injected in each and every process that's running on your system.)
A keyhook will allow key combinations to be captured from other processes, though.
For a solution without programming requirements: Drop a shortcut for the application on your desktop. Edit it, assign a shortcut, close it. Press shortcut to test...