Jump to content

close atuoit application


zxcvbnm
 Share

Recommended Posts

Then lets try a different approach.

Make the timer app check for a registry key value.

If value is 1 - close timer. Something like this pseudo code:

$test = RegWrite(Value = 2)

While $test = 2

Sleep(1000)

$test = Regread(value)

"put here your current timer code".

Wend

The second file instead of Processclose do a RegWrite(Value = 1).

@edit - added a sleep

Edited by Juvigy
Link to comment
Share on other sites

compile error:

C:\Documents and Settings\murdoccaa\Desktop\count10.au3(47,23) : ERROR: syntax error

$test = RegWrite(Value=

~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\murdoccaa\Desktop\count10.au3(51,26) : ERROR: syntax error

$test = RegRead(Value)

~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\murdoccaa\Desktop\count10.au3(51,26) : ERROR: RegRead() [built-in] called with wrong number of args.

$test = RegRead(Value)

~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\murdoccaa\Desktop\count10.au3 - 3 error(s), 0 warning(s)

Link to comment
Share on other sites

You could have the timer.exe program do a ProcessExists on the calling program, so when the calling program closes, if it doesn't see that process any longer it closes itself.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Hey zxcvbnm,

You'll have to define the registry key yourself. For a user can write any registry key unter "HKCU" (HKey_CURRENT_USER).

E.g. just create a new Key and Value under HKCU\Software\zxcvbnm

Regards,

Hannes

:)

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

  • 3 months later...

I am trying to do something similar. ProcessClose() works but it is a brutal close it doesn't close nicely.

I have an application written in autoIT3 that is running from notification tray and I want to be able to close this application from a second autoIT3 application.

I have to process name and can use ProcessClose but I want to know if there is a cleaner way such as sending a command directly to the first application and once received would run a predefined function which would do some cleanup and then nicely exit the application. I don't really want to continually check the registery or a ini file entry I just want to send a command to the running application that it will listen for and then run a function. How can I do that?

Link to comment
Share on other sites

Until I figure out communicating with an already running AutoIT application I did the following:

If ProcessExists("closeMyApp.exe") Then
    doExit()
EndIf

I put that in my application I want to close and then I created a new application called closeMyApp.exe which all I have in it is sleep(500) to keep it open long enough for my main application to see it. You should place the above code in a While Loop or else it will only check ONCE at start up of main application which if it did find that exe running would just start then stop the main app which is not good.

Link to comment
Share on other sites

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