public static void Click(Process_Object procObj, Program_Profile progProf) { //Adapted only for 64 bit systems? //TODO: Make alternate code for 32bit systems WindowsStructs.SetForegroundWindow(procObj.GetMWHandle()); UInt64 clickPoint = 0x0; clickPoint = clickPoint | (UInt32)(progProf.Get_OffsetY() + 5); clickPoint = clickPoint << 0x10; clickPoint = clickPoint | (UInt32)(progProf.Get_OffsetX() + 5); WindowsStructs.SendMessage(procObj.GetMWHandle(), WindowsStructs.WM_LBUTTONDOWN, (IntPtr)WindowsStructs.MK_LBUTTON, (IntPtr)clickPoint); WindowsStructs.SendMessage(procObj.GetMWHandle(), WindowsStructs.WM_LBUTTONUP, (IntPtr)WindowsStructs.MK_LBUTTON, (IntPtr)clickPoint); //WindowsStructs.SendMessage(procObj.GetMWHandle(), WindowsStructs.WM_LBUTTONDOWN, WindowsStructs.MK_LBUTTON, (UInt32)((progProf.Get_LengthY() << 0x10) | progProf.Get_LengthX())); //WindowsStructs.SendMessage(procObj.GetMWHandle(), WindowsStructs.WM_LBUTTONUP, WindowsStructs.MK_LBUTTON, (UInt32)((progProf.Get_LengthY() << 0x10) | progProf.Get_LengthX())); }
public static Bitmap Take_Snapshot_Process(Process_Object proc, Program_Profile prof) { return(Take_Snapshot_Process(proc, prof.Get_OffsetX(), prof.Get_OffsetY(), prof.Get_LengthX(), prof.Get_LengthY())); }
//Test Process Close() //cn_process.Close();// //End Test //Diagnostic Window Test //SnapshotHelper.Print_Process_Window_Dimensions(cn_process); //End Test //Test Launcher Copy and Compare //Bitmap screen = SnapshotHelper.Take_Snapshot_Process(cn_process, 491, 436, 183, 41); //Bitmap refScreen = new Bitmap("reference.PNG"); //Bitmap queue_img = new Bitmap("join.bmp"); //Image_Manipulator.Compare_Image_Section(refScreen, queue_img, new Rectangle(491, 436, 183, 41), new Rectangle(0, 0, queue_img.Width, queue_img.Height)); //End Test //Loop for test comparison of live results //TODO: Add listener for Lol.exe to know when it closes and resume scanning. Assuming user will want to queue for another game //TODO: Add listener to LolClient.exe to when the user closes it, shutdown the app. Currently working prototype //TODO: Add implementation for normal blind pick //TODO: Bug starting program before league starts endless Error Loop - workaround repress button //Connect to phone //TODO: On activation of queue pop, move process window to active, so that click corresponds to the proper progam // Server_Socket.StartListening(); //end connect // COMMENTED OUT PROGRAM CODE FOR OTHER TESTS public static void Analyze_Process(Process_Object cn_process) { //Console.Write(Program_Importer.programs.ElementAt(choice).ToString()); bool queue_popped = false; //CHANGE TO FALSE OR BROKEN bool is_active = true; bool main_game_launched = false; //Need to actually start a game to get name of the process int counter = 0; Program_Profile chosen = Program_Importer.programs.ElementAt(choice); Bitmap screen = null; // Bitmap queue_img = new Bitmap("join.bmp"); // Can Cache image in order to increase perfomance, image is also hardcoded byte[,,] pixelValues = Image_Manipulator.Store_Image_Value(chosen.Get_Image(), Image_Manipulator.DEFAULT_RESIZE); while (!queue_popped && is_active) { is_active = cn_process.IsOpen(); if (is_active == false) { Console.Clear(); Console.Write("Process has closed. Closing Program..."); return; } try { screen = SnapshotHelper.Take_Snapshot_Process(cn_process, chosen); // if (Image_Manipulator.Compare_Image(Program_Importer.programs.ElementAt(choice).Get_Image(), screen) && Program_Importer.programs.ElementAt(choice).Get_MatchMode()) queue_popped = true; if (Image_Manipulator.Compare_Image(pixelValues, screen, Image_Manipulator.DEFAULT_RESIZE) && chosen.Get_MatchMode()) { queue_popped = true; } else { queue_popped = false; } } catch (Exception e) { Console.Write("\nError: " + e.ToString()); } //Console.Write(queue_popped); System.Threading.Thread.Sleep(250); if (counter == 100) { GC.Collect(); counter = 0; } counter++; } if (chosen.Get_AutoStatus()) { Process_Object.Click(cn_process, chosen); } //if (queue_popped == true) Server_Socket.SendSignal("Popped"); //else Server_Socket.SendSignal("Closed"); //End Test //Socket Tests //Server_Socket.StartListening(); //End Socket Tests //Close connection //Server_Socket.GoDeaf(); //End Close Console.Write("\nClick to Restart"); //Console.Clear(); }
public static void Import_Programs() { Console.WriteLine("Importing programs"); FileStream read = File.OpenRead("data.txt"); string contentsS; int[] dimensions; byte[] contents = new byte[read.Length]; byte temp; bool detected_token = false; int x = 0; int EOF; string[] sections; while (x < read.Length) { EOF = read.ReadByte(); temp = (byte)EOF; if (EOF == -1) { break; } else if (temp != '"' && detected_token == false) { contents[x] = temp; x++; } else if (temp == '"' && detected_token == true) { detected_token = false; } else if (temp == '"' && detected_token == false) { detected_token = true; } } read.Close(); read.Dispose(); //TODO: Change to JSON, style loading contentsS = ASCIIEncoding.ASCII.GetString(contents); //contentsS = contentsS.Replace(" ", ""); contentsS = contentsS.Replace("\n", ""); sections = contentsS.Split(new char[2] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); //TODO: Last program isn't importing the autoclick property properly x = 0; while (x < sections.Length) { sections[x + 4] = sections[x + 4].Replace(" ", ""); dimensions = Image_Manipulator.Get_Image_Dimensions(sections[x + 4]); Program_Profile profile = new Program_Profile(Int32.Parse(sections[x + 2]), Int32.Parse(sections[x + 3]), dimensions[0], dimensions[1], sections[x + 4]); profile.Set_Name(sections[x + 1].Replace("\r", "").Replace("\n", "").Replace(" ", "")); //\r causing problems? profile.Set_DisplayName(sections[x].Replace("\r", "")); if (sections[x + 5].Replace(" ", "").Replace("\n", "").Replace("\r", "").Equals("yes")) { profile.Set_MatchMode(true); } else { profile.Set_MatchMode(false); } if (sections[x + 6].Replace(" ", "").Replace("\n", "").Replace("\r", "").Equals("yes")) { profile.Set_AutoStatus(true); } else { profile.Set_AutoStatus(false); } if (profile != null) { programs.Add(profile); } x += 7; } }