Jump to content

How can i make a sleep do stuff, while it's sleeping like check for a key press?


Recommended Posts

Func SleepCheckLoop()

$TotalSleepTime = GUICtrlRead($Input2)

Sleep($TotalSleepTime)

Return

EndFunc ;==>SleepCheckLoop

I want to check for this:

If _IsPressed("23", $DllOpen) Then ExitLoop

Exitloop, if it needs one, or Return.

Halp?

PS: Searching failed.

Edited by X42Negative
Link to comment
Share on other sites

umm

Func SleepCheckLoop()
    $TotalSleepTime = GUICtrlRead($Input2)
    local $curTime=0
    While $curTime<$TotalSleepTime
        If _IsPressed("23", $DllOpen) Then ExitLoop
        sleep(1)
        $curTime +=1
    Wend
    Return
EndFunc ;==>SleepCheckLoop

Probably not the BEST way to do this but it will work(it might miss a key press I doubt it) if you explain a little better what your trying to do i might be able to help more.

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Link to comment
Share on other sites

Hmm not that I know of according to the help file sleep has a maximum sleep time but it does not say anything about a min time

Maximum sleep time is 2147483647 milliseconds (24 days)

btw that would be "mistaken" not "mistaking" ;)

Edited by MerkurAlex

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Link to comment
Share on other sites

How about using Timers.au3? (Couldn't find an easy way to capture keystrokes, so please excuse a chunk missing from the inner loop.)

#Include <Timers.au3>

Dim $lastKey = "None"
Dim $waitTime = 1000
Dim $initTime = _Timer_Init()

While $lastKey <> "X"
    While _Timer_Diff($initTime) > $waitTime
        ; Capture keystrokes and assign the last key to $lastkey
    EndIf
    
    MsgBox(0, "Last Key", $lastKey)
Wend
Link to comment
Share on other sites

Ah well, yes because it was sending way to slow, so I just added /10. Now it's pretty much accurate, and works well.

Func SleepCheckLoop()
    $TotalSleepTime = GUICtrlRead($Input2)/10
    local $curTime=0
    While $curTime<$TotalSleepTime
        If _IsPressed("23", $DllOpen) Then Return
        sleep(10)
        $curTime +=1
    Wend
    Return
EndFunc ;==>SleepCheckLoop

Thank you.

Link to comment
Share on other sites

@turbov21

That should work as well but this line

While _Timer_Diff($initTime) > $waitTime

should be

While _Timer_Diff($initTime) < $waitTime

@X42Negative

No problem hope it works properly ;)

Edited by MerkurAlex

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Link to comment
Share on other sites

Hmm not that I know of according to the help file sleep has a maximum sleep time but it does not say anything about a min time

btw that would be "mistaken" not "mistaking" ;)

While there is no real "lowest", 1-9 will be run as 10 and 0 is... Special... Check this thread: link
Link to comment
Share on other sites

While there is no real "lowest", 1-9 will be run as 10 and 0 is... Special... Check this thread: link

Well... that's interesting thanks for the link ;)

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Link to comment
Share on other sites

I have the feeling my remark is ignored... wonder why that is?

Maybe because you're the only one that knows who he is? Maybe if you give us a tip?
Link to comment
Share on other sites

  • Developers

Maybe because you're the only one that knows who he is? Maybe if you give us a tip?

This is nearly correct: also the OP knows who he/she is so I expect a reply from Him/Her! Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

This is nearly correct: also the OP knows who he/she is so I expect a reply from Him/Her!

I just kind of did what all the "newbies" do, come in here and request help. Wasn't meant to take it that way, but it got finished after all. Anyway, how is everything Jos? It's been awhile. I assume you know who I am, although I'm not 100% sure of this. Anyway, thanks for the help everyone.

Anyway, I am leaving now Jos. Your forum has helped me once again.

Edited by X42Negative
Link to comment
Share on other sites

  • Developers

I just kind of did what all the "newbies" do, come in here and request help. Wasn't meant to take it that way, but it got finished after all. Anyway, how is everything Jos? It's been awhile. I assume you know who I am, although I'm not 100% sure of this. Anyway, thanks for the help everyone.

Anyway, I am leaving now Jos. Your forum has helped me once again.

Of course I know who you are and you should know that as you met both my "lets give him a couple of chances" site as well as "you are not screwing with me anymore" site.

Bye

Jos

edit: for those I left totally puzzled: maybe swift rings a bell?

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

edit: for those I left totally puzzled: maybe swift rings a bell?

2000 posts and still can't handle a simple Sleep()?....

Why am I not surprised? ;)

:evil:

Link to comment
Share on other sites

  • Developers

2000 posts and still can't handle a simple Sleep()?....

Why am I not surprised? ;)

:evil:

You need to add all these together to come up with the correct post count:

GoldFishCrackers

IUnderstandAutoIt

KuKluxKlan

NewUser554

Rejectedz

Swift

TehWhale

X42Negative

XCalibur

So propably now also understand why I know exactly when he returns.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Not 100% sure what happened but im guessing he has been banned many times.

I just had to say I lol'd at the name "IUnderstandAutoIt" im sure you can guess why ;)

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

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