View Full Version : Enter key = mouse click?
02-16-2004, 11:18 AM
I wanted to start a new thread on this, since I've seen the question a few times. Is there any way to make the "enter" key simulate a left mouse click? I've got my arrow key navigation down, so I don't need to move a mouse cursor around my pages (thanks, Corey!!!), but now I want to be able to have a specific button launch a specific action (open a file) when the enter key (or any other normal keyboard key that could be mapped to a remote) is pressed.
Is there a general On Key command that will make an enter stroke simulate a mouse click?
02-16-2004, 02:02 PM
More info: I actually tried mapping a left-click command to a remote control, but the problem is, the mouse cursor doesn't move around with the arrow keys - just the active position. This means that, even with a hotspot or a button action enabled, a left click will just be a left click somewhere on the screen (wherever the mouse is).
If I might make a suggestion:
Instead of putting all of your code in the object that you need to click, create a Global Function and call the function in the click event.
Then for the enter key use a variable to track where you are in the menu so that when you detect the enter key, you know which function to call.
This would certainly be the hard way to do it, but it does show some of the of possibilites the KeyStrokes DLL gives you.
02-16-2004, 04:35 PM
Hmmm. . . that feels like it has potential. Let's try this: I'm attaching a sample file that Corey created which allows one to navigate with the arrow keys. Can a function be added that allows an "enter" keystroke to trigger something different for each button?
Here ya go, this is by far not the most optimized code at all, but it should give you a good starting point.
02-16-2004, 05:12 PM
Worm, you just made the hero list! Thanks for playing along. And it's good to know that a simple if/then can be used, too. I had that thought, but I just couldn't get my brain around it for some reason.
I love these forums. :)
02-16-2004, 09:47 PM
Haha! I tried something based on the comments you put in that code, Worm. You said an if/then command would work, and I was wondering how the heck I could make it specific for each button. But I had a spark, and wondered just how intuitive this software is. Would "and" fit in anywhere?
if (e_Key == 13) and button == 1 then
File.Open("something.txt", "", SW_SHOWNORMAL);
And lo, it does work! Great work, team. You've started me on a great path. :)
Powered by vBulletin™ Version 4.0.6 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.