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 Program

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



Joined: 03 Apr 2009
Posts: 2

PostPosted: Fri Apr 03, 2009 1:17 pm    Post subject: Close Program Reply with quote

I wrote a script called Moffsoft.ahk for keyboard shortcuts which works. I wrote another called close.ahk to close Moffsoft.ahk but I cannot work out why this fails:
WinClose Moffsoft.ahk - AutoHotkey
which is the syntax suggested in FAQ. Apologies for elementary nature of this question.
Back to top
View user's profile Send private message
aCkRiTe



Joined: 21 Jul 2006
Posts: 555

PostPosted: Fri Apr 03, 2009 1:26 pm    Post subject: Reply with quote

Im assuming your Moffsoft script is just keyboard shortcuts, which has no gui so there is really no window to close. Why dont you just assign a hotkey like the following in your Moffsoft script to exit it when you want. I dont see the need for a second script to close the first one, unless Im missing something here.

Code:

Esc::
Exitapp

_________________

HTH...
Back to top
View user's profile Send private message
DevX



Joined: 07 Jan 2009
Posts: 43

PostPosted: Fri Apr 03, 2009 2:51 pm    Post subject: An easy way Reply with quote

If you really want to close one script from another, an easy way is to compile the script you want to terminate. That way, it will run as Moffsoft.exe and not Autohotkey.exe. Then you can

Code:
Process, Close, Moffsoft.exe


If you dont want to compile, then you need a bit more code.

Code:

IfWinExist, ahk_pid %Capturer%
  {
    WinClose, ahk_pid %Capturer%
  }
  else
  {
    Run,"%A_ProgramFiles%\AutoHotkey\AutoHotkey.exe" "C:\Documents and Settings\konakm\Desktop\Ahk\capturer.ahk",,,Capturer
  }


if winclose does not work use

Code:
Process, Close, %Capturer%


This will cause the taskbar system tray icon to not dissapear until mouse rollover though ( another script can fix this, lol )

The code above will launch your script and save its pid for later termination, which also means that your closing script must launch your other script(s).

There might be other ways to do it, but I remember spending a lot of time getting this menu of mine to work, and this is what works.
Back to top
View user's profile Send private message
Julio



Joined: 03 Apr 2009
Posts: 2

PostPosted: Fri May 29, 2009 1:01 pm    Post subject: Reply with quote

Hi, thanks for prompt replies. Using Esc for exit in Moffsoft - it's a calculator - works perfectly and is exactly what I wanted. I'm afraid 'compiling' scripts and those kind of things are way beyond my competence but I intend to study this a bit more as this stuff is incredibly helpful.
Back to top
View user's profile Send private message
Drugwash



Joined: 07 Sep 2008
Posts: 921
Location: Ploiesti, RO

PostPosted: Fri May 29, 2009 8:10 pm    Post subject: Reply with quote

Check your AHK\Compiler folder, there should be Ahk2Exe.exe in there. Launch it and follow the white rabbit... erm, I mean.. you know... Wink
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
drainx1



Joined: 10 Apr 2009
Posts: 139
Location: Wichita,Kansas

PostPosted: Fri May 29, 2009 8:16 pm    Post subject: Reply with quote

also try
Code:
winkill
it forces the window to close
_________________
Drainx1
Your favorite.

What says that we aren't a visualization of someones dream?
And that person could change the laws of physics without thinking a thing about it.
They could recreate the world, and not know what happened.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Anyr



Joined: 28 Apr 2009
Posts: 56

PostPosted: Fri May 29, 2009 9:00 pm    Post subject: Reply with quote

The problem has already been answered guys. The ExitApp worked
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