I have a form with a webbrowser control and a Button (Find Button)
Below is the code for find button. Web browser control contains some text and when Find button is clicked the Find dialog opens. we use SendKeys "^f" to open the find dialog.
But find dialog does not open when I use the shortcut key of Find button(Alt+N).
Can someone please help on this?
Private Sub cmdFind_Click()
On Error GoTo ErrorHandler
WebBrowser1.SetFocus
WebBrowser1.Refresh2
SendKeys "^f"
Exit Sub
ErrorHandler:
End Sub
I don't know what's happening, but I suspect the key press is interfering with the SendKeys. Instead of worrying about how to make that work use the ExecWB method instead.
Private Sub cmdFind_Click()
On Error GoTo ErrorHandler
WebBrowser1.SetFocus
WebBrowser1.ExecWB OLECMDID_FIND, OLECMDEXECOPT_DODEFAULT
Exit Sub
ErrorHandler:
End Sub
Related
I got a weird dialog box in web application testing and I am just stuck. Dialog box is a conditional. It displays based on some data we enter. I just need to be able to click OK or press enter if it displays.
I clicked OK while recording. UFT does not add any code and nothing was added to OR. When I spy, it is not recognizing the ok and does not recognize the dialog box.
Manually I simply click OK or press enter to handle. Then I wrote the shell way to press enter. It does not do anything.
Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "{ENTER}"
Set WshShell = Nothing
How can I handle this dialog box using UFT?
you can you insight object to identify the "Ok" button. in case you are not able to spy it.
If this is the browser's regular dialog (javascript's alert) UFT supports dismissing it using Browser(...).HandleDialog.
If this works then it should also have recorded the HandleDialog step, if it doesn't it may be a defect in UFT, I suggest contacting MicroFocus's support.
I need to launch qtp.exe application using vbscipt, but im not getting the idea like how to click on certain button and how to open a particular test file using vbscript.
Please give me some hint or ideas.
You can do it easily by creating COM object of QTP.
Dim QTPObj,QTPTest
Set QTPObj=CreateObject("QuickTest.Application")
'Check if the application is not already Launched
If Not QTPObj.Launched then
QTPObj.Launch
end if
QTPObj.Visible=True
QTPObj.Open "D:\MyQTPTests\Test1001 1001" 'name of the start up script
Set QTPTest=QTPObj.Test
QTPTest.Run 'Run the Test
QTPTest.Close 'Close the Test
QTPObj.Quit 'Quit the QTP Application
I'm looking for an answer that will describe how to choose your own picture/object and use it as an icon in:
x = msgbox ("hey", icon 0,"title")
You can't use custom icons with the VBScript MsgBox function. You could build a custom dialog using the Internet Explorer COM object or an HTA, but that's about all you can do in VBScript.
I want to know how to make a screen locker using VB6. I have tried maximizing the frame but it still can be minimized. Then I have made the frame very large to fit the entire screen and made the frame irresizeable but someone can press Alt+F4 and close it. I also want the task manager to be disabled. So can anyone please help me?
This is probably not what you are trying to do but, you can lock windows by calling the WINAPI function LockWorkStation.
Option Explicit
Private Declare Function LockWorkStation Lib "User32" () As Boolean
Call it with
Call LockWorkStation
If you put the declare statement in a .bas module and call it from a form you will want to change the declare scope to Public. This function is supported in Windows XP and up, and Windows Server 2003 and up.
There is no absolute way to completely prevent the application from stopping. And can we know why you would do that?
Still, you can prevent the user from closing the application with the cancel parameter.
private sub Form_unload(Cancel as Integer)
Cancel = 1
End Sub
You can remove the exit button and make the form immovable and irresizeable. The you can call a batch file that will stop the task manager as :
:run
taskkill /f /im taskmgr.exe
goto run
This will continuously stop the task manager if it is opened.
I have util which at the end of it's work shows message box with notification and OK button. I run it under command line and would like to disable all message boxes that can break my process and require user reaction. Does any way to accoplish this task?
I would recommend just adding a --quiet command line switch instead, so users have better control over this kind of thing.
If you want to try to do it automatically, you can check the parent PID right when your app launches, and see if it's cmd.exe. Of course this is not 100% accurate because there are more scenarios where users don't want user interaction.
Well... you could use VBScript to automatically click or press ENTER on the messagebox. But you'll need to know the window name or number of the messagebox.
This code will bring focus to a Window called MESSAGEBOXNAME, and the press ENTER.
Set oShell = CreateObject("WScript.Shell")
oShell.AppActivate("MESSAGEBOXNAME")
WScript.Sleep 500
oShell.SendKeys "~"
Where MESSAGEBOXNAME is the Window Name of the MessageBox, that should be in the upper right corner of the messagebox.