Message from webpage automation. Sendkey = NO! API?

msnyder1112

New member
Joined
Feb 5, 2015
Messages
3
Programming Experience
Beginner
Hey guys. I'm new to this forum. I'm desperate. I am a beginner with programming so please bear with me. I do have basic knowledge... I think! Lol.

I am writing a program to make my job easier. Basically, every morning I have to delete 14,000 - 15,000 records from an internal website that we use to upload data. The webpage shows 50 at a time so this can get pretty boring.
So far, my program points to the webpage, "checks all" and clicks delete. Now I get a message box that asks if I am sure I want to delete. I want it to automatically click "OK".
I used sendkey and it worked for a while but for some odd reason it stopped working.
Here's the code I currently have.
I am using Visual Studio Express 2013

VB.NET:
Public Class Form1    Dim oInputs As Object
    Dim oWShell As Object


    Private Sub btndel_Click(sender As Object, e As EventArgs) Handles btndel.Click
        With CreateObject("InternetExplorer.Application")
            .visible = True
            .Navigate(txturl.Text)
            Threading.Thread.Sleep(3000)
            oInputs = .document.getElementsbytagname("a")
            For Each elm In oInputs
                If InStr(elm.innertext, "(Un)Check All") > 0 Then
                    elm.click()
                    Exit For
                End If
            Next
            For Each elm In oInputs
                If InStr(elm.innertext, "Delete") > 0 Then
                    elm.click()
                    Exit For
                End If
            Next
            Do While .busy Or .readystate <> 4
                Threading.Thread.Sleep(2000)
            Loop
        End With
        Threading.Thread.Sleep(5000)


        oWShell = CreateObject("wscript.shell")
        Do Until oWShell.AppActivate("Message from webpage")
            Threading.Thread.Sleep(2000)
        Loop
        Dim objShell = CreateObject("WScript.Shell")
        Dim Success = objShell.AppActivate("Message from webpage")


        Do Until Success = True
            Threading.Thread.Sleep(1000)
            Success = objShell.AppActivate("Message from webpage")
        Loop


        Application.DoEvents()
        AppActivate("Message from webpage")
        SendKeys.Send("{ENTER}")


    End Sub
End Class
 
If you have privileged access to the server and the underlying database or files things would be much faster and simpler... Even if you do not have that access remotely, if you can install a task on the server it would be a LOT better than automating web pages.

Otherwise look at a web testing package like Selenium . They have all the tools you need to automate web pages...
 
Hi Herman. Thank you for the quick response. Go figure, I do not have access to the database and I am not able to install a task to delete all the files. We do have a standard "delete all files" option, but it isn't trustworthy. It schedules the records to be deleted and doesn't always work. It's a terrible system we have and I'm just trying to simplify things until a better solution comes.

I checked out Selenium and it looks like something that interests me, but right now I don't have the time nor resources to download, learn, play around with, etc.

I'm checking into API, which I have seen a lot of people suggest in an instance like this.
If anyone is familiar with API's please help me.

Thanks!
 
Selenium IS an API, a web-testing API.

It is free and open-source if you were wondering... In your case all you would need is the Selenium FireFox plugin to be able to write some script to do what you want. It's as simple as pressing record, do the manipulation, then adjust the script code produced, add conditionals, etc...
 
Back
Top