I'm trying to use powershell to automate and parse a website.
Everything works great until I "click" on a link and it opens in a new window.
How can I access that window so I can parse it?
$ie = New-Object -com Internetexplorer.application
$ie.Visible= $true
$ie.Navigate("http:/.....")
....
# find a link...
$link.click(); # a new popup window open up.
# how can I get access to the new popup window?
Thank you!
Try using the NewWindow3 event so that you can grab the object when it gets created.
Raised when a new window is to be created. Extends NewWindow2 with additional information about the new window.
Syntax
Private Sub object_NewWindow3( _
ByRef ppDisp As Object, _
ByRef Cancel As Boolean, _
ByVal dwFlags As Long, _
ByVal bstrUrlContext As String, _
ByVal bstrUrl As String)
Related
I want to print Notes-documents directly to an pdf-printer. The documents are selected in a view. I do not want to open the printer dialog form.
Using the "NotesUIView.Print"- method works in principle, however, the generated pdf-documents sometimes look not exactly like the Notes-documents (especially regarding tables).
Therefore I tried to use the "NotesUIDocument.Print" - method:
Option Public
Option Explicit
Const pdfAppName = "PDF-XChange Standard"
Dim dc As NotesDocumentCollection
Dim curDoc As NotesDocument
Dim uidoc As NotesUIDocument
Dim workspace As New NotesUIWorkspace
...
Set dc = curDB.UnprocessedDocuments
...
Set curdoc = dc.GetFirstDocument
Call workspace.EditDocument(False,curDoc)
Set uidoc = workspace.Currentdocument
Call uidoc.Print(1,0,0,False,pdfAppName)
...
Dispite the first parameter in "uidoc.print" is set to "1" the printer dialog form opens. In the printer dialog form the printer "PDF-XChange Standard" is selected correctly. Selecting the "OK"-Button prints the document correctly.
Many thanks in advance for hints.
I would like to print directly to an attached label printer without showing the print dialog.
I have searched to see if such a thing is possible but it seems it is not. So, I thought I would ask here in case someone knows a way to do it.
You have to save the Printer SetupString. Then the next time you go to print use that SetupString to initialize the PrinterSetup object. See actual code copied from working project below:
'Now print the mail barcode
dim ps as PrinterSetup
dim page as Graphics
ps = LabelPrinter //See below
if ps<>nil then
page = OpenPrinter(ps)
if page<>nil then
//send stuff to the printer here
Public Function LabelPrinter() as PrinterSetup
if gLabelSetup<>"" then //gLabelSetup is saved in preferences
dim ps as new PrinterSetup
ps.SetupString = gLabelSetup
return ps
else
return nil
end if
End Function
I'd like to get the keyboard input of a user in Websharper for an entire page (or whatever gets me closest), and I can't see any nice way of doing this.
I've attempted something along the lines of
JQuery.Of("document").Keyup(fun _ _ -> Window.Self.Alert("boo"))
But I keep running into a lot of NotImplementedExceptions. Are these really not implemented? Or am I hitting some weird edge case because I'm going against the grain?
Update:
I've got version 2.4.85.235 installed from nuget, if that means anything to anyone. I'm also using VS 2012.
I've also tested with a fresh sitelets templated site from VS 2010, and I see the same thing. I've installed the latest package from the WebSharper site.
Make sure that you're not calling client-side methods that are not implemented on the server. If that's the case separate client and server code, display the involved elements and invoke the JavaScript through the Web Control mechanism and use "html", "body" or Dom.Document.Current as a selector. Below is a sample for displaying an alert every time the enter key is pressed:
module Client =
open IntelliFactory.WebSharper
open IntelliFactory.WebSharper.Html
open IntelliFactory.WebSharper.JQuery
[<JavaScriptAttribute>]
let paragraph () =
P [Text "Press the Enter key to display an alert box."]
|>! OnAfterRender (fun x ->
JQuery.Of("html").Keydown(fun _ event ->
match event.Which with
| 13 -> JavaScript.Alert "Enter key was pressed."
| _ -> ()).Ignore)
type ParagraphViewer () =
inherit Web.Control()
[<JavaScript>]
override this.Body = paragraph () :> _
I have a requirement where I need to access a chart generated in one session, in another.
To explain, process A generates some HTML which includes a chart with image url /ChartImg.axd?i=chart_0_0.png&g=a40f233f40fb4995b737d284f83ab1b7
I have deleteAfterServicing=false and dir=c:\, and if I look in c:\ chart_0_0.png is there.
Now process B (therefore running in its own session) comes along an opens the HTML file, the chart 404s because (it seems) the image handler will only allow access to that chart from the session it was created in.
Is there any way to disable this behaviour?
I look forward to your response
Karl
Ok so I solved it by doing the following:
Public Overrides Sub RenderControl(writer As System.Web.UI.HtmlTextWriter)
If Me.RenderToFile Then
'Save it to a file first
Me.SaveImage(HttpContext.Current.Server.MapPath(RenderToFileLocation),
ChartImageFormat.Png)
'Return the image urn
writer.Write("<img src=""" & Url.Content(ConfigurationManager.AppSettings("ChartFilePath")) & "?c=" & Url.Content(RenderToFileLocation) & """ />")
Else
MyBase.RenderControl(writer)
End If
End Sub
Then from there a created a simple .net MVC handler which returned the file and deleted it
Function Index(ByVal c As String) As ActionResult
Dim dir = Server.MapPath(ConfigurationManager.AppSettings("ChartFilePath"))
Dim filepath = System.IO.Path.Combine(dir, c)
Index = MyBase.File(filepath, "image/png")
'Delete the file
Try
IO.File.Delete(filepath)
Catch ex As Exception
End Try
End Function
I have written an Excel COM Add-In in C++ for automation of Excel with VBA. It contains an own dialog showing some general informations about the Add-In.
Now i create a button in Excel that opens the dialog. Leaving the dialog with the escape key leads to an Excel message that the script is being interrupted instead of just closing the dialog. I could suppress the interruption message with:
Application.EnableCancelKey = xlDisabled
But that seems not to be the solution as the script can not be interrupted any more.
Here is an example how i use VBA to open the dialog:
Private Sub ShowAboutDialog_Click()
Dim oComAddIn As COMAddIn
Set oComAddIn = Application.COMAddIns.Item("MyComAddIn.Example")
oComAddIn.Connect = True
Call oComAddIn.Object.ShowAboutDlg
End Sub
My guess is that the problem is somewhere in the message handler of the dialog:
INT_PTR CALLBACK CAboutDialog::AboutDlg(
HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
...
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
// Here, the ESCAPE key should also be trapped?
EndDialog(hwndDlg, LOWORD(wParam));
return TRUE;
}
...
}
return FALSE;
}
The Dialog is created with:
DialogBox(g_hModule, MAKEINTRESOURCE(IDD_ABOUT), hWndParent, (DLGPROC)AboutDlg)
Thanks a lot!
Dialogs should return their exit status to the calling routine rather than allowing to terminate code execution. So I suggest you to
convert your ShowAboutDlg from a Sub() to a Function()
returning a constant out of the VbMsgBoxResult Enum set (avoid hardcoding!)
trap the ESC key in your dialog and return a VbCancel (or VbAbort)
Good luck
MikeD