Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Close an application - doesn't work!


  • Please log in to reply
32 replies to this topic
trismarck
  • Members
  • 390 posts
  • Last active: Nov 25 2015 12:35 PM
  • Joined: 02 Dec 2010

Ok, so I was wrong, Process, Close does not set A_LastError.

So what does the msgbox show when you run this:

; for WinXP or higher
ProcessClose(PID) {
    if PID is not number
        return, 0, ErrorLevel := "Wrong parameter"
    
    if(hProc := DllCall("OpenProcess"
                            , UInt, 0x001F0000 | (A_OSVersion = "WIN_XP" ? 0xFFF : 0xFFFF)
                            , UInt, false
                            , UInt, PID) )
    {
        if(not DllCall("TerminateProcess"
                            , Ptr, hProc
                            , UInt, 0) )
            return, 0, ErrorLevel := "TerminateProcess"
                . "`nErrorLevel: " ErrorLevel
                . "`nLastError: " A_LastError
        
        DllCall("CloseHandle"
                            , Ptr, hProc)
    }
    else
    {
        return, 0, ErrorLevel := "OpenProcess"
            . "`nErrorLevel: " ErrorLevel
            . "`nLastError: " A_LastError
    }
    return, PID, ErrorLevel := 0
}
;PID := DllCall("GetCurrentProcessId") + 99999999
Process, Exist, Pvxwin32.exe
ProcessClose(PID := ErrorLevel)
MsgBox, % ErrorLevel

New Autohotkey forum: http://ahkscript.org.


Albireo
  • Members
  • 558 posts
  • Last active: Dec 13 2019 02:02 PM
  • Joined: 01 Feb 2006

Thanks!

 

 

Ok, so I was wrong, Process, Close does not set A_LastError.

So what does the msgbox show when you run this:

; for WinXP or higher
ProcessClose(PID) {
    if PID is not number
        return, 0, ErrorLevel := "Wrong parameter"
    
    if(hProc := DllCall("OpenProcess"
                            , UInt, 0x001F0000 | (A_OSVersion = "WIN_XP" ? 0xFFF : 0xFFFF)
                            , UInt, false
                            , UInt, PID) )
    {
        if(not DllCall("TerminateProcess"
                            , Ptr, hProc
                            , UInt, 0) )
            return, 0, ErrorLevel := "TerminateProcess"
                . "`nErrorLevel: " ErrorLevel
                . "`nLastError: " A_LastError
        
        DllCall("CloseHandle"
                            , Ptr, hProc)
    }
    else
    {
        return, 0, ErrorLevel := "OpenProcess"
            . "`nErrorLevel: " ErrorLevel
            . "`nLastError: " A_LastError
    }
    return, PID, ErrorLevel := 0
}
;PID := DllCall("GetCurrentProcessId") + 99999999
Process, Exist, Pvxwin32.exe
ProcessClose(PID := ErrorLevel)
MsgBox, % ErrorLevel

The program seems to work a bit "random" in Win 8.1 64-bit.

 

But on your question .:

Open processes

ErrorLevel: 0

LastError: 5

(I haven't tried as many different way to run - yet.)

 

____________________________
 
The program can be started in many ways.
c:\pvx\pvxwin32.exe .\scserver.ini
c:\pvx\pvxwin32.exe .\chncupd.ini
c:\pvx\pvxwin32.exe .\squidstar.ini

c:\pvx\pvxwin32.exe .\providex.ini
c:\pvx\pvxwin32.exe .\winpos.ini
c:\pvx\pvxwin32.exe .\qpdb.ini
 
and it performs different things and should thus be stopped in different ways.

in the task manager (tab processes) can you see  something like this .:

 

ProvideX for Windows (32 bitar)
   Squid Back-Store 2.41.70
   
ProvideX for Windows (32 bitar)
   CommLog
   
ProvideX for Windows (32 bitar)
   Star Communication Server ||....

 

But in the tab "information", can you only see Pvxwin32.exe and the process ID.

 

The most difficult process to deal with, is when the application is running as the "Star Communication Server .."

also the most important process to deal properly.

 

 

//jan



tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007

you could try WMI to close by process name or cammand line that started it


Never lose.
WIN or LEARN.

Albireo
  • Members
  • 558 posts
  • Last active: Dec 13 2019 02:02 PM
  • Joined: 01 Feb 2006

you could try WMI to close by process name or cammand line that started it

What is WMI?

and how to use WMI to handle this process?

//Jan



trismarck
  • Members
  • 390 posts
  • Last active: Nov 25 2015 12:35 PM
  • Joined: 02 Dec 2010

Error 5 means that the access to the process was denied. This might happen i.e. if the process has privileges of the System user (even if the Autohotkey script is run as user part of an Administrators group).

 

I've looked at the script in the first post in the thread and I have the following notes:

  • PostMessage 0x112, 0xF060,,, %WinTitle%, %SCserverTxt% - Autohotkey doesn't send that message anymore
  • PostMessage 0x112, 0xF060,,, %WinTitle%, %SCserverTxt% - PostMessage only sets errorlevel either on timeout or the target window not existing. PostMessage does not set errorlevel upon whether the window has processed the posted message or not
  • WinWaitClose %WinTitle%, %SCserverTxt%, 10 - WinWaitClose doesn't close the window, it only waits for the window to be closed
  • WinKill %WinTitle%, %SCserverTxt%, 10 - WinKill doesn't set errorlevel. So there is a suspicion that WinKill actually worked
  • WinClose was not tested

So I'd suggest testing WinClose and WinKill again, perhaps with ahk_exe Pvxwin32.exe as the WinTitle parameter (and w/o the WinText parameter, to be sure).

 

Also, what does it mean that:

The program seems to work a bit "random" in Win 8.1 64-bit. 

Is the program the AHK script with the ProcessClose() function?

 

Also, is it possible to kill the process through Task Manager, _regardless_ of the command line switch used when launching the process?


New Autohotkey forum: http://ahkscript.org.


Albireo
  • Members
  • 558 posts
  • Last active: Dec 13 2019 02:02 PM
  • Joined: 01 Feb 2006

Thanks!

 

 

You could try the Taskkill command or the Tskill command.

It depends on the existence of the command.

If both exist, it's better to use Taskkill.

RunWait, taskkill /f /t /im Pvxwin32.exe,, Hide UserErrorLevel
; or
RunWait, tskill Pvxwin32,, Hide UserErrorLevel

Now I have tested "Taskkill" (from the DOS-command prompt)

For info .:

PID 1712 = pvxwin32.exe

PID 1984 = explorer.exe

 

as "trismark" says, I got the following message .:

 

ERROR: The process with PID 1712  (child process of PID 1984) could not be terminated.
Reason: Access denied

 

Have tested

#NoEnv
#SingleInstance force
SetBatchLines -1
SetWorkingdir  %A_ScriptDir%

ProcessName := "Pvxwin32.exe"
SCserverTxt := "Star Communication Server"


; Get the ID for the process
Process Wait, %ProcessName%, 5.5
NewPID = %ErrorLevel%  ; Save the value immediately since ErrorLevel is often changed.
If NewPID = 0
   {
   MsgBox 64, %A_ScriptName% - Rad %A_LineNumber%, Unable to find process "Pvxwin32.exe" in 5.5 seconds
   Return
   }

WinClose ahk_exe %ProcessName%
MsgBox 64, %A_ScriptName% - Rad %A_LineNumber%, ErrorLevel = %ErrorLevel%

WinKill ahk_exe %ProcessName%
MsgBox 64, %A_ScriptName% - Rad %A_LineNumber%, ErrorLevel = %ErrorLevel%
  
ExitApp

The program "pvxwin32.exe" is not terminated.

ErrorLevel = PID

 

The problem is "Access denied"

_____________

 

I have no idea why the program(pvxwin32.exe), is sometime easy and sometimes hard to close.

 

No problem to kill the process(pvxwin32.exe) with the Task Manager.

 

//Jan

 



trismarck
  • Members
  • 390 posts
  • Last active: Nov 25 2015 12:35 PM
  • Joined: 02 Dec 2010

What about those:

DllCall("EndTask"
    , Ptr , WinExist("ahk_exe Pvxwin32.exe")
    , UInt, false
    , UInt, false)    ; force
;    , UInt, true)    ; force
MsgBox, % ErrorLevel


oWMI := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
NAme := "Pvxwin32.exe"
for proc in oWMI.ExecQuery("Select * from Win32_Process Where Name = '" NAme "'")
    MsgBox % proc.terminate() 

Also, in Task Manager, do you kill the process through the 'End Task' button or through the 'End Process' button? (I have those buttons in Applications or Processes tab on Windows XP respectively, perhaps they are named differently on Win8.


New Autohotkey forum: http://ahkscript.org.


Albireo
  • Members
  • 558 posts
  • Last active: Dec 13 2019 02:02 PM
  • Joined: 01 Feb 2006

Thanks "Trismarck"!

Interesting.

 

This made a difference. (I have to test more to see if this method can be used in full.)

 

........

 

What about those:Also, in Task Manager, do you kill the process through the 'End Task' button or through the 'End Process' button? (I have those buttons in Applications or Processes tab on Windows XP respectively, perhaps they are named differently on Win8.

 

 

I only have one choice (one button). "Avsluta aktivitet" and I can translate this to "End Task" or "Exit Activity".

And when I press the button, the application (Pvxwin32.exe) exits (no questions).

 

At the first test run, the following occurred (Win 8.1 64-bit swe)

- A window opens that asks the question "Do you want to quit? Yes / No"

That's OK!, that question shall normally come up.

 

But if I don't answer on the question directly.
A new message is coming up .: (freely translated)

 

This program is not responding.
 
Click Cancel to return to Windows and check the status of the program.
 
If you choose to end the program now, all unsaved data will be lost. Click "Quit now " to end the program now.

And I have two buttons "Quit Now" and "Cancel"

 

If I press "Cancel" - the ahk program is showed "0" and button "OK".

Now comes the window "Do you want to quit? Yes / No" back

My choice "Yes" - the ahk program show "0" and button "OK". again

I press OK and the program (Pvxwin32.exe) was closed.

 

Have not tested on another OS, config or other choices - right now

 

//Jan



trismarck
  • Members
  • 390 posts
  • Last active: Nov 25 2015 12:35 PM
  • Joined: 02 Dec 2010

In the script I posted, there are two methods. One is through EndTask() and the other is through WMI. Both of those could be tested. Additionally, uncomment the fifth line in the script to _force_ the process to close.

 

Also, in Task Manager, is the End Task button (Avsluta aktivitet) on the Processes tab or on the Details tab?


New Autohotkey forum: http://ahkscript.org.


Albireo
  • Members
  • 558 posts
  • Last active: Dec 13 2019 02:02 PM
  • Joined: 01 Feb 2006

I've now tested the same thing on a Win XP pro 32-bit computer.

 

First the ahk program is showed "0" and button "OK".

one second later a new window (from Pvxwin32.exe) opens that asks the question "Quit Star Communication Server? Yes / No"
(a little bit different text than from win 8, but the same meaning)

 

If nothing is done, the program  (Pvxwin32.exe) is automatically closed after maybe 5 seconds,

and the only thing left is the information "0" from the AHK program.

 

Obviously, it is something essential that distinguishes between Win8 and Win XP, how the files / security handled.

(I have not tested the same thing on Win 7)

_________

 

I have had problems to install that program (pvxwin32.exe) into WIn 8.
I must install the program as administrator in Win 8, and for safety's sake, have I closed the firewall.

and to not always get the question "Do you really want to run the program" I have reduced control of UAC (Windows User Access Control) in Win 8.

 

(Hope you understand what I mean despite my poor english)

//Jan



Albireo
  • Members
  • 558 posts
  • Last active: Dec 13 2019 02:02 PM
  • Joined: 01 Feb 2006

OK!

I missed that it was two programs (excuse me, I do not understand everything that happens in the code)

It is not easy to describe the processes, but I will try

 

the first script

DllCall("EndTask"
    , Ptr , WinExist("ahk_exe Pvxwin32.exe")
    , UInt, false
    , UInt, false)    ; force
;    , UInt, true)    ; force
MsgBox, % ErrorLevel

Win 8.1 64-bit

- A window opens that asks the question "Do you want to quit? Yes / No"

That's OK!, that question shall normally come up.

 

But if I don't answer on the question directly.
A new message is coming up .: (freely translated)

 

This program is not responding.
 
Click Cancel to return to Windows and check the status of the program.
 
If you choose to end the program now, all unsaved data will be lost. Click "Quit now " to end the program now.

And I have two buttons "Quit Now" and "Cancel"

 

If I press "Cancel" - the ahk program is showed "0" and button "OK".

Now comes the window "Do you want to quit? Yes / No" back

My choice "Yes" - the ahk program show "0" and button "OK". again

I press OK and the program (Pvxwin32.exe) was closed.

 

If I instead press "Quit Now".

a New window with a message from Microsoft Windows is opened.

(freely translated)

 

ProvideX for Windows is not responding.

Information may be lost if you close the program.

(two choises)
- Close the program
- Wait until the program is responding

 

If I made the choice .:

"Close the program",  or "Wait until the program is responding" same thing occurs.

Microsoft Windows is trying to repair the problem, and it works. The program "Pvxwin32.exe" is closed after a while.

After this above, a MsgBox from the "ahk program", is opened, and showing "0"

 

 

With  line 5, the same thing happened, I think, (the script below show the line 5 active)

DllCall("EndTask"
    , Ptr , WinExist("ahk_exe Pvxwin32.exe")
    , UInt, false
    , UInt, false    ; force
    , UInt, true     ; force
    , UInt, true)    ; force
MsgBox, % ErrorLevel

Win XP pro - 32bit

- A window opens that asks the question "Do you want to quit? Yes / No"

That's OK!, that question shall normally come up.

 

But if I don't answer on the question directly.
First the ahk program is showed "0" and button "OK".

one second later a new window (from Pvxwin32.exe) opens that asks the question

"Quit Star Communication Server? Yes / No" (freely translated - a little bit different text than from win 8, but the same meaning)

 

If nothing is done or if you quickly select yes or no in the window that pops up - same thing happens in all cases.

the program  (Pvxwin32.exe) is automatically closed after maybe 5 seconds,

and the only thing left is the information "0" from the AHK program.

 

With or without line 5, the same thing happened, but with the line 5, I received the message from AHK program:. "A4" (instead of "0")

 

_______________________________________

 

the second script

oWMI := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
NAme := "Pvxwin32.exe"
for proc in oWMI.ExecQuery("Select * from Win32_Process Where Name = '" NAme "'")
	MsgBox % proc.terminate()

Win 8.1 64-bit / WinXP

The program Pvxwin32.exe is closed direct in both OS.

No questions or something like this.

______________________________________

 

In both examples have you used "pvxwin32.exe",

but if I must use the programs PID:s or something because I normally have many processes with the name "Pvxwin32.exe".

Does it matter to make the choice of the programs with  PvxWin32.exe or PID:s?

 

 

Also, in Task Manager, is the End Task button (Avsluta aktivitet) on the Processes tab or on the Details tab?

Process tab. (Win 8.1)

(but in the Details tab (Information) - I can see the processnumber and quit the program in the same way)

 

_______________________________

 

 

 

Also, in Task Manager, do you kill the process through the 'End Task' button or through the 'End Process' button? (I have those buttons in Applications or Processes tab on Windows XP respectively, perhaps they are named differently on Win8.

In win 8.1 (more interesting because I was going to use the finished product in Win 8.1)

I can not find a button "End Process." So the answer must be the "End Task"

 

_____________________________________

 

Are there any problems or risks, to use the second script to close an application?

(No memory leak or other problems)

 

//Jan



tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007

i use code like the second script within a large corp intranet and never seen problems related to using that


Never lose.
WIN or LEARN.

trismarck
  • Members
  • 390 posts
  • Last active: Nov 25 2015 12:35 PM
  • Joined: 02 Dec 2010

First script
Win 8.1 64-bit
- A window opens that asks the question "Do you want to quit? Yes / No"
That's OK!, that question shall normally come up.

Well, if the 'soft' kill works, I'd just automate that window by ControlSend or sending keystrokes to it. It's certainly safer than terminating the process.
 

With  line 5, the same thing happened, I think, (the script below show the line 5 active)

DllCall("EndTask"
    , Ptr , WinExist("ahk_exe Pvxwin32.exe")
    , UInt, false
    , UInt, false    ; force
    , UInt, true     ; force
    , UInt, true)    ; force
MsgBox, % ErrorLevel

I don't think so - that script will always show A8, as too many parameters are passed to EndTask.
That script fails to call the function because EndTask only takes _three_ parameters. What I've really meant by uncommenting line 5 was to at the same time comment out line 4. The AX error is described in the documentation of DllCall.
 

Win XP pro - 32bit
- A window opens that asks the question "Do you want to quit? Yes / No"
That's OK!, that question shall normally come up.
 
But if I don't answer on the question directly.
First the ahk program is showed "0" and button "OK".
one second later a new window (from Pvxwin32.exe) opens that asks the question
"Quit Star Communication Server? Yes / No" (freely translated - a little bit different text than from win 8, but the same meaning)

If the Quit Star Communication Server window is a window not generated by Pvxwin32.exe, then it's ok. Otherwise, it would mean that the process you're killing is part of some bigger application and after killing the process, the whole application quits.
 

WinXP
With or without line 5, the same thing happened, but with the line 5, I received the message from AHK program:. "A4" (instead of "0")

See above.

 

In both examples have you used "pvxwin32.exe",
but if I must use the programs PID:s or something because I normally have many processes with the name "Pvxwin32.exe".

Does it matter to make the choice of the programs with  PvxWin32.exe or PID:s?

The first script: WinExist and ahk_pid as WinTitle.
The second script: ProcessId instead of name of the process. And the type of the argument would also have to be changed.
 

Process tab. (Win 8.1)
(but in the Details tab (Information) - I can see the processnumber and quit the program in the same way)

On Windows XP, closing the process from one of those yields different behaviour than closing from other.
 

Are there any problems or risks, to use the second script to close an application?
(No memory leak or other problems)
 
//Jan

Well, terminating the process is the last resort mechanism. I.e. if that process was saving a configuration file and while doing that, it was terminated, the program could have trouble running again if the programmer didn't foresee that scenario.


New Autohotkey forum: http://ahkscript.org.


Albireo
  • Members
  • 558 posts
  • Last active: Dec 13 2019 02:02 PM
  • Joined: 01 Feb 2006

Thanks again!

 

Well, if the 'soft' kill works, I'd just automate that window by ControlSend or sending keystrokes to it. It's certainly safer than terminating the process.

Yes, I also think it would have been useful to use this option, but...

The message .:

This program is not responding.

Click Cancel to return to Windows and check the status of the program.
If you choose to end the program now, all unsaved data will be lost. Click "Quit now " to end the program now.

And I have two buttons "Quit Now" and "Cancel" and so on.

 

If I try the other way (line 4 is comment out  and line 5 is uncommenting) like this .:

DllCall("EndTask"
    , Ptr , WinExist("ahk_exe Pvxwin32.exe")
    , UInt, false
    , UInt, false    ; force
; 	, UInt, true)     ; force
    , UInt, true)    ; force
MsgBox, % ErrorLevel

The program is closed without questions. (I never get the message .: A8)

 

Win XP. pro 32-bit
No matter which version of the testcode (line 4 or 5) I got the same result below.

First a message "a4" is from AHK-script.
Behind that window, a question from Pvxwin32.exe, "Do you want to quit". (Yes / No)
But if you dont be fast to answer, the Pvxwin32.exe is automatically closed. (about one or two seconds)
(I don't know what happen if I pressed No in time)

 

 

 

Now when I tested some different script (with VNC), has the remote computer
stopped answering....
I don't know if it was from wrong scripts or something other.

 

 

//Jan



Albireo
  • Members
  • 558 posts
  • Last active: Dec 13 2019 02:02 PM
  • Joined: 01 Feb 2006

Now I have done some more tests.

(Most of it has already been described. this is more a summary.)

 

1. Method 1. This is, maybe the best method to close an application. (But it doesn't work fully)

DllCall("EndTask"
    , Ptr , WinExist("ahk_exe Pvxwin32.exe")
    , UInt, false
    , UInt, false    ; force
    , UInt, true)     ; force
;     , UInt, true)    ; force
MsgBox, % ErrorLevel

Win 8.1 64-bit

Run the AHK-program above.

- A window opens that asks the question

Message
Do you want to quit the Star Communication Server? (Yes / No)

   (That's OK!, that question should normally come up.)

 

But if I don't answer on that question directly. (waiting some seconds)
A new message is coming up in front of other windows .: (freely translated)

This program is not responding.

Click Cancel to return to Windows and check the status of the program.
If you choose to end the program now, all unsaved data will be lost. Click "Quit now " to end the program now.
(This window has two buttons - "Quit Now" and "Cancel")

 

Press "Cancel" - on.: "This program is not responding"

The window from AHK program shows "0" and the button "OK"

   (and the window "This program is not responding" disappear)

Now, again I can see the "Do you want to quit, Yes / No" window.

   (after the  "OK"-button on the AHK-window has been pressed)

My choice "Yes" - and the program (Pvxwin32.exe) was closed.

 

Press "Quit Now" - on.: "This program is not responding"

a New window with a message from Microsoft Windows is opened. (freely translated)

ProvideX for Windows is not responding.

Information may be lost if you close the program.

(two choises)
- Close the program
- Wait until the program is responding

 

 

Press "Close the program" - on.: "Providex for Windows is not responding"

Microsoft Windows is trying to repair the problem, and it seems to work. The program "Pvxwin32.exe" is closed after a while.

And a MsgBox from the "ahk program", is opened, and showing "0" and "OK"

 

 

Press "Wait until the program is responding" - on.: "Providex for Windows is not responding"

The MsgBox from the "ahk program", is opened, and showing "0" and "OK" (Press OK)

Now we are back to the original question .:

Message
Do you want to quit the Star Communication Server? (Yes / No)

Press "Yes" - on.: "Message"

The Pvxwin32.exe is closed.

 

 

Press "No" - on.: "Message"

The program Pvxwin32.exe will continue. (as expected)

 

 

              = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

 

Win XP 32-bit

Run the AHK-program above.

Directly, the MsgBox shows the message "A4" and button OK. (not "0" as in Win 8.1)

After a while, (maybe a few seconds) the question .:

Message
Do you want to quit the Star Communication Server? (Yes / No)

is coming up, behind the MsgBox from the AHK-script.

Unless something is done, (a few seconds)

the question "Do you want to quit, the Star Communication Server?" disappears,

and the Pvxwin.exe is ended.

Even if I try to press "Yes" or "No", ends Pvxwin32.exe automatically.

 

--------------------------------------------------------------

=====================================

--------------------------------------------------------------

 

2. Method II

DllCall("EndTask"
    , Ptr , WinExist("ahk_exe Pvxwin32.exe")
    , UInt, false
    , UInt, false    ; force
; 	, UInt, true)     ; force
    , UInt, true)    ; force
MsgBox, % ErrorLevel

Win 8.1 64-bit

Run the AHK-program above.

 

Pvxwin32.exe is closed without questions

the MsgBox from AHK script above shows "0" and OK .

 

              = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

 

Win XP 32-bit

The same as for the previous script happens.

 

Run the AHK-program above.

Directly, the MsgBox shows the message "A4" and button OK. (not "0" as in Win 8.1)

After a while, (maybe a few seconds) the question .:

Message
Do you want to quit the Star Communication Server? (Yes / No)

is coming up, behind the MsgBox from the AHK-script.

Unless something is done, (a few seconds)

the question "Do you want to quit, the Star Communication Server?" disappears,

and the Pvxwin.exe is ended.

Even if I try to press "Yes" or "No", ends Pvxwin32.exe automatically.

 

--------------------------------------------------------------

=====================================

--------------------------------------------------------------

 

3. Method III (only for documentation and testing of a wrongly AHK script)

DllCall("EndTask"
    , Ptr , WinExist("ahk_exe Pvxwin32.exe")
    , UInt, false
    , UInt, false    ; force
    , UInt, true     ; force
    , UInt, true)    ; force
MsgBox, % ErrorLevel

Win 8.1 64-bit

Can not find any difference in method 1 above or this test. sequence of events seems to be the same way.

the MsgBox shows the message "0" and button OK. (not A8 as expected)

 

              = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

 

Win XP 32-bit

Can not find any difference in method 2 above or this test. sequence of events seems to be the same way.

But MsgBox shows the message "A8" and button OK. (as expected)

 

--------------------------------------------------------------

=====================================

--------------------------------------------------------------

 

Conclusion!

 

Interesting that one instruction can differ so much between Win 8 and Win XP

 

My desire is to just automatically close a program and answer the question .: "Do you want to quit the Star Communication Server?" (but it seems not easy).

Have no idea why all the other options and choices is coming up.

 

However, I think it is positive, that it is possible to exit the program by force (if the program does not work in the right way)

 

Is it impossible to automatically close a program with an AHK script correctly (without a lot of questions)?

 

//Jan