Przejdź do głównej zawartości

Toggle Vibrate & Ring

Toggle VibraOrRing
cab installation for WM 6.0:
XDA Thread...

c# how to toggle Vibra and Ring On ? simple... use this code :)

using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace toggleVibrateSound
{
class Program
{
private enum SoundEvent
{
All = 0,
RingLine1,
RingLine2,
KnownCallerLine1,
RoamingLine1,
RingVoip
}

private enum SoundType
{
On = 0,
File = 1,
Vibrate = 2,
None = 3
}

private struct SNDFILEINFO
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szPathNameNative;

[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szDisplayNameNative;

public SoundType SstType;
}


[DllImport("aygshell.dll", SetLastError = true)]
private static extern uint SndSetSound(SoundEvent seSoundEvent, ref SNDFILEINFO pSoundFileInfo, bool fSuppressUI);

[DllImport("aygshell.dll", SetLastError = true)]
private static extern uint SndGetSound(SoundEvent seSoundEvent, ref SNDFILEINFO pSoundFileInfo);


public static void SetRingerOn()
{
SNDFILEINFO sfi = new SNDFILEINFO();
sfi.SstType = SoundType.On;
uint ret = SndSetSound(SoundEvent.All, ref sfi, true);
}

public static void GetCurrentSoundType()
{
SNDFILEINFO sfi = new SNDFILEINFO();
uint ret = SndGetSound(SoundEvent.All, ref sfi);
SoundType aa = sfi.SstType;
if (aa == 0) Vibra(); else SetRingerOn();
}

public static void Vibra()
{
SNDFILEINFO sfi = new SNDFILEINFO();
sfi.SstType = SoundType.Vibrate;
uint ret = SndSetSound(SoundEvent.All, ref sfi, true);
}
unsafe static void Main(string[] args)
{
//Vibra(); // set vibra mode on
//SetRingerOn(); // set ringer mode on
GetCurrentSoundType(); // in this case we toggle Vibra and Ring...

}
}
}

cheers... :)

Komentarze

Popularne posty z tego bloga

NetBeans and Trackpoint problem...

Netbeans doesn't allow (for some reasons) using native trackpoint + third blue button for scrolling through code view listing :/ that's annoying if You're not using mouse wheel ... I have Lenovo X200 and that was big problem for me... here is solution: open C:\Program Files\Lenovo\TrackPoint find tp4table.dat an edit it in Notepad++, add these lines, between similar lines: ; NetBeans support *,*,netbeans.exe,*,*,*,WheelStd,0,9 save the file, restart computer and voila... now Netbeans supports scrolling with Lenevo's trackpoint... tested with Netbeans 7.01 on win7 and default lenovo's trackpoint drivers

Send WinKey - Open Start Menu...

Send WinKey is tiny application that is emulating click of Windows Key... * You can use it while binding / mapping your hardware keys (ex Xperia, Touch Pro etc.) when You need the "fast" opening of Start menu (not touching screen but pressing the button...) Cab Installation XDA-Developers Thread *(yesssss... I know that MortScript has got that kind of options... but ... not everybody needs to have mortscript installed... or not everybody wants to edit those lines of scripts/codes... etc) :) cheers...