Jump to content

Simple hotkey... hotkeyset, or _IsPressed? neither working


notaqua
 Share

Recommended Posts

Hello everyone, if someone could please help me with this, I would really appreciate it. I am trying to write a very, very simply script, but having trouble figuring out what I'm doing wrong. I imagine I could figure it out... eventually, but searching the forums and trying different example is cumbersome.

All I want to do is make a script that gives me a simple, custom mapped hotkey. Here is what I want the script to do...

1. Run script

2. Run indefinitely and do nothing unless hotkey is pressed

3. Click a location on the screen when hotkey is pressed

4. Continue to run, and respond to the hotkey

Really simple right? I would have thought so.

Here is the state of the code as it is now, please forgive how rough and simple it is, I am a TOTAL noob at AutoIt.

#include <Misc.au3>
HotKeySet ( "{ESC}", Terminate() )
HotKeySet ( "{Space}" , doubleclick() )

While 1
  
   If
  
WEnd
 
 
Func doubleclick()  
      Mouseclick ( "left" , 885, 528 , 2 )
  
EndFunc
Func Terminate()
    Exit 0
EndFunc

So the results I've had so far...

At first, I had the doubleclick() function inside the While loop, and that caused an infinite loop of my mouse being stuck at the coordinate, double clicking, and forcing me to log out to stop the script.

Also, I never pressed the "Space" button, which I thought is the hotkey that I specified to call the doubleclick() fuction. The doubleclick() the runs as soon as I start the script, never waiting or responding to the hotkey.

What am I doing wrong here?

I tried to go and mess around with IsPressed, but the code doesn't seem to exist in my library. Typing _ispressed, does nothing and shows up as black, plain text.

Anyone help?

Link to comment
Share on other sites

notaqua,

Also your "hotkeyset" syntax is incorrect. This should get you started.

#include <Misc.au3>

HotKeySet ( "{ESC}", "Terminate" )
HotKeySet ( "{Space}" , "doubleclick" )

While 1

   sleep(86400000)      ; sleep all day

WEnd


Func doubleclick()
      Mouseclick ( "left" , 885, 528 , 2 )
EndFunc

Func Terminate()
    Exit 0
EndFunc

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

Thank you very much, both.

After christmas I'll give this another shot.

I know it's current state wouldn't run, sorry. I was just in the middle of editing and deleting, and the While loop is currently just empty, I know. The If was going to be for (what I was thinking at least), If... _IsPressed, Space, = doubleclick function. But I didn't know where to go from there, and IsPressed was not working at all. Thanks for the suggestions, I'll try your code tonight kylomas.

Link to comment
Share on other sites

Actually, I tested it right now =)

Works perfectly kylomas! Thank you!

However... now my next question, is there a way to make the hotkey a combination of keys, and what is the syntax for that? i.e. Shift-Space = doubleclick()

I tried just adding:

HotKeySet ( "{LSHIFT}" , "{Space}" , "doubleclick" )

but that certainly didn't work =)

May I pick your brains some more?

Link to comment
Share on other sites

@Firefox

Sorry, but that didn't help. For one, the help file is not really helpful for things like this. You didn't give me much reference to go on. See what part of helpfile? I typed +{SPACE} into the search, and recieved an enormous list of articles, just like always (the reason I'm here).

I tried

HotKeySet ( "{LSHIFT}{SPACE}" , "doubleclick" )

and

HotKeySet ( "{LSHIFT}+{SPACE}" , "doubleclick" )

Neither works, so if you have the actual code to try, I would appreciate it. You said that is the syntax, but it won't work? So apparently it's not the syntax? Why won't "this one" work?

Link to comment
Share on other sites

notaqua,

HotKeySet ( "+{Space}" , "doubleclick" )

sets Shift-Space as a hot key. In the help of HotKeySet there is a link to Send for format information. See help of Send for explanation of "+".

Additional look at the examples of HotKeySet. You can see the line

HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d

which gives you a hint (+=shift, !=Alt)

A-Jay

Rule #1: Always do a backup         Rule #2: Always do a backup (backup of rule #1)

Link to comment
Share on other sites

You didn't give me much reference to go on.

It's a joke? You need more assistance?

Everything I gave you is explained in the helpfile for the function Send which is related to HotKeySet because they are using the same key combinations.

key

The key combination to use as the hotkey. Same format as Send().

Whatever. Edited by FireFox
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...