Question: I'm trying to make an apple script to allow me to manage a cpp project automatically. And I used Jenkins too.

Basically, the cpp project is a kind of infinite loop, which will execute in a terminal. And I set Jenkins rebuild and execute it per 20 sec. In other words, my pc should do the tasks below:  

1) rebuild the project;  

2) execute the project;  

3) wait for 20 sec;  

4) close the terminal.  

However, when I arrive at 4), a dialog will pop up: Do you want to close this window?  

So I have to click the button "Close".

My question is: how to code in applescript to do the 4) automatically?  

Here is my applescript:

```
tell application "Terminal"
    do script "cd /Users/Shared/Jenkins/Home/workspace/test"
    do script "make clean" in window 1
    do script "make" in window 1
    do script "./matrix.out" in window 1
    delay 20
    close window 1  # problem's here
end tell

```

Answer: 
I'm not clear on why your sample code doesn't work. I suspect it's because of the extra characters. 

After running this command Windows Explorer will be open and have the desired file selected (if it exists).

```
FullPathFilename := "e:\temp\test.csv"
Explorer := "explorer /select," . FullPathFilename
Run, %Explorer%

```
With contribution of [Ro Yo Mi](https://stackoverflow.com/questions/37102222/ahk-or-vba-code-to-rename-currently-opened-office-document-word-excel-powerpo/37102514#37102514) I am able to come up with following solution. However I am assuming that there might better solution to this task. 

```
 ;;; Customize Document Location (Choose form All Commands) in Quick Access Toolbar and get its position (#4 for my case)
#If WinActive("ahk_class OpusApp") || WinActive("ahk_class XLMAIN") || WinActive("PPTFrameClass")
#p:: ;Close Word/Excel/PowerPoint Document and Locate in Explorer Folder Location
clipboard = ;empty the clipboard
Send !4 ; Select full path while document location at #4 position in Quick Access toolbar
Send ^c ; copy the full path
ClipWait ; waits for the clipboard to have content
Send {esc}
Send, ^{f4} ; Close opened document only but keep Word/Excel/PPT program running
Explorer := "explorer /select," . clipboard
Run, %Explorer%\
return

```