Sign in to follow this  
Followers 0
X42Negative

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

19 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



Hey ... I think I smell somebody I know....

Let me think who it could be... ;)

I've missed you Jos. Long time no see. I've been a bit rusty with AutoIt, and a solution to this cannot be found...

Hmm...

Oh, and nice new forum software. It's pretty expensive.

Share this post


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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

That is pretty much what I'm trying to do. I might have to optimize it a little. And if I'm not mistaking, the lowest AutoIt can sleep is 10ms. Thanks for the code, I will try it now.

Edited by X42Negative

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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]

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

@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]

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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.


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


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

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