Jump to content

Need a nice way of closing uTorrent from my program


Ger Teunis

Recommended Posts

Thanks for the app. It works under wine, but only when "Close to tray" is not selected.

Thank you, I was not aware that this .NET application would run under wine!

Did you install the .NET framework on your wine to make it work?

Regarding the "Close to tray" option>

Could you post the textual output from the application while you try to close the application?

I use a lot of windows specific low-level calls (WM_* messages) to close the uTorrent client when the normal close is not really closing the application (like with the option "Close to tray"). I can imagine that Wine is not completely reacting the same as windows in handling the low-level calls. I am a bit surprised that the application is working at all in wine!

Link to comment
Share on other sites

Did you install the .NET framework on your wine to make it work?

yes, I needed to use two commands, which installed .NET 2.0:

wget http://www.kegel.com/wine/winetricks

sh winetricks dotnet20

Could you post the textual output from the application while you try to close the application?

There seems to be some complications. Sorry. First, i didn't noticed them. So (i will post only relevant/variable pieces to save space):

Case 1: When "Close to tray" is checked.

Case 1a: When window is minimized to system tray:

Application does not have a open window; will search for windows to close.

Process NOT closed, use force option to close.

Done...

Case 1b: When window is NOT minimized to system tray (so it appears on taskbar):

Closing application and waiting for response...

Timeout while closing application; will search for windows to close.

Process NOT closed, use force option to close.

Done...

Case 2: When "Close to tray" is NOT checked.

Case 2a: When window is minimized to system tray:

Application does not have a open window; will search for windows to close.

Process NOT closed, use force option to close.

Done...

Case 2b: When window is NOT minimized to system tray (so it appears on taskbar):

Closing application and waiting for response...

Application is closed.

Done...

Case 3: When "Close to tray" AND "Minimize to tray" both are NOT checked:

Closing application and waiting for response...

Application is closed.

Done...

Are you on a recent Wine? Like, 1.1.6.

On last stable - 1.1.1.

Regards.

PS: It is not such a big problem. The issues with not closing when it is minimized i can simply overcome by running before CloseApp.exe a few more strings of shell code:

if ps -e | grep uTorrent.exe #To see if it is running

then

wine /path_to_uT/uTorrent.exe #This command always maximizes uT

wine /path_to_CA/CloseApp.exe "C:\Program Files\uTorrent\uTorrent.exe"

fi

So this would maximize uT if it is running and then CloseApp.exe will close it anyway (except cases 1a/1b).

I can do this dirty hack(?) because (for me) it is only needed to close on very rare restarts and while APC battery is low -> shutdown. So it is not a problem of popping-up uT window. As for "Close to tray" habit - i'll get used to it :)

Link to comment
Share on other sites

I think it is the 'window walker' that is not compatible with 1.1.1 at least. The window walker code will try to close a minimized (to tray) uTorrent.

That window walker code is very platform specific indeed, but it would be nice that even an non-emulated environment ;) like wine will also work like it should.

1a> because it is minimized I use the window walker = not working

1b> not closing because "close to tray" is enabled (close will not close but minimize).

fallback to the window walker = not working.

2a> same is 1a.

2b> No window walker needed because the uTorrent window is not minimized

Perhaps a newer wine will work!

Ps> thanks for the winetricks tip.

Link to comment
Share on other sites

Now running 1.1.7. Results are IDENTICAL. About "window walker" - i think you are absolutely right.

P.S. Another winetricks tip: Some winetricks (like msxml3) download *.msi files with further execution of something like "msiexec /i downloaded_file.msi" and this step always fails with my setup (don't know why). The simple solution is to re-run "msiexec /i downloaded_file.msi" command manually with quiet switch in the end: "msiexec /i downloaded_file.msi /q".

Link to comment
Share on other sites

  • 1 year later...
  • 9 months later...

Hello!

Just wanted to share my experience. I am writing a program to search my HUGE video directory and create a folder with hard links to new files, e.g.:

I have a directory with movies

[movieS]

Movie_title_1.avi (12.01.2010)

Movie_title_2.avi (13.01.2010)

Movie_title_3.avi (14.01.2010)

Movie_title_4.avi (15.01.2010)

And my program creates a directory with hard links to these files so I can browse them by date_created AND STREAM (what's good about hard links is that they don't consume HDD space, but a dlna client treats them as original files).

[movieS]

[RECENT]

01_Movie_title_4.avi (15.01.2010)

02_Movie_title_3.avi (14.01.2010)

03_Movie_title_2.avi (13.01.2010)

04_Movie_title_1.avi (12.01.2010)

Movie_title_1.avi (12.01.2010)

Movie_title_2.avi (13.01.2010)

Movie_title_3.avi (14.01.2010)

Movie_title_4.avi (15.01.2010)

The main problem was: when a new movie is added, we have to delete hard links & create new ones. But trying to delete hard links failed on files locked by uTorrent (e.g. uploading).

So I also looked for a way of uTorrent safe closing. I read this thread for a solution, but did not want to sacrifice "close to tray".

So my algorithm is:

1. Check if process utorrent is running

2. If it is, run ("C:\Program Files (x86)\uTorrent\utorrent.exe"). This operation brings main window of uTorrent at top, not starting new process.

3. Wait until active window tiltle includes "µTorrent"

4. Send alt – f – x (File – Exit) Here if you have a confirmation of quit enabled, we can send ENTER, but I just turned it off.

5. Wait until there is no process with name "utorrent" running.

So the only drawback of this method is a "flash" of utorrent main window showing for 0.5 sec.

Advantage: You can have all settings you like (close to tray, exit confirmation and so on).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...