-1

I want to login to kingdoms.com with a web browser. But the login screen is in an iframe tag, so I can't reach the email, password textboxes and login button. please help me.

HtmlWindowCollection iframes = wb.Document.Window.Frames;

HtmlWindow iframe = wb.Document.Window.Frames[2];

HtmlElement element = iframe.Document.GetElementsByTagName("input")[0];
sao
  • 1,835
  • 6
  • 21
  • 40

1 Answers1

0

Taken from here:

wb.Document.GetElementById("idName").SetAttribute("value") = "ddddd" ;

Edit:

Then figure out where to point your Cursor and position it using this code

Cursor.Position = wb.PointToScreen(new Point(X_Coord, Y_Coord));

Then perform a Mouse click using code from this answer by JohnForDummies

[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
        public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);

        private const int MOUSEEVENTF_LEFTDOWN = 0x02;
        private const int MOUSEEVENTF_LEFTUP = 0x04;
        private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
        private const int MOUSEEVENTF_RIGHTUP = 0x10;

        public static void DoMouseClick()
        {
            mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
        }

You can simulate keyboard presses using code from here by Rajesh

[DllImport("user32.dll")]
public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, uint dwExtraInfo);

const int VK_UP = 0x26; //up key
const int VK_DOWN = 0x28;  //down key
const int VK_LEFT = 0x25;
const int VK_RIGHT = 0x27;
const uint KEYEVENTF_KEYUP = 0x0002;
const uint KEYEVENTF_EXTENDEDKEY = 0x0001;
int press()
{
    //Press the key
    keybd_event((byte)VK_UP, 0, KEYEVENTF_EXTENDEDKEY | 0, 0);
    return 0;
}
demoncrate
  • 390
  • 2
  • 14