Jump to content


Photo

Hotkey to shutdown when debugging


  • Please log in to reply
3 replies to this topic

#1 zilav

zilav

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 451 posts

Posted 20 November 2014 - 07:28 AM

Is it possible to add a shortcut property like ServerModule.DebugShutdownKey, so when DebugHook <> 0 and the keys are pressed, unigui will shutdown itself?

I run unigui dozens of times per day, and every time need to select with mouse a tray icon, right click for popup menu, then click Shutdown. Quite annoying really when you do that again and again, day after day.


  • 0

#2 NelsonFS

NelsonFS

    Active Member

  • uniGUI Subscriber
  • PipPipPip
  • 90 posts

Posted 20 November 2014 - 10:11 AM

Other method is simply create a Events inside Delphi:

Project => Option => Build Events

- Change on top to "All Configuration"

Below Pre-Build Events:

- Unckeck Option "Cancel On Error"

- In command line set:

      taskkill /F /IM $(OUTPUTFILENAME) /T

 

just this!

When run/debug will kill server application before compile and run again!

:D


  • 0

#3 zilav

zilav

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 451 posts

Posted 20 November 2014 - 02:35 PM

I can just press Ctrl+F2 for that. But I don't want to kill the process. I want unigui to shutdown normally, write proper log messages including my own ones, call all relevant events inside the app and don't pile up icons of killed processes in system tray.


  • 0

#4 georgek

georgek

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 08 May 2018 - 04:24 PM

As a workaround you can create a new application called MyAppCloser which will send a custom message to your server for example WM_USER+15

You have to include a window message listener to the server and once the message is received you have to shutdown everything from your app (disconnect from DB, etc) and when you are ready you send back a message to the MyAppCloser like WM_USER+16. Then you terminate server.

When MyAppCloser receives WM_USER+16 it just sleeps 1-2 seconds (give some time to exe to terminate) and then terminate (exit).

To make sure your app will close in all cases (including server hang/freeze) you can add a timer that will timeout in X seconds (number of seconds is totally up to your app shutdown process). If no WM_USER+16 is received within X seconds you will force kill the executable using ShellExecute the command

taskkill /F /IM ParamStr(1) /T

 

Then add a pre-built event as @NelsonFS adviced

 

MyAppCloser.exe $(OUTPUTFILENAME)

 

If you further have many UniGui apps at the same time a fixed WM_USER + 15 will mess up things. You can configure the WM_USER + X numbers in command line

MyAppCloser.exe $(OUTPUTFILENAME) 15 16

 

so it will check for executable file as well as the WM_USER + X to send and WM_USER + X to receive make it unique for a specific unigui app.


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users