Monday, December 29, 2014

UI Thread?

Hello,


I'm new to C#.


In my code, I'm using a While loop in my main. This made it so that the code launches without any UI.


How can I get it to launch with the UI and how do I change "maptimerlabel.Text" from another thread for example?


This is my code, if you could explain or edit the code for me I would be very happy.



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Magic;
using System.Threading;
using WindowsInput;

namespace Program
{
public partial class frmmain : Form
{
public frmmain()
{
InitializeComponent();
BlackMagic swr = new BlackMagic();
swr.OpenProcessAndThread(SProcess.GetProcessFromProcessName("Game.exe"));
uint timeraddress = 0x00286C60;


int[] click = new int[15] { 21750, 21916, 22083, 22166, 22250, 22416, 22583, 22749, 22833, 22916, 23000, 23083, 23249, 23416, 23500 };

int offset = 0;
int holdtime = 40;
int clickcounter = 0;
while (1 == 1)
{

int maptimer = swr.ReadInt(timeraddress);
maptimerlabel.Text = "Map Time: " + maptimer;
if (maptimer >= click[clickcounter] + offset)
{
InputSimulator.SimulateKeyDown(VirtualKeyCode.VK_N);
Thread.Sleep(holdtime);
clickcounter = clickcounter + 1;
InputSimulator.SimulateKeyUp(VirtualKeyCode.VK_N);
}
}
}


}
}








No comments:

Post a Comment