Sign in to follow this  
Followers 0
notaqua

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

10 posts in this topic

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?

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

@notaqua

The syntax is : "{LSHIFT}{SPACE}" but this one won't work, use "+{SPACE}" instead (see helpfile).

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
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?

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

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

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Thank you ajag for your helpful and clear response. I'll test this out tonight when I get home, I think I have everything I need now.

Share this post


Link to post
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
Sign in to follow this  
Followers 0