Sign in to follow this  
Followers 0
Skizzy

Loop until Keydown

13 posts in this topic

#1 ·  Posted (edited)

Okay, I'm an AutoIt newbie, but I used to do some things with VB about 6 or 7 years ago. Nowadays, I usually just create simple macros with ACTool, but it's not cooperating the way I want it to, so I have switched over to AutoIt.

I am trying to create a macro that continually presses {F1} then MouseClick("left") right after it, until the numberpad + is pressed, which terminates or pauses the program.

So far I have:

Send ("{F1}")
MouseClick("left")

Pretty simple, huh? That works fine, but I am not sure how to loop it until numberpad + is pressed. I have read documentation on AutoIt for close to two hours now, but have nothing to help me. Now, I knew how to do it in ACTool, but since I've never used AutoIt before, I have no clue.

Thanks in advance!

Edited by Skizzy

Share this post


Link to post
Share on other sites

Hotkeyset ("q" "exit1")

While 1 = 1 
Send ("{F1}")
MouseClick("left")
wend

Func Exit1()
    Exit(0)
Endfunc

Does it work?

I changed the Numpad + into "q" because I couldn't find that key's code thing. (as in, "{numpad+} )


Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Maybe something like this.

#include <Misc.au3>

$dll = DllOpen("user32.dll")

Do
    Send ("{F1}")
    MouseClick("left")
Until _IsPressed('6B', $dll)

DllClose($dll)oÝ÷ ØêÚºÚ"µÍÚ[ÛYH  ÓZØË]LÉÝÂÌÍÙHÜ[   ][ÝÝÙÌ  ][ÝÊBÚ[HÝÒÔÜÙY
    ÌÎNÍÌÎNË  ÌÍÙ
BÙ[
    ][ÝÞÑ_I][ÝÊBS[ÝÙPÛXÚÊ ][ÝÛY ][ÝÊHÑ[ÛÜÙJ   ÌÍÙ

Cheers

Edit: You beet me to it alex OF DEATH ...lol

And the send for Numbpad + is NUMPADADD :shocked:

Edited by smashly

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Nevermind.

Thought something else.

Edited by alex OF DEATH

Share this post


Link to post
Share on other sites

HotkeySet("{NUMPADADD}","StartPause")
$pause=False
While 1
Sleep(1000)
WEnd
Func Startpause()
$pause=Not $pause
While $Pause=True
Send("{F1}")
Mouseclick("left")
WEnd
EndFunc

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Thanks for the replies! I made something almost exactly like alex OF DEATH's, even before I read his reply! :(

I ended up with

Hotkeyset ("{NUMPADADD}" "Terminate")

While 1 = 1
    Send ("{F1}")
    MouseClick ("left")
WEnd

Func Terminate()
    Exit 0
EndFunc

First time around, I had to reboot my computer because I forgot to set a Exit command.. that wasn't fun. :shocked:

Thanks again for the replies guys.

Edited by Skizzy

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I'm only following the example from the Help file...

DllOpen....

But since you don't need to , then I won't ..lol

Learn something new every day :shocked:

Cheers

Edited by smashly

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I'm only following the example from the Help file...

DllOpen....

No need, this should work fine.

HotkeySet("{NUMPADADD}","StartPause")
HotkeySet("{ESC}","Quit")
$pause=False
While 1
Sleep(1000)
WEnd
Func Startpause()
$pause=Not $pause
While $Pause=True
Send("{F1}")
Mouseclick("left")
WEnd
EndFunc
Func Quit()
Exit
EndFunc

You don't have to exit your program, you can just set it so you can activiate it anytime.

Edited by Generator

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

But why would you use all that when you can do the same thing with 6 lines?

#include <Misc.au3>

While Not _IsPressed('6B')
    Sleep(10)
    Send ("{F1}")
    MouseClick("left")   
WEnd

Edit: I see why, cpu load.. doh , added sleep and it it's efficient.

Edited by smashly

Share this post


Link to post
Share on other sites

No need, this should work fine.

HotkeySet("{NUMPADADD}","StartPause")
HotkeySet("{ESC}","Quit")
$pause=False
While 1
Sleep(1000)
WEnd
Func Startpause()
$pause=Not $pause
While $Pause=True
Send("{F1}")
Mouseclick("left")
WEnd
EndFunc
Func Quit()
Exit
EndFunc

You don't have to exit your program, you can just set it so you can activiate it anytime.

Cuz this way works the best

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