I often encounter a problem when downloading my daily tv show in form of rar parts. When doing that i want to open the video file already while downloading (like streaming).
Therefore i made up a small application that clicks the button of the rar application every 1,5s.
Because of that i can watch the partial extracted movie with VLC (i guess several other players can do that too).
The code of the Application basically consists of two functions:
public static void ClickButton(IntPtr AHandle) { SendMessage(GetParent(AHandle), WM_COMMAND, MakeWParam(GetWindowLong(AHandle, (int)GWL.GWL_ID), (int)ButtonControlMessages.BM_CLICK), AHandle); } public static IntPtr GetButtonHandle() { IntPtr ButtonHandle = FindWindow("#32770", null); IntPtr wndChild = IntPtr.Zero; if (ButtonHandle != IntPtr.Zero) { for (int i = 0; i < 3; i++) { wndChild = FindWindowEx(ButtonHandle, wndChild, "Button", null); } return wndChild; } return wndChild; } |
and the corresponding Pinvoke code.
the rest is the code of the main function, a small loop:
int count = 0; while (true) { count++; ClickButton(GetButtonHandle()); System.Threading.Thread.Sleep(1500); Console.WriteLine("Try to Click Button: " + count.ToString()); } |