Wie kann ich Pidgin per Befehl schließen?

527
Blauhirn

Das Problem wurde unter https://developer.pidgin.im/ticket/9698 beschrieben .

In Linux kann ich pidgin bitten, via pkill pidginoder zu schließen kill [pid]. Das Programm wird sich dann darum kümmern und sich selbst herunterfahren. Windows funktioniert nicht so. Ein WM_CLOSESignal wird nur das Fenster schließen, nicht den Vorgang (genau wie wenn Sie sich selbst treffen x).

Wie schließe ich Pidgin per Befehl?

Motivation : Es scheint, dass viele XMPP-Server die Clients benötigen, um sich aktiv zu verabschieden, um zu erkennen, dass sie offline sind. Mit anderen Worten, es werden keine keep-alivePakete benötigt oder es gibt keine Timeouts (und wenn, ziemlich verzögert). Dies ist normalerweise kein großes Problem, da wir unsere Kunden entsprechend starten und beenden (Herunterfahren wird als beendet betrachtet). Wenn Sie jedoch in den suspend/ hibernate-Modus wechseln, ist es so, als wäre die Netzwerkverbindung plötzlich unterbrochen - keine Möglichkeit für pidgin, "Hey, geht offline" zu sagen. Also, ich brauche ein Skript automatisch schließen Pidgin anmutig (ausgeführt direkt vor Aussetzung).

0

2 Antworten auf die Frage

0
Blauhirn

Here is an AutoHotkey script which emulates the following user steps:

  • Open main window if not open already
  • Send Ctrl-Q to it so pidgin quits

.

pidginMainWindowTitle := "Buddy List" process, exist, pidgin.exe if(ErrorLevel!=0) { ; Pidgin process is running -> close it if(!winExist(pidginMainWindowTitle)) { ; ..but main window is not. ; determine full pidgin path winGet, pidginPath, ProcessPath, ahk_exe pidgin.exe if(pidginPath=="") { msgbox, Process path empty? exitapp } ; run pidgin again: will open main window run %pidginProcessPath% ; wait for the window max. 2 seconds winWait, %pidginMainWindowTitle%,, 2 if(ErrorLevel==1) { msgbox, Couldn't start main window exitapp } ; send exit key combo to pidgin main window controlSend,, ^q, %pidginMainWindowTitle% ; wait for the process to close max. 2 seconds process, WaitClose, pidgin.exe, 2 if(ErrorLevel) { msgbox, Couldn't exit pidgin gracefully exitapp } } } 
0
CBHacking

The utility you want is taskkill.exe, which is a command-line program built into the Windows OS (roughly analogous to kill on Unix-like systems) and found in the system directory (C:\Windows\System32\taskkill.exe). By default, it asks (but does not force) programs to exit, and does not use window messages.

Run taskkill /? from a command line shell (cmd or powershell) for usage information, but the basic command you want is taskkill /im pidgin.exe (note that the extension is necessary on the image name of the program to kill). Do NOT pass the /f flag here, as this will forcibly terminate the program (analogous to kill -9) without giving it time to perform any cleanup (though that is useful for programs you want to kill immediately, or that are hung and don't respond to normal close requests).

Getting this to run automatically at logoff may be tricky; consider using Task Scheduler.