AutoHotkey Community

It is currently May 27th, 2012, 12:36 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: December 17th, 2009, 2:02 pm 
Offline

Joined: April 24th, 2009, 7:06 pm
Posts: 87
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 17th, 2009, 2:11 pm 
Offline

Joined: April 15th, 2009, 12:05 am
Posts: 75
Location: Italy
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 17th, 2009, 2:28 pm 
Offline

Joined: April 24th, 2009, 7:06 pm
Posts: 87
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 17th, 2009, 3:27 pm 
Offline

Joined: April 24th, 2009, 7:06 pm
Posts: 87
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 December 17th, 2009, 3:46 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 17th, 2009, 3:35 pm 
how about WinClose?
(DetectHiddenWindows might helps)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 17th, 2009, 3:44 pm 
Offline

Joined: April 24th, 2009, 7:06 pm
Posts: 87
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 17th, 2009, 5:00 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
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.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 17th, 2009, 6:19 pm 
Offline

Joined: April 24th, 2009, 7:06 pm
Posts: 87
Thanks for this hint,
looks very interesting.
I guess i will get it done with it...

Thanks.
Deep-Silence


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: iDrug, Leef_me, Ohnitiel, rjgatito, XstatyK, Yahoo [Bot] and 20 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group