Jump to content

Simple but nessary


gamerman2360
 Share

Recommended Posts

Yesterday my computer froze while playing World of Warcraft(actually I left it on all night and when I woke up it was stuck) and I was able to get TaskMgr going but I couldn't see it. Everything I tried was failing so I decided to make this after I hard booted. Anyone could make this just wanted to save time. I'm going to make it a wrapper to the game I play so I never have that problem again! ;)

HotKeySet("^!+{ESC}", "Kill");CTRL(^) + ALT(!) + SHIFT(+) + ESC

While 1
    Sleep(562949953421312);Idle 2^49
WEnd

Func Kill()
    WinKill("")
EndFunc

I hope it works.

PS: Is there a better way to idle? I made the number big so it wouldn't have to activate sleep every 100ms.

Edit: PPS: Speeking of hard booting, I've been having to do that plenty lately because my computer isn't shutting down... When it tries I leaves my mouse on the screen(I can move it and everything) and stops doing everything.

Edited by gamerman2360
Link to comment
Share on other sites

Your time period is almost 18 million years. If your computer is still running after that long, give me a call.

Ha! (Just having fun).

Sounds like your computer is sick. Take action before it croaks.

J

If I am too verbose, just say so. You don't need to run on and on.

Link to comment
Share on other sites

1

While 1

Sleep(562949953421312);Idle 2^49

WEnd

will not work because it sleeps so much it will not react to the hot key ( or thing else for a long time )

While 1

Sleep(500);Idle

WEnd

is more than sufficient

2

If you need to clean-up your computer then try the free *XPClean Menu* Below( Win Xp Only )

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

PS: Is there a better way to idle? I made the number big so it wouldn't have to activate sleep every 100ms.

Good observation -- not many people realise that larger Sleep() values mean less unnecessary CPU usage, especially when the only purpose of the script at that point is to wait for hotkeys.

So you're on the right track, however because the Sleep() function doesn't accept a value larger than 0x7FFFFFFF (or 2,147,483,647 for the decimally adept) your Sleep() line is in fact not sleeping. Try replacing it with this:

Sleep(0x7FFFFFFF)
Edited by LxP
Link to comment
Share on other sites

So you're on the right track, however because the Sleep() function doesn't accept a value larger than 0x7FFFFFFF (or 2,147,483,647 for the decimally adept)

Ahem.

Hmm, that's strange, you're right. I suspect that AutoIt stores the value internally as a signed int, even though it should be unsigned, hence the maximum sleep supported is only the maximum int value. I would almost call this a bug.

Edited by Valik
Link to comment
Share on other sites

Ahem.

Hmm, that's strange, you're right. I suspect that AutoIt stores the value internally as a signed int, even though it should be unsigned, hence the maximum sleep supported is only the maximum int value. I would almost call this a bug.

Yep, I would also call it a bug. It should definitely be possible to pause a script for more than ~ 24,86 days!! You never know when you're going to need this ....

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Yep, I would also call it a bug. It should definitely be possible to pause a script for more than ~ 24,86 days!! You never know when you're going to need this ....

Cheers

Kurt

AutoIt's Sleep() looks identical to the Windows API function so it's not unreasonable to take a first guess that AutoIt just uses the underlying API call which means it should at least support the maximum value the API function should. While this is not true, it's irrelevant since AutoIt uses a custom method for handling sleep times and can support times much larger. AutoIt claims to support 64-bit (signed) integers and Sleep() would be a perfect example of where one could be used. However, AutoIt's Sleep() doesn't even support an 32-bit unsigned integer because internally it uses a 32-bit signed integer and more or less destroys the value passed to it. This makes the Sleep function incongruent with both the Windows API function it mimics as well as with the maximum numerical value AutoIt supports. Did I also mention that its undocumented as to what or why the maximum supported sleep time is what it is?

Even though you may not encounter or in fact ever need this functionality, the current functionality is either wrong or at least needs documented.

Also, I'll point out that LxP consistently uses 0x7FFFFFFF as the value to pass to Sleep() when nothing needs done in the idle loop. I'll cite this as an example that people can and will use obscenely large numbers in Sleep() and so it should at least support up to 0xFFFFFFFF like the API influence (if not supporting 64-bit integers). At any rate, the maximum value should be documented since it is obviously different than what AutoIt states maximum supported numerical values are.

Link to comment
Share on other sites

Your time period is almost 18 million years. If your computer is still running after that long, give me a call.

Ha! (Just having fun).

Sounds like your computer is sick. Take action before it croaks.

J

Actually I think it was something in WOW, I was using out of date addons so that could have added to the problem...

Good observation -- not many people realise that larger Sleep() values mean less unnecessary CPU usage, especially when the only purpose of the script at that point is to wait for hotkeys.

So you're on the right track, however because the Sleep() function doesn't accept a value larger than 0x7FFFFFFF (or 2,147,483,647 for the decimally adept) your Sleep() line is in fact not sleeping. Try replacing it with this:

Sleep(0x7FFFFFFF)
;) I've even heard something like it's faster if you use decimal, I think. If it is I think it was at http://www.autoitscript.com/forum/index.php?showtopic=14936. Anyway, I want to ask is it better to use Sleep() or something like GUIGetMsg() or TrayGetMsg() to idle time? If TrayGetMsg() then I could add a bunch of Tray options, relevent or irrelevent to the script.
Link to comment
Share on other sites

integers). At any rate, the maximum value should be documented since it is obviously different than what AutoIt states maximum supported numerical values are.

You're right, it should be documented.

However, from a users point of view it makes no difference. In my eyes it's insane to pause a script that long. Even if one would need such a long break he could always call sleep() in a loop.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

To clarify, the max sleep value is in the help (quote):

Remarks

Maximum sleep time is 2147483647 milliseconds (24 days).

IMHO if the user needs a longer period, they should be prepared to research the issue and then toss Sleep(x) into a loop. That unlikely scenario is better than anyone wasting time redoing the Sleep fn.

J

If I am too verbose, just say so. You don't need to run on and on.

Link to comment
Share on other sites

  • 2 weeks later...

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