|
Luc is quite right, Thread.Sleep won't help.
Instead, set up a class level Timer, with a (say) 1/10th second interval. Use a counter in the Timer.Tick event to allow your five seconds to elapse, and then continue your processing.
The other solution is as Luc says to move your processing code onto a separate thread, which you can Sleep without affecting the GUI. Remember that you can only access UI components from the GUI thread though!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Your first issue...
Use SendWait instead of Send...
System.Windows.Forms.SendKeys.SendWait("{PGDN}");
...consider putting this on a separate thread - as Luc has said you do not want to be making the UI wait for anything that does not complete almost instantly
Your navigate problem (second issue)...
add an event handler for the DocumentCompleted event of the WebBrowser control, then add second and third command in there...
WebBrowser wb = new WebBrowser();
wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
}
Don't vote my posts down just because you don't understand them - if you lack the superior intelligence that I possess then simply walk away
|
|
|
|
|
Hi
I'm using C# version 2008 on Win 7.
I am building an app and need to add a console page.
In delphi I would simply click new item and click on console.
With C# there is no reference to a console item to add.
Am I missing something or is this a limitation of the Express addition?
If so, is there a workaround?
Bob
|
|
|
|
|
No, there is no such thing as a "Console Page", not even in the Ultimate editions of Visual Studio.
If you want a console window, you'll have to create one yourself with, at the very least, AllocConsole, AttachConsole, FreeConsole Win32 functions.
|
|
|
|
|
Do you mean adding a console window to a non-console app? If so - this tip[^] may help.
|
|
|
|
|
It's Easy ,
Click Menu Project -> Project Properties -> Select Application Tab -> In Out Put Type ComboBox Select "Console Application"
Have a good day !
I know nothing , I know nothing ...
|
|
|
|
|
Hy experts
I need a little help here. Can anybody tell me how to select
a radio button from another program knowing the name,id or text of the radio button.
I want to automate internet explorer by checking the "First Name" radio button then pressing the "Send" button.
This is the code I'm using to set the focus to internet explorer:
using System;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
public class getWindow
{
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string IpClassName, string IpWindowName);
[DllImport("user32.dll")]
public static extern int SetForegroundWindow(IntPtr hWnd);
public static void Main(string[] args)
{
IntPtr iHandle = FindWindow(null, "Details - Windows Internet Explorer");
SetForegroundWindow(iHandle);
}
}
Any help would be appreciated.
Thank you in advance.
|
|
|
|
|
For some reason this will not work on my machine (Vista Enterprise sp2)
My messagebox display says "697538 seconds 697538 (this increments each time I run it but is always the same as the first number) seconds At second 0" .
When I run the second block of code it says "Last input ticks is 8 and idle ticks is 697791247 (this increments each time I run it) .
I got code example from this site, any idea as to why this won't work for me or what I am doing wrong? Thank you for reading.
http://www.geekpedia.com/tutorial210_Retrieving-the-Operating-System-Idle-Time-Uptime-and-Last-Input-Time.html[^]
public static void timerThread()
{
int timerCount = 0;
while (true)
{
MessageBox.Show("Start counting");
Thread.Sleep(10000);
int systemUptime = Environment.TickCount;
int LastInputTicks = 0;
int IdleTicks = 0;
LASTINPUTINFO LastInputInfo = new LASTINPUTINFO();
LastInputInfo.cbSize = (uint)Marshal.SizeOf(LastInputInfo);
LastInputInfo.dwTime = 0;
LastInputTicks = (int)LastInputInfo.dwTime;
IdleTicks = systemUptime - LastInputTicks;
string one = Convert.ToString(systemUptime / 1000) + " seconds";
string two = Convert.ToString(IdleTicks / 1000) + " seconds";
string three = "At second " + Convert.ToString(LastInputTicks / 1000);
MessageBox.Show(one + " " + two + " " + three);
Thread.Sleep(60000);
}
}
public static void timerThread()
{
int timerCount = 0;
int LastInputTicks = 0;
int IdleTicks = 0;
while (true)
{
MessageBox.Show("Start counting");
Thread.Sleep(10000);
int systemUptime = Environment.TickCount;
LASTINPUTINFO lastInPut = new LASTINPUTINFO();
lastInPut.dwTime = 0;
lastInPut.cbSize = (uint)Marshal.SizeOf(lastInPut);
lastInPut.dwTime = (uint)Marshal.SizeOf(lastInPut);
LastInputTicks = (int)lastInPut.dwTime;
IdleTicks = systemUptime - LastInputTicks;
MessageBox.Show("Last input ticks is " + LastInputTicks.ToString() + " and idle ticks is " + IdleTicks.ToString());
Thread.Sleep(60000);
}
}
|
|
|
|
|
Hi
Not sure about this, but where are you calling the GetLastInputInfo method to fill the lastInPut struct?
I are Troll
|
|
|
|
|
This simple test code works for me:
using System;
using System.Runtime.InteropServices;
using System.Timers;
namespace LastInputTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Press Enter to exit!");
using (Timer timer = new Timer(1000))
{
timer.AutoReset = true;
timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
timer.Start();
while (Console.ReadKey().Key != ConsoleKey.Enter)
{
Console.WriteLine();
}
}
}
static void timer_Elapsed(object sender, ElapsedEventArgs e)
{
LASTINPUTINFO lii = new LASTINPUTINFO();
lii.cbSize = LASTINPUTINFO.Size;
NativeMethods.GetLastInputInfo(ref lii);
Console.WriteLine(lii.dwTime);
}
}
internal static class NativeMethods
{
[DllImport("User32.dll", SetLastError = true)]
public static extern int GetLastInputInfo(ref LASTINPUTINFO lii);
}
[StructLayout(LayoutKind.Sequential)]
internal struct LASTINPUTINFO
{
public static readonly int Size = Marshal.SizeOf(typeof(LASTINPUTINFO));
public int cbSize;
public uint dwTime;
}
}
|
|
|
|
|
Thank you, I was able to get this to work
|
|
|
|
|
You're welcome
|
|
|
|
|
i have got some unicode values , i need to get the relevant string(letters) from that, i tried with .net encoding , but didn't find a way .
any idea how to get it.
thanx in advance.
|
|
|
|
|
There is nothing to encode, a Unicode value is already a letter so it can be displayed directly.
I must get a clever new signature for 2011.
|
|
|
|
|
prasadbuddhika wrote: i have got some unicode values
You mean an array with bytes that represent characters? Something like this[^];
String myText = System.Text.Encoding.Unicode.GetString(myBuffer);
I are Troll
|
|
|
|
|
Hi all,
I am currently employed by a company in Tampa, FL as a .NET Engineer with a primary role in WPF development.
We are currently searching for solid WPF candidates to bring on board. This company has been in the area for
30+ years, is a privately held family owned corporation, and has very low turnover. Pay and benefits are very competitive and work environment is great.
One prerequisite however is that you would need to live in Florida in or near Tampa i.e. no telecommuting.
If you're interested send me a message via Code Project.
Thanks,
Azad
|
|
|
|
|
Azad. You should ask this in the jobs board. The language specific forums is not the appropriate place for a question like this.
|
|
|
|
|
Hi Pete,
Could you point me to the jobs board - I looked but wasn't able to find a forum specific for jobs?
Thanks in advance,
Azad
|
|
|
|
|
Never mind. It looks like the jobs forum has been dropped. I apologise, but there used to be one. I guess it was canned by Chris at some point.
|
|
|
|
|
It's ironic. I got univoted for apologising for getting it wrong, but no vote for getting it wrong in the first place. I don't mind the univote, but it really should have been against the other post.
|
|
|
|
|
A new member or low rep one. My huge 8000 rep points was stronger than the univoter.
All the best,
Dan
|
|
|
|
|
Finally I can Vote your post Down !
I know nothing , I know nothing ...
|
|
|
|
|
Fair enough. As long as it's the right one you vote down.
|
|
|
|
|
Hmm: since there is no job board I suppose it is churlish to admonish you for posting this here; however it is still not good form to do so.
Lucky sod being in Tampa: what a great place to be: if you're offering transatlantic relocation, I'm in!
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|