|
Yes. Go and ask your question in QA or, better still, ask it on the forum of the Youtube video you followed in the first place and leave this forum for real C# questions.
This space for rent
|
|
|
|
|
Hello,
Currently I am automating website in Internet Explorer. Due to compatible issue in different IE's, I am planning to automate in Google Chrome.
I have searched on internet for that, many have suggested that Selenium is the best solution. But in selenium I will get events only if events are created using code. If user manually navigate to some other URL then we cannot manage it.
Mainly I want the same working as there in Internet Explorer. For example, 'browser control', 'beforenavigate' , 'documentcomplete' etc.
What is the best working method to website automation in Google Chrome using C# ( With all functions which can be done in Internet Explorer)?
Please help.
modified 9-May-16 8:08am.
|
|
|
|
|
|
Currently I am having vb6 project for Website automation in Internet Explorer. So I thought It would be better if I migrate to vb.net or C#.
|
|
|
|
|
There is nothing I can see in your question realated to either VB.NET or C#, which is why I suggested the Web development forum.
|
|
|
|
|
|
in reports i have set a property to display on last page
but it is not displaying on all pages except first page.i have page footer and page headter.i have to display page footer on last page.can you please share the answers.thank you
|
|
|
|
|
Hello friends,
I'm working on a keyboard application for a small community. Their alphabets are as shown below.
Basically, the application will allow users to either type on the pc keyboard, or the virtual onScreen keys.
It should be noted that their alphabet do not have letter Q, F, X, Z and this will be replaced with Unicode chars.
I've managed to get the onScreen working using the SendKeys.send() method of C#.
However, I'm having trouble getting this working with keyboard input using KeyDown method.
When someone type Q, I wanted Unicode character say "Ɣ" to appear, and not the letter "Q".
A partial part of my code is as below. The keyDown event doesn't seem to fire at all.
Appreciate any help please.
Alphabets
Quote: Quote: Majuscules
A A̱ Ä B C D Dh E E̱ Ë Ɛ Ɛ̱ Ɛ̈ G Ɣ H I I̱ J
K L M N Ŋ Nh Ny O O̱ Ö Ɔ Ɔ̱ P R T Th U W Y
Minuscules
a a̱ ä b c d dh e e̱ ë ɛ ɛ̱ ɛ̈ g ɣ h i i̱ j
k l m n ŋ nh ny o o̱ ö ɔ ɔ̱ p r t th u w y
protected override CreateParams CreateParams
{
get
{
CreateParams param = base.CreateParams;
param.ExStyle |=0x08000000;
return param;
}
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Q:
SendKeys.Send("Ɣ");
break;
}
}
|
|
|
|
|
As I recall, the KeyDown event is sent to the control which currently has the keyboard focus. That is quite likely not your form. You may need to attach your handler to the KeyDown events of multiple controls to achieve your aim, or otherwise ensure that focus is on the control you choose.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Peter, thanks so much for your response.
That seems to be my problem at the moment.
How do I do that please?
Thanks,
dotComex.
|
|
|
|
|
Try setting the Form.KeyPreview property to true - if you don't, then the other controls get "first dibs" on the keyboard data.
If that doesn't work, then override the Form ProcessCmdKey method - you should be able to detect it there.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hey buddy! Thanks.
Here is what I have tried. It's not working though except that it sends Ö and close the program. However, when I comment out this.Close(), the program does not put the above character on ms word. Is there anything I'm not doing right? I intent to use switch & cases if I can get it working this way.
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Escape)
{
this.Close();
SendKeys.Send("Ö");
return true;
}
else
{
return base.ProcessCmdKey(ref msg, keyData);
}
}
|
|
|
|
|
You aren't sending anything to Word - you are sending it to your application...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hello OriginalGriff,
My intention is to send something to applications such as word, notepad etc. etc.
In my code, i have the SendKeys.Send() to send out relevant to the above applications. I'm not sure if it's right in this case, but it works for sending characters when buttons are clicked.
Here below are the main methods. What should I really do here? How should I send it to the Ms Word please?
protected override CreateParams CreateParams
{
get
{
CreateParams param = base.CreateParams;
param.ExStyle |=0x08000000;
return param;
}
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
switch (keyData)
{
case Keys.Q:
SendKeys.Send("Ɣ");
break;
}
return base.ProcessCmdKey(ref msg, keyData);
}
modified 8-May-16 6:08am.
|
|
|
|
|
SendKeys sends to the active application - which if your app is receiving the keyboard input is your app, not Word or Notepad.
Providing an onscreen keyboard that "interfaces" between the user and any other app is a much more complex job - and not one I have any experience with. I suspect that you will need to look at Global Hooking to "preview" the keyboard and intercept things, which is not a job for the faint hearted (get it slightly wrong, and your dev system will become very unstable).
I'd be tempted to look at "custom" keyboard layouts instead of hooking: The Microsoft Keyboard Layout Creator[^]
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
With your link, I can see a whole lot of pranks in the offing.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
You know you have a low and crude sense of humour!
I feels sorry for the next bloke who does not lock his PC before dissappearing out the door
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi, I finally got something working with keyboard Hooks. However, now both unicode character and the key value of the pressed are being sent. For example, when I pressed Q, I expect to see Ɣ on word, notepad etc. However, I'm getting both i.e. QƔ at the moment. How should I remove the Q and display only the sent character?
private void Form1_Load(object sender, EventArgs e)
{
ghook = new GlobalKeyboardHook();
ghook.KeyDown +=new KeyEventHandler(ghook_KeyDown);
foreach (Keys key in Enum.GetValues(typeof(Keys)))
ghook.HookedKeys.Add(key);
ghook.hook();
}
private void ghook_KeyDown(object sender, KeyEventArgs e)
{
textBox1.Text += ((char)e.KeyValue).ToString();
processKeyPressed((char)(e.KeyCode));
if((char)(e.KeyCode)=='Q')
SendKeys.Send("Ɣ");
}
|
|
|
|
|
I thank you for your response, Original.
I wish we could get this working.
Still believe someone out there would help.
Thanks.
|
|
|
|
|
|
So I basically have a Complex Matrix class like so:
public struct ComplexMatrix
{
private int Rows;
private int Cols;
private Complex[,] matrix;
public ComplexMatrix(int Rows, int Cols)
{
this.Rows = Rows;
this.Cols = Cols;
Complex[,] temp = new Complex[Rows, Cols];
this.matrix = temp;
for (int i = 0; i <= Rows - 1; i++)
{
for (int j = 0; j <= Cols - 1; j++)
{
matrix[i, j] = new Complex(0, 0);
}
}
}
public Complex this[int Row, int Col]
{
get { return matrix[Row, Col]; }
set { matrix[Row, Col] = value;}
}
...
However, Im a bit lazy so I would really like to set matrix items as follows:
MyMatrix[1, 1] = new Complex(1, 0);
MyMatrix[0, 1] = 1;
MyMatrix[1, 0] = 5d;
But I found no easy way of doing this. I basically want the setter of the property to be able to take an object, but the get function will always return a Complex.
I could of curse do this:
public object this[int Row, int Col]
{
get { return matrix[Row, Col]; }
set
{
if (value is Complex)
{
matrix[Row, Col] = (Complex)value;
}
else if (value is double)
{
matrix[Row, Col] = new Complex((double)value, 0);
}
else if (value is int)
{
matrix[Row, Col] = new Complex((double)((int)value), 0);
}
else
{
throw new NotSupportedException("Not supported");
}
}
}
But that is really cumbersome when you want to get the value. Is there any tricks I could use to make this work properly?
|
|
|
|
|
I think I need some Coffee here. The complex class takes care of that for me 
|
|
|
|
|
Just beat me. I was going to suggest looking at Complex constructors taking other numeric types and promoting.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
I don't know if this type of structure (using a List of Lists instead of an Array) is relevant to your concerns, it's something I experimented with some time ago:
public class ComplexMatrix : List<List<Complex>>
{
public ComplexMatrix() { }
public ComplexMatrix(List<List<Complex>> list)
{
foreach(var lst in list) this.Add(lst);
}
public ComplexMatrix(IEnumerable<IEnumerable<Complex>> lstenum)
{
foreach (var lst in lstenum.ToList())
{
this.Add(lst.ToList());
}
}
public ComplexMatrix(int rows, int cols)
{
List<Complex> complexrow;
for (int i = 0; i < rows; i++)
{
complexrow = new List<Complex>(cols);
this.Add(complexrow);
for (int j = 0; j < cols; j++)
{
complexrow.Add(0.0d);
}
}
}
public Complex this[int row, int col]
{
set { this[row][col] = value; }
get { return this[row][col]; }
}
public void SetValue(int row, int col, double real, double imaginary)
{
this[row][col] = new Complex(real, imaginary);
}
} Sample use:
public void Test1()
{
var repeated1 = Enumerable.Repeat(Enumerable.Repeat(new Complex(1, 1), 5), 5);
var repeated2 = Enumerable.Repeat(Enumerable.Range(1, 6).Select(i => new Complex(i,i)), 6);
ComplexMatrix cmatrix0 = new ComplexMatrix(repeated1);
ComplexMatrix cmatrix1 = new ComplexMatrix(repeated2);
ComplexMatrix cmatrix2 = new ComplexMatrix(4,4);
cmatrix2.SetValue(0,0, 34.5, 666.4);
cmatrix2[2,2] = 4.0;
Complex c22 = cmatrix2[2,2];
ComplexMatrix cmatrix3 = new ComplexMatrix
{
{Enumerable.Repeat(new Complex(0.0,0.0), 2).ToList()},
{Enumerable.Repeat(new Complex(0.0,0.0), 2).ToList()}
};
cmatrix3[1, 1] = new Complex(3.4, 45.66);
Complex cmplx = cmatrix3[1, 1];
} Other than an interesting experiment in self-education re Enumerable.Repeat, Enumerable.Range, auto-initializers, and Indexers, etc.: meaning of-it-all is left up to you
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
It's a nice solution, although I prefer the Matlab coding style more, but that seems a bit cumbersome to implement in C#, like so:
var MyMatrix = [1,0,0 ;
0,1,0 ;
0,0,1]
Although I could use my previus developed code to do so:
Evaluate Complex and Real Math Calculator[^]
|
|
|
|
|