AutoHotkey Community

It is currently May 27th, 2012, 10:21 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: July 7th, 2007, 7:52 pm 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
Here's a "not so nice" method (since it will not wait for you to save your data or confirm closing each script) that you can try that might also close compiled scripts (**not extensively tested and may contain errors - USE AT YOUR OWN RISK)

Code:
DetectHiddenWindows, On
ahk := DllCall("FindWindowEx", "Int", 0, "UInt", ahk, "Str", "AutoHotkey", "Str", A_ScriptFullPath . " - " . "AutoHotkey v" . A_AhkVersion)
ahkme = %ahk%
count := 0
notclosed := 0
Loop
{
  ahk := DllCall("FindWindowEx", "Int", 0, "UInt", ahk, "Str", "AutoHotkey", "Int", 0)
  If (ahk) {
    IfInString, ahkf, `,%ahk%`,
    {
      MsgBox, Endless loop detected while trying to close %ahk%
      break
    }
    If (ahk = ahkme) {
      If (lastahk = ahkme)
        break
      Else
        continue
    }
    If (ahk) AND !(ahk = ahkme){
      DllCall("EndTask", UInt, ahk, uint, 0, uint, 1)
      Sleep, 250
    }
    If (DllCall("IsWindow", "UInt", ahk)) {
      WinClose, ahk_id %ahk%
      Sleep, 250
    }
    If (DllCall("IsWindow", "UInt", ahk)) {
      WinKill, ahk_id %ahk%
      Sleep, 250
    }
    If (DllCall("IsWindow", "UInt", ahk)) {
      PostMessage, 0x112, 0xF060,,, ahk_id %ahk% ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
      Sleep, 250
    }
    If !(DllCall("IsWindow", "UInt", ahk)) {
      count++
    } Else {
      notclosed++
    }
    ahkf .= "," . ahk . ","
    lastahk = %ahk%
  }
  else If !(DllCall("FindWindowEx", "Int", 0, "UInt", ahkme, "Str", "AutoHotkey", "Int", 0))
    break
}
MsgBox, %count% AutoHotkey processes were closed.`n%notclosed% AutoHotkey processes were detected but could not be closed using this method
Edit: added DectectHiddenWindows


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 7th, 2007, 11:07 pm 
Offline

Joined: October 9th, 2006, 8:19 pm
Posts: 236
Location: Finland
I use Process Explorerto see the command lines and starting times of applications :)

_________________
Pekka Vartto


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, robotkoer, Yahoo [Bot] and 64 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