Sign in to follow this  
Followers 0
JimmyN

While 1 and Sleep

6 posts in this topic

#1 ·  Posted (edited)

I have a script that works fine, but I'm wondering if I'm not following "best practices" guidelines.  It's a simple script that maps the middle mouse button to a hotkey used by a clipboard manager. Click on the middle button , anywhere, and the clipboard manager pops up.  It loads at start-up and is always running.
#include <Misc.au3>

Local $hDLL = DllOpen("user32.dll")

While 1
    If _IsPressed("04", $hDLL) Then Send("^!C")
WEnd

My question is should I have a Sleep(100), or something, in the loop?  It's seems that many examples, that have an infinite loop, do this.  

Thanks...Jimbo

Edited by JimmyN

Share this post


Link to post
Share on other sites



Look at AdLibRegister in the help file for an alternative.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

sleep(30) should be e enough.

Saludos

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Adlib example:

#include <Misc.au3>

Local $hDLL = DllOpen("user32.dll")
 
AdlibRegister('Pressed')
 
OnAutoItExitRegister('Quit')

 
While 1
    ; run indefinitely
WEnd
 
Func Pressed()
    If _IsPressed("04", $hDLL) Then Send("^!C")
EndFunc
 
Func Quit()
    DllClose($hDLL)
EndFunc
Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

Thanks!

1 person likes this

Share this post


Link to post
Share on other sites

Thanks!

 

Anytime ;)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

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