I have a visual basic 6 application that needs to get pictures from a particular website but the problem is that the users have to open the webpage on the browser and log in to the webpage then download the picture and upload it in the vb6 app. Is it possible to have the vb6 go to that webpage and log in and capture the screenshot and save it in a particular folder without opening the browser?
The url opens the login page by default and you have to log in first, to access the picture page, which we just have to take a screen shot and crop it.
Is this possible in pure VB6?
Here is some VERY generic code that will log you into a website. It is basically a matter of finding the controls in the browser document and filling in the correct values. Since you have provided no code to build on it's up to you to fill in all the correct values. This is using Microsoft Internet Controls to add a browser control to a form.
Private Sub Form_Load()
Dim i As Integer
WebBrowser1.Navigate ("http://URL of the page you want to go to")
Do While WebBrowser1.ReadyState <> READYSTATE_COMPLETE
DoEvents
Loop
If InStr(WebBrowser1.LocationURL, "http://targetwebsite/login.aspx") Then
On Error Resume Next
For i = 0 To WebBrowser1.Document.Forms(0).length - 1
' Uncommenting the MsgBox method will display the control names and help find the controls you are looking for
'MsgBox WebBrowser1.Document.Forms(0)(i).Type & ", " & WebBrowser1.Document.Forms(0)(i).Name
If WebBrowser1.Document.Forms(0)(i).Type = "text" Then
WebBrowser1.Document.Forms(0)(i).Value = "user name"
End If
If WebBrowser1.Document.Forms(0)(i).Type = "password" Then
WebBrowser1.Document.Forms(0)(i).Value = "user password"
End If
Next i
' now find and click the submit button
For i = 0 To WebBrowser1.Document.Forms(0).length - 1
If WebBrowser1.Document.Forms(0)(i).Type = "submit" Then
WebBrowser1.Document.Forms(0)(i).Click
End If
Next i
End If
' You should now be logged in and loading the page you want
End Sub
Related
I am trying to make a page that lets my admins read the MIRC Log files from our bot...I am having the hardest time trying to get this to work for some reason...i have taken bits and pieces of code to get what i have working...but it still either doesn't display at all OR after about 200 lines, it stops reading each line but instead make it one big mess of text...here is what i have for code
Protected Sub bView_Click(sender As Object, e As EventArgs) Handles bView.Click
Response.Write(Server.MapPath("~/mirc/logs/" & lbfiles.SelectedItem.Text))
lFileOut.Text = ""
Try
Dim FILENAME As String = Server.MapPath("~/mirc/logs/" & lbfiles.SelectedItem.Text)
Dim objStreamReader As StreamReader = New StreamReader(FILENAME, Encoding.UTF8)
Dim cont As String
Do
cont = objStreamReader.ReadLine()
lFileOut.Text = lFileOut.Text & cont & "<br>"
'Response.Write(cont)
Loop Until cont Is Nothing
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
Here is a test file i have been testing everything on...it just doesn't do anything nor does it throw any error...i am completely stumped on this one.
test file
Do this: go into your server, in your root folder make a new folder called whatever you want then go into your mIRC script goto tools/options/logging change directory to the new folder you made click save.. that way you or anyone you want to view all logs from your mIRC script can view by going to www.yoursite.net/foldername and it will show you the list of all logged things, status and room window conversations...
If you want to know how to code it so your opers can just have a clickable link in their remotes I can do that for you as well.... hope this helps
I made the rails app that parses one website. I wonder, whether it is possible to show the process of the parsing in a progress bar which will be shown on a main page(to start the process you need to click the button)? I think I need to use bootstrap for view of progress bar, but how to pass the process of execution itself into view of bar?
Edit:
The parser itself is situated in the model that stores result to the database after each step i. e. if parser detects first company and its data - save, then the second company and so on. The progress bar will show result based on information from database(I don't understand how to use ajax for this) and I really want to use bootstrap progress bar, not jquery bar.
My model-parser
class PrintingHouses < ActiveRecord::Base
require 'mechanize'
agent = Mechanize.new
page = agent.get('http://www.print-index.ru/default.aspx?p=84&gr=198')
sum=0
loop do
page.search('.goodname .goodname').each do |n|
link = Mechanize::Page::Link.new(n, agent, page)
new = link.click
name = new.search('#ctl00_ctl00_BaseCentralRegion_CentralRegion_lblGoodName h1')
address = new.search('.address')
phone = new.search('.phone')
email = new.search('.email')
website = new.search('.www')
PrintingHouses.create(name: name.text.center(100), address: address.text.strip,
phone: phone.text.strip, email: email.text.strip,
website: website.text.strip)
end
num = page.search('.goodname .goodname').count
sum=sum+num
break unless link = page.link_with(:text => " » " )
page = link.click
end
puts sum
end
This question is marked as a duplicate but I didn't find anything that could help me so please help.
The gem Progress Job looks promising for providing progress updates on background jobs. At this time it looks like it works with DelayedJob.
Background
I have an ASP.NET web application with a VB.NET back end. In this application users can create payment requests which must be approved by a manager before they are sent to accounts payable for further processing. Within my request page (the page where the user enters the request information) I have a button that links to a separate .aspx page which provides a print preview of the request. When the request is approved by all of the required approvers, I have a VB.NET function that contains a WebBrowser object that navigates to the print preview page behind the scenes and takes a snap shot of it, then saves it as a .tiff file to an internal file share which is then picked up by a internal process and imported into another internal application called OnBase to go through processing for accounts payable.
The Problem
My problem is that when the my function takes the snap shot of the print preview page, the saved tiff has a lower resolution than desired. In other words, it looks kind of crappy when it is viewed through OnBase and when it is printed out.
The Question
How do I increase the resolution of the generated .tiff file at the time that the snapshot of the webpage is generated?
The Code
Private Sub CaptureWebPage()
Try
Dim tiffFileName As String
tiffFileName = OnBasePath & "CheckRequest_" & CurrentRequestId & ".tiff"
Dim impersonateCode As New AliasAccount("TheUsername", "ThePassword")
impersonateCode.BeginImpersonation()
Dim browser As Windows.Forms.WebBrowser = New Windows.Forms.WebBrowser
browser.ScrollBarsEnabled = False
browser.ScriptErrorsSuppressed = True
browser.Navigate(OnBasePath & htmlFileName)
While browser.ReadyState <> Windows.Forms.WebBrowserReadyState.Complete
System.Windows.Forms.Application.DoEvents()
End While
System.Threading.Thread.Sleep(1500)
browser.ClientSize = New Size(950, 768)
Dim Height As Integer = browser.Document.Body.ScrollRectangle.Bottom
browser.ClientSize = New Size(950, Height)
Dim bmp As Bitmap = New Bitmap(browser.Bounds.Width, Height)
browser.DrawToBitmap(bmp, browser.Bounds)
If File.Exists(tiffFileName) Then
File.Delete(tiffFileName)
End If
If File.Exists(OnBasePath & htmlFileName) Then
File.Delete(OnBasePath & htmlFileName)
End If
bmp.Save(tiffFileName.ToString(), ImageFormat.Tiff)
bmp.Dispose()
impersonateCode.EndImpersonation()
Catch ex As Exception
Throw
End Try
End Sub
Additional Information
I have tried to use the .SetResolution method of my bitmap object, but it doesn't actually change the resolution of the generated .tiff file. I have tried to Google this numerous times find a solution, but haven't found anything useful.
Thanks In Advance
Screen "resolution" is much lower than print "resolution". Typically desktop monitors are around 100ppi, where a normal printer on a desk might be 600dpi.
The only suggestion I have for getting a higher resolution rendering of the web page would be configure what is grabbing the screenshot to use a resolution 3x what you are using now, and then set its zoom to 300%. Text elements and vector graphics will be rendered smoothly. Images will still be their web resolutions, and you may even lose image quality through interpolation when sizing up.
You could try and print the page to a virtual print driver in PDF format. I have found OnBase sometimes does strange things with image files, it doesn't like colour or grey scale TIFFs. Instead use JPEG for colour / grey scale.
I have a requirement that is :--
On click of ‘Logout’ link, popup message “This will terminate the session and close the browser. Do you want to continue?” with Yes and No buttons. On click of ‘Yes’, session should be terminated in IIS server and current tab of browser closed.
To implement this I have writen below piece of code but I dont know how to terminate the session on IIS
<script language="vbscript">
Function OnClickLogout()
dim Answer, msg
Msg = "This will terminate the session and close the browser. Do you want to continue?"
Answer = MsgBox(Msg, vbYesNo + vbCritical, "Error")
if Answer = vbYes then
window.close
else
'Retrun to the previous page
end if
End Function
</script>
Could anyone please suggest me how to do this in vbscript. My website is in ASP but its a legacy application so I have to do the code!!!
Couldn't you simply use JavaScript? We us it all the time at work in our ASP Classic projects. Something like that to start off:
function DeleteProductGroup(){
var r=confirm("Are you sure you want to delete this product group?");
if (r==true){//here goes the code if user presses YES
}
else{//here goes the code if user presses NO
}
}
I have a requirement when a user clicks a specific arrangement of radio buttons to run a series of vbscripts (and soon Perl scripts).
I have all of the vbscripts stored server side, they do not need to be on the remote system to run. Oh yes, the scripts are gathering information on remote system in our intranet.
What would be the best way. Currently I have this to run just one script, not multiple...should I keep this or dispose of this idea.
Protected Sub windowsScript(ByVal COMPUTERNAME As String)
' Create an array to store VBScript results
Dim winVariables(1) As String
Dim filePath As String = COMPUTERNAME & "\C$\Windows\somefile.txt"
'Execute PsExec on script
runPsExec(COMPUTERNAME, "systemInfo.vbs", 1)
'Import data from text file into variables
textRead(filePath, winVariables)
System.Threading.Thread.Sleep(1000)
'Delete the file on server - we don't need it anymore
runPsExec(COMPUTERNAME, "systemInfo.vbs", 2)
MsgBox("Windows OS: " & winVariables(0).ToString())
MsgBox("Service Pack: " & winVariables(1).ToString())
End Sub
Also, it is hard to see here because I do have another function "textRead" but what is going on is this particular script is stored client side and the vbscript it outputting to a text file. textRead will read the variable and send a text file back to the server to read it.
This is definitely not what I want to do.
I want to be a little more dynamic, plus with my new scripts...they don't need to be on the client at all.
Any help would be appreciated :)
I'm thinking of making some type of While loop, not sure if that would work.
It's kind of strange to do this through the browser. In my company we collect systeminfo at logontime with a vbscript logonscript and add the result to a logfile which we can access through a webapp to do research. Occasionally when the need rises we run a specific script to gather more data or change some system setting through windows SCCM.
If the goal is to provide the user with info about his system there are some good utilities around which can be run locally (but from a location on a server share).
EDIT
a simple way to start multiple processes
dim scripts_to_run, script
const COMPUTERNAME = 0, SCRIPTNAME = 1, EXTRA_PARAMS = 2
scripts_to_run = Array(_
Array("computer1","script1.vbs",1),_
Array("computer2","script1.vbs",0),_
Array("computer3","script3.vbs",3)_
)
for each script in scripts_to_run
runPsExec script(COMPUTERNAME), script(SCRIPTNAME), script(EXTRA_PARAMS)
runPsExec join(script,",")
next
sub runPsExec(p1, p2, p3)
'here coms your code shat runs the script
wscript.echo p1 & p2 & p3
end sub
or a shorter version
dim scripts_to_run, aArgs
scripts_to_run = Array(_
Array("computer1","script1.vbs",1),_
Array("computer2","script1.vbs",0),_
Array("computer3","script3.vbs",3)_
)
for each aArgs in scripts_to_run
runPsExec aArgs
next
sub runPsExec(aArgs)
'here coms your code shat runs the script
wscript.echo aArgs(0) & aArgs(1) & aArgs(2)
end sub