AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to pause an external process?

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
r0lZ



Joined: 21 Apr 2007
Posts: 177

PostPosted: Fri Jul 06, 2007 7:11 pm    Post subject: How to pause an external process? Reply with quote

Hi!
I need to pause a process that has not been started by my script. I know its PID, process name or exe path to identify it.
Is it a way to pause and resume that process, in a manner similar to changing its priority?
_________________
r0lZ
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 8255
Location: Maywood, IL

PostPosted: Fri Jul 06, 2007 7:20 pm    Post subject: Reply with quote

I don't think J Random Process can be paused. can you set the priority th the lowest setting?
_________________

(Common Answers)
Back to top
View user's profile Send private message Visit poster's website
r0lZ



Joined: 21 Apr 2007
Posts: 177

PostPosted: Fri Jul 06, 2007 7:44 pm    Post subject: Reply with quote

Well, it's possible, of course, but the goal is to pause it completely, to avoid heavy IO operations.

When two processes are writing large files to disc at the same time, the CPU load of each process is usually not high, and therefore even with both processes running at idle priority, too many disc accesses occur.

I would like to launch several instances of the same program, and pause all of them but one to minimize the IO operations. When the first process has finished its job, the next one should resume automatically. Unfortunately using the idle priority is not sufficient in this case.
_________________
r0lZ
Back to top
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 1019
Location: London, UK

PostPosted: Fri Jul 06, 2007 7:54 pm    Post subject: Reply with quote

you could use PsSuspend launched via ahk's run command.
_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
r0lZ



Joined: 21 Apr 2007
Posts: 177

PostPosted: Fri Jul 06, 2007 9:12 pm    Post subject: Reply with quote

Nice finding!

But, IMO, the existence of this tool proves that there must be some kernel function able to do what I need. I would like to use it instead of an external tool.

Thanks anyway!
_________________
r0lZ
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 8255
Location: Maywood, IL

PostPosted: Fri Jul 06, 2007 10:07 pm    Post subject: Reply with quote

if you can find a related function in MSDN, post here, and a DllCall wizard may be able to figure out how to call it.
_________________

(Common Answers)
Back to top
View user's profile Send private message Visit poster's website
r0lZ



Joined: 21 Apr 2007
Posts: 177

PostPosted: Fri Jul 06, 2007 10:36 pm    Post subject: Reply with quote

Unfortunately, I have just browsed the MSDN site, and found nothing directly exploitable (except, perhaps, SuspendThread, but I don't know how to retrieve the thread information.)

Also, PsSuspend source code is not available any more. Pity! Sad
_________________
r0lZ
Back to top
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 1019
Location: London, UK

PostPosted: Sat Jul 07, 2007 7:33 am    Post subject: Reply with quote

This one Looks like it has full source and description, should be able to establish what to do from that.
_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
r0lZ



Joined: 21 Apr 2007
Posts: 177

PostPosted: Sat Jul 07, 2007 9:22 am    Post subject: Reply with quote

Thanks!

Currently, I have implemented the pause using pssuspend.exe and it works pretty well, although it is better to hide the windows pertaining to the suspended process (as they are not refreshed any more.) Luckily, it's easy to do with AHK, but I have still to improve the method to hide ALL windows sharing the same process.

Also, as you can imagine, pausing a system process can be extremely dangerous. For example, suspend explorer.exe to see what I mean, and prepare to reboot! Wink
_________________
r0lZ
Back to top
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 1019
Location: London, UK

PostPosted: Sat Jul 07, 2007 10:33 am    Post subject: Reply with quote

Yeah I know what you mean, I used to use a pssuspend remotly at work combined with a few other apps.

Locking the PC first then pausing winlogon was a good one lol.

Remote task manager has a front end that can perform this task too. And can do it remotely too.
_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
r0lZ



Joined: 21 Apr 2007
Posts: 177

PostPosted: Sat Jul 07, 2007 10:51 am    Post subject: Reply with quote

I have searched the forum, but couldn't find the answer. How can I retrieve the complete list of all windows opened by a specific process? (I am already able to find the parent window of the process, but cannot find the children.)
_________________
r0lZ
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Sat Jul 07, 2007 11:24 am    Post subject: Reply with quote

r0lZ wrote:
How can I retrieve the complete list of all windows opened by a specific process?


Code:
DetectHiddenWindows, ON ; You should avoid this for your purpose!!
PID := DllCall("GetCurrentProcessId")

Gui, 1:Show, x0 y0   w200 h100, Test Window1
Gui, 2:Show, x205 y0 w200 h100, Test Window2

WinGet, List, List, ahk_pid %PID%

Loop %List%
 {
   WinGetTitle, Title, % "ahk_id " List%A_Index%
   Wins .= Title "`n"
 }

MsgBox, 0, Windows for PID: %PID%,  %Wins%

ExitApp


Smile
Back to top
View user's profile Send private message Send e-mail
r0lZ



Joined: 21 Apr 2007
Posts: 177

PostPosted: Sat Jul 07, 2007 12:27 pm    Post subject: Reply with quote

Ah, OK! I didn't know the ahk_pid %PID% trick.
Huge thanks!
_________________
r0lZ
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group