Jump to content

Close app when icon is clicked


Recommended Posts

Hello all,

I would like to know if and how I can close my AutoIt app when it's icon is clicked (instead of opening another one).

Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
Link to comment
Share on other sites

No I want it to work like this:

You click the icon --> Application opens

You click the icon again(While the app is still open) --> Application closes

Edited by Vadersapien
Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
Link to comment
Share on other sites

If you try Mison's suggestion it may not work

Yeah I tried that myself...it was the first thing I thought of...and it didn't work...

I'll have a go at ProcessExists and ProcessClose...but would this work with multiple instances of the application.

Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
Link to comment
Share on other sites

If you try Mison's suggestion it may not work because you might now have a window. However, you could use the same idea he suggested with using ProcessExists and ProcessClose instead of the Win* commands he had.

I thought about that too, but I don't have enough experience in working with ProcessExists and ProcessClose.

I use the script I had posted to check if my application(with GUI) is already running, and will wxit if that is true.

Hi ;)

Link to comment
Share on other sites

Yeah I tried that myself...it was the first thing I thought of...and it didn't work...

I'll have a go at ProcessExists and ProcessClose...but would this work with multiple instances of the application.

I don't think it would work with multiple instances. Processes started from the same .exe file have the same process name from what I remember. Each process has it's own individual PID number; but I'm not sure how that would help.
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

So like this? (Must be a compiled script, won't work in SciTE for obvious reasons)

_CloseProcess (@ScriptName)

While 1
    Sleep (100)
WEnd

Func _CloseProcess($varProcess)
    $varClosedProcess = 0
    $PList = ProcessList()
    For $x = 1 to $PList[0][0]
        If StringInStr ($PList[$x][0], $varProcess) Then
            If $PList[$x][1] <> @AutoItPID Then
                $varClosedProcess = 1
                ProcessClose ($PList[$x][1])
                Sleep (100)
            EndIf
        EndIf
    Next
    If $varClosedProcess = 1 Then Exit
EndFunc
Edited by exodius
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...