vyrru5 / audioswitch

Automatically exported from code.google.com/p/audioswitch
0 stars 0 forks source link

JIT crash when left-clicking #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi! Just found this app and it looks like exactly what I'm after, but I'm 
getting a crash when left-clicking the tray icon (see exception below). I went 
to grab the debug version at submain.eu but am getting a 404 - any chance you 
could upload it to this site?

Running Windows 7 Ultimate 32-bit and looking to swap between onboard sound and 
video card HDMI out. (right-clicking the icon seems to work fine.

Thanks!

Dan

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Exception: Could not retrieve taskbar information.
   at AudioSwitch.WindowPosition.GetTaskBarInfo()
   at AudioSwitch.WindowPosition.GetWindowPosition(NotifyIcon notifyicon, Int32 windowwidth, Int32 windowheight)
   at AudioSwitch.FormSwitcher.notifyIcon1_MouseUp(Object sender, MouseEventArgs e)
   at System.Windows.Forms.NotifyIcon.OnMouseUp(MouseEventArgs e)
   at System.Windows.Forms.NotifyIcon.WmMouseUp(Message& m, MouseButtons button)
   at System.Windows.Forms.NotifyIcon.WndProc(Message& msg)
   at System.Windows.Forms.NotifyIcon.NotifyIconNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
AudioSwitch
    Assembly Version: 1.30.0.0
    Win32 Version: 1.30
    CodeBase: file:///C:/Program%20Files/AudioSwitch/AudioSwitch.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

Original issue reported on code.google.com by hasanyon...@googlemail.com on 2 Feb 2013 at 7:46

GoogleCodeExporter commented 9 years ago
http://submain.eu/AudioSwitch-Debug.zip
Try this latest version and report back any similar errors. Is your taskbar 
somehow different from default, like hidden or different size? The API used to 
get the location should work fine on Windows 7, so there must be something 
different in your system to make it misbehave. Maybe you can also give a 
screenshot to get a better view of your taskbar location & size?

Original comment by tanelte...@gmail.com on 2 Feb 2013 at 8:43

GoogleCodeExporter commented 9 years ago
Funny you should mention that - just remembered that on the machine I want to 
use it on I've changed the shell from Explorer. Think that could be it.... ;) 

Incidentally that does raise an interesting point. I'm looking to use it on my 
media center (XBMC) hence the change of shell. I wonder if it would be possible 
to include a 'portable' version of the app. I tried copying the AppData folder 
from my laptop to the XBMC machine to see if I could transfer the hotkey 
setting that way, but that didn't work (probably GUID related).

I know theres a lot of people in the XBMC/media center community that are 
looking for something that achieves the same as your app so it could be worth 
considering. Something like checking for a config file in the exe path and 
using that for the config, together with maybe a 'supress GUI' option (or 
ofcourse done through command line options). I can then use EventGhost to 
translate button presses on my remote control to easily switch between audio 
outputs.

Any thoughts? I haven't had a look at your code properly and would be willing 
to help out if its something you think is worth considering (if you don't mind 
bits of VB.Net invading your code!).

Original comment by hasanyon...@googlemail.com on 2 Feb 2013 at 9:10

GoogleCodeExporter commented 9 years ago
well I actually try to avoid VB.NET as I'm trying to rid myself from all that's 
left from 8 years of VB6 :) But, I see it as a great option to either make a 
separate app just for the background purpose, or maybe even to make some XBMC 
plugin to do the same. I'm also using XBMC but I don't need this functionality 
on this PC myself. I think that I could make a command-line option to run in 
stealth mode or something... Currently the hot key is saves according to .NET 
app's default user setting, meaning that it's somewhere in 
C:\Users\<user>\AppData\Local\AudioSwitch, but the subfolder name changes with 
every version number change, so not a constant. I think I could remake the 
taskbar location finding also to put the menu in center of the screen in case 
the taskbar is not found at all, instead of failing with an exception. Would 
you like to try this with a debug version and see how it would work?

Original comment by tanelte...@gmail.com on 2 Feb 2013 at 9:26

GoogleCodeExporter commented 9 years ago
Will run the debug version when I'm back at the PC.

For some background essentially I've got XBMC on a two screen setup, to the 
living room TV for day-to-day viewing and to a projector for movies. 
Essentially I'm after a way of changing the audio output via a button on the 
remote control when I'm going between the two video outs (from the HDMI hooked 
up to the TV to the audio out of my sound card thats plugged in to the surround 
sound).

I reckon the command line switch would be easiest, would be more flexible then 
I guess too. Definitely let me know if you want some testing.

And yes, VB is an absolute **** to get out the habit of!

Original comment by hasanyon...@googlemail.com on 2 Feb 2013 at 9:35

GoogleCodeExporter commented 9 years ago
I will shortly make a debug version (available at the same URL) that would take 
-silent as the command line option to run without any user notifications. One 
question though, should it still show notifications when the device gets 
changed, or should it hide all possible interactions in silent mode? I think 
the usage woule then be to first run it in normal mode, set the shortcut and 
then run it in silent mode to operate on the hotkey. This would make sense to 
me. For this I will first make it to show itself in center of default screen in 
case the taskbar is not found, and then the -silent option to hide all messages 
and disable the GUI totally.

Original comment by tanelte...@gmail.com on 2 Feb 2013 at 9:40

GoogleCodeExporter commented 9 years ago
Yeah that sounds good. XBMC can be a bit odd when playing with other program 
notifications. Perhaps ultimately there could be a -stfu option :D.

What do you think about the possibility of setting the keystrokes at command 
line? 

Original comment by hasanyon...@googlemail.com on 2 Feb 2013 at 9:43

GoogleCodeExporter commented 9 years ago
This can of course be done, I'll look into it, should be fairly simple. I'll 
update this issue when I have something ready for testing :)

Original comment by tanelte...@gmail.com on 2 Feb 2013 at 9:45

GoogleCodeExporter commented 9 years ago
I have updated the debug package. commandline options available:

-s - silent (no notifications, except when applying or removing hot keys)
-m - set modifier hot keys
-k - set regular key for hot key combination
usage: AudioSwitch.exe -mcontrol,alt,shift -kw -s

setting the hot keys overwrites the ones in user config file and remembers them 
next time if no new ones were given in command. They must not be set every 
time, but can be if needed.

Please give this debug version some testing and report ANY errors you get when 
using it, since I have also shifted around a lot of code for a cleanup and I 
would like to find any possible bugs before I release it as a new version.

Thanks!

Original comment by tanelte...@gmail.com on 2 Feb 2013 at 10:16

GoogleCodeExporter commented 9 years ago
I added few command line options to the debug version:
-i - index of a device which to set as default
-n - name of the device which to set as default (must be precise)
-l - get a list of names with their indexes, command-line printed response

Sample: AudioSwitch.exe -i1
sets the device as default which is indexed as 1'th in the 0-based list

After these commands AudioSwitch will exit, so it's optimal way to change 
device without any other app usage. No Form or anything else gets loaded.

Original comment by tanelte...@gmail.com on 2 Feb 2013 at 12:51

GoogleCodeExporter commented 9 years ago
sorry, removed -n because whitespaces in the name string cause too much of a 
hassle and there is no need for it currently, so I'll not invest any time in 
this right now.

Original comment by tanelte...@gmail.com on 2 Feb 2013 at 12:53

GoogleCodeExporter commented 9 years ago
That worked an absolute treat! Following your shortcut, XBMC now switches audio 
between my TV and surround sound when I hit Blue on my remote control. Awesome!

One thing, I tried setting it to Alt+1 at the command line and it set it to 
Alt+LeftButton (I think). But I've got around that.

Excellent stuff sir. Would highly recommend getting a post on to the XBMC 
forums, I think you'll get a lot of downloads from this!

Original comment by hasanyon...@googlemail.com on 2 Feb 2013 at 3:26

GoogleCodeExporter commented 9 years ago
Thanks! That would be really cool :) In case there are no more issues to fix 
I'll release this version soon in downloads section and update the front page 
with new options for using the command-line part. When this is done I'll have a 
look in the XBMC forums, maybe I'll find a place for this thread :)

Original comment by tanelte...@gmail.com on 2 Feb 2013 at 3:52

GoogleCodeExporter commented 9 years ago
Top man! This will be the place you want - 
http://forum.xbmc.org/forumdisplay.php?fid=116 . Best of luck sir and congrats 
on the app!

Original comment by hasanyon...@googlemail.com on 2 Feb 2013 at 4:12