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 

close process without losing data

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



Joined: 24 Apr 2009
Posts: 87

PostPosted: Thu Dec 17, 2009 1:02 pm    Post subject: close process without losing data Reply with quote

Currently i am busy with this little script here
I want start a application automatically. And close it after a chosen time.
So far the script works fine, BUT:

I do not want to loose Data, caused by the brutal termination of the process. Is there a way to shut it down smoothly?
The program i am using is a process running as a Trayicon without a window. (notepad.exe is only meant as an example)

Code:

Label_Script_Start:

TimetoWaitInMinutes = 4
TimeToWait_Value := (TimetoWaitInMinutes * 60000)

Run, notepad.exe
Sleep, %TimeToWait_Value%
Process, Close, notepad.exe
Sleep, 10000
Goto, Label_Script_Start


Thanks,
Deep-Silence
Back to top
View user's profile Send private message
UncleScrooge



Joined: 14 Apr 2009
Posts: 75
Location: Italy

PostPosted: Thu Dec 17, 2009 1:11 pm    Post subject: Reply with quote

one way could be:
Code:

Label_Script_Start:

TimetoWaitInMinutes = 4
TimeToWait_Value := (TimetoWaitInMinutes * 60000)

Run, notepad.exe,,, npadID
Sleep, %TimeToWait_Value%
IfWinExist ahk_pid %npadID%
{
   WinActivate, ahk_pid %npadID%
   Send !{F4}
}
Sleep, 10000
Goto, Label_Script_Start

whereas u could add some more lines to check if Notepad windows comes active or not (before sendig keystrokes I mean), etc.
the same idea could apply to a program which accepts keystrokes as a way to close it like:

Code:
Send !{F4}

_________________
Intel Centrino @ 2.8GHz
4 GB RAM
WIN XP SP3
Back to top
View user's profile Send private message AIM Address
Deep-Silence



Joined: 24 Apr 2009
Posts: 87

PostPosted: Thu Dec 17, 2009 1:28 pm    Post subject: Reply with quote

Thanks,

i will try this
Perhaps i can define a hotkey for the program to close itself.
Let me have a look at this...


Thanks,
Deep-Silence
Back to top
View user's profile Send private message
Deep-Silence



Joined: 24 Apr 2009
Posts: 87

PostPosted: Thu Dec 17, 2009 2:27 pm    Post subject: Reply with quote

Unfortunately there is no way to setup a hotkey to close my program.
i am going to observe the "lose Data behaviour"

If it does not work, i need to find another way...

Thanks for now
Deep-Silence


Last edited by Deep-Silence on Thu Dec 17, 2009 2:46 pm; edited 1 time in total
Back to top
View user's profile Send private message
Guest






PostPosted: Thu Dec 17, 2009 2:35 pm    Post subject: Reply with quote

how about WinClose?
(DetectHiddenWindows might helps)
Back to top
Deep-Silence



Joined: 24 Apr 2009
Posts: 87

PostPosted: Thu Dec 17, 2009 2:44 pm    Post subject: Reply with quote

Actually this app has not Windows,
But if you perform i right-click on its trayicon there is a menu coming up,
where you can select options or exit the program.

i thought about, detecting the icon position and perform the right-click
but i think this is not the smartest solution...



Thanks,
Deep-Silence
Back to top
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 5043
Location: the tunnel(?=light)

PostPosted: Thu Dec 17, 2009 4:00 pm    Post subject: Reply with quote

If you have to manipulate the program from the tray icon perhaps utilizing majkinetor's Tray 2.1 will be of assistance. Here's a thread to reference for troubleshooting if you decide to use Tray 2.1 as well.
_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message Send e-mail
Deep-Silence



Joined: 24 Apr 2009
Posts: 87

PostPosted: Thu Dec 17, 2009 5:19 pm    Post subject: Reply with quote

Thanks for this hint,
looks very interesting.
I guess i will get it done with it...

Thanks.
Deep-Silence
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