Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[Process] Suspend/Resume commands


  • Please log in to reply
7 replies to this topic
-deXter-
  • Members
  • 45 posts
  • Last active: Dec 23 2013 11:26 PM
  • Joined: 28 Nov 2004
Suspend is a handy feature I use (using process.exe) when I really need to save up on CPU cycles- instead of closing a whole bunch of apps and reloading them later, I simply suspend the whole lot and resume them. Better than setting the priority to idle, and almost as good as closing the app.

Would be nice if AHK had this feature built-in.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
Since you can do it with a program, why build it in AutoHotkey, with little change this is used by somebody else than you?
When I type in my text editor, the AutoHotkey Help window is unlikely to eat CPU cycles. Same for Word, beside its automatic save feature which won't kick if document is saved. Perhaps a browser will continue to run a Flash animation, I don't know if it does it when minimized.
So overall the benefit seems small, unless I am missing something. Saving memory by forcing the application to go in the swap file would be more useful.
Just my 2€c.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

-deXter-
  • Members
  • 45 posts
  • Last active: Dec 23 2013 11:26 PM
  • Joined: 28 Nov 2004
You do have a point there, but personally, I'm using an old P3-450 Mhz comp with around 40-50 processes running at any given time, so I do everything I can to save CPU cycles :)

Besides that, suspend is also useful if you'd like to actually "pause" a program during execution, for eg, say you'd like to pause a game that doesn't support pausing.

In your point about the flash animation, your browser does continue to run the animation, although it will be saving a few cycles as it doesn't have to draw the frames on the screen, but yeah, it continues to run it when minimized. Now say this flash animation was a game, (and since most flash games don't have a pause option), using the PROCESS_SUSPEND_RESUME (0x0800) call you'd actually be pausing it!

My point is that there is a lot of scope for the suspend feature; introducing it in AutoHotkey will make for a lot of interesting scenarios/solutions. Besides, its just a few more lines of code and pretty easy to implement.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
I understand you, I have a P2 300 at home...
Providing more complete use case as you did can help persuading Chris that it is useful...
You seems to know a bit on the subject, perhaps you can research it a little more and provide relevant info to Chris to save him some work.
It can be a useful addition to the Process command.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
This exact feature has already been requested before. Someone pointed out the following article with some source code (not sure if its method is usable via DllCall, or whether it's the best method compared to whatever process.exe uses): <!-- m -->http://www.codeproje...eads/pausep.asp<!-- m -->

JGR
  • Members
  • 59 posts
  • Last active: Feb 07 2012 08:49 PM
  • Joined: 15 Jun 2006
Try:
DllCall("ntdll\ZwSuspendProcess", "UInt", phndl)
DllCall("ntdll\ZwResumeProcess", "UInt", phndl)

This works on all NT-based machines, it uses the NTAPI.
The quoted method in the previous post is a very long-winded way of doing effectively the same thing.

JGR

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Thanks.

-deXter-
  • Members
  • 45 posts
  • Last active: Dec 23 2013 11:26 PM
  • Joined: 28 Nov 2004
Thanks a lot JGR :)