Jump to content

While 1 and Sleep


JimmyN
 Share

Go to solution Solved by MikahS,

Recommended Posts

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
Link to comment
Share on other sites

Link to comment
Share on other sites

  • Solution

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

 

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

 

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...