내 C# 응용 프로그램에서 flashwindowex winapi를 사용하여 아이콘 트레이에서 IE 창을 플래싱합니다. 코드에 중단 점을 추가하고 디버그에서 실행하면 코드가 잘 실행됩니다. 그러나 중단 점이 제거 될 때 같은 코드가 작동하지 않습니다.창 깜박임
그것은 콘솔 응용 프로그램이며 이름으로 만든 IE 프로세스의 핸들을 찾기 위해 몇 가지 Windows API를 사용하고 있습니다. 프로세스의 핸들은 프로세스를 플래싱하기 위해 FlashWindowEX
WINAPI로 전달됩니다.
public static System.IntPtr hnd = IntPtr.Zero;
public delegate bool CallBackPtr(IntPtr hwnd, int lParam);
public static CallBackPtr callBackPtr;
public const UInt32 FLASH_T = 3;
public const UInt32 FLASH_S = 12;
static void Main(string[] args)
{
try
{
OrigCode();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.ReadLine();
}
public static void OrigCode()
{
string strPzszPath = string.Empty;
string strCommandLine = string.Empty;
string strpath1 = "http://localhost/Till/Default.aspx";
strPzszPath = string.Concat(strPzszPath, strpath1);
strPzszPath = string.Concat(strPzszPath, "?TSCashierID=JILL&TSBalPeriod=2&TSBalDate=2015-06-02");
strCommandLine = strPzszPath;
Process procRequested = new Process();
////Create the process in minimised mode by default
procRequested.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
procRequested.StartInfo.UseShellExecute = false;
////Get the file name in which process is required to be started
procRequested.StartInfo.FileName = @"C:\Program Files\Internet Explorer\IExplore.exe";
procRequested.StartInfo.Arguments = strCommandLine;
////Start the process, process should be created in minimised mode
procRequested.Start();
callBackPtr = new CallBackPtr(SetFocusEnum);
int intResult = EnumWindows(callBackPtr, 0);
FLASHWINFO fi = new FLASHWINFO();
fi.cbSize = Convert.ToUInt32(Marshal.SizeOf(fi));
fi.hwnd = hnd;
fi.dwFlags = FLASH_T | FLASH_S;
fi.ucount = UInt32.MaxValue;
fi.dwTimeout = 0;
FlashWindowEx(ref fi);
}
private static bool SetFocusEnum(IntPtr hWnd, int intLParam)
{
int intSize = GetWindowTextLength(hWnd);
try
{
if (intLParam == 0) //Process created so check by name
{
if (intSize++ > 0)
{
//Capture the running window name
StringBuilder sbWindowName = new StringBuilder(intSize);
GetWindowText(hWnd, sbWindowName, intSize);
//Capture the running process with the window name
if (sbWindowName.ToString().Contains("My Web Application Title"))
{
//Capture the handle which will be used to set the focus
hnd = hWnd;
}
}
}
}
catch (Exception ex)
{
}
finally
{
}
return true;
}
아래는 내가 사용하는 WINAPI 기능은 다음과 같습니다
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
internal static extern int EnumWindows(CallBackPtr callPtr, int intProc);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
internal static extern int GetWindowTextLength(IntPtr intptrHwnd);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
internal static extern int GetWindowText(IntPtr intptrHwnd, StringBuilder strText, int intMaxCount);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool FlashWindowEx(ref FLASHWINFO pwfi);
[StructLayout(LayoutKind.Sequential)]
private struct FLASHWINFO
{
public UInt32 cbSize;
public IntPtr hwnd;
public UInt32 dwFlags;
public UInt32 ucount;
public UInt32 dwTimeout;
}
우리가 계속 아무 상관이없는 경우 우리가 당신을 도울 수, 코드를 제시해주십시오. 무엇이 무엇인지, 어떤 일이 일어나지 않았는지에 대한 설명은 코드 없이는별로 도움이되지 않습니다. –
안녕하세요, 내 휴대폰과 코드를 통해 내일 공유 할 수있는 쿼리를 게시 오전하지만 만약 내가 접근 방식에 대해 이야기한다면, 나는이 링크에 표시된 것과 같은 방식으로 flashwindoex를 사용하고 있습니다. http://stackoverflow.com/questions/4889181/get-user-attention-ste-stealing-focus. 해당 창 핸들 값을 얻으려면 enumwindows winapi 및 해당 값을 사용하여 오전 나는 flashwindowex 메서드에 전달하고있다. –
저는 현재 내 전화에도 있습니다. 따라서 특정 코드가 없으면 많은 것을 할 수 없습니다 (모든 것을 올바르게 사용했는지 확인하기를 원했을 것입니다). 컴퓨터에 접속할 때 시험을 보겠습니다. –