Custmized icon for message box - vbscript

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.

Related

How to click ok on a dialog box using UFT

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.

Simulate "drag & drop" with Windows

How i can simulate "drag & drop" file with Windows Arguments on "object line" Object line in red rectangle (image example)
The shortcut properties dialog does not support drag & drop (neither files nor text as far as I can tell).
You could use UI Automation to change the text but just modifying the shortcut .lnk file is a better option.
From a scripting language you can set TargetPath and Arguments on a WshShortcut object or use the IShellLink interface in a real application.

Excel Mac's start-up behavior changes when add-in's Auto_Open has MsgBox

I'm using Excel for Mac 2011 (version 14.5.9) on OS X Yosemite (10.10.5). If I
start Excel from the Dock, it pops up the "Excel Workbook Gallery" dialog. If I start Excel by double-clicking an existing workbook in Finder, Excel opens the workbook as expected.
But these behaviors change if I install a simple add-in called "hello_world.xlam". The add-in has just one standard VBA module ("Module1") with only this macro:
Sub Auto_Open()
MsgBox "Hello World"
End Sub
The message box is displayed regardless of how Excel is started. However, Excel seems to forget its default start-up behavior. If I start Excel from the Dock, the "Excel Workbook Gallery" dialog is not displayed. That's a minor issue. The bigger issue is that if I start Excel by double-clicking a workbook in Finder, Excel does not open the workbook after the message box is closed.
If I disable this add-in (by going into Tools --> Adds-Ins, and unchecking the add-in), then the usual start-up behavior is restored.
Any workaround for this?
Discovered a work-around using an event procedure. Deleted the Module1 from the hello_world add-in. Added this procedure to the add-in's ThisWorkbook code module:
Private Sub Workbook_Open()
MsgBox "Hello World"
End Sub
The message box appears when Excel starts, and its start-up behavior remains unchanged.

Invoke 'Open' Dialog from Windows Desktop

Is there some way I can programmatically (in VBS) OR by using CMD/RUN open the 'Open' dialog that contains the places bar and a browser but without opening say notepad or MSpaint?
http://i.technet.microsoft.com/dynimg/IC354177.jpg
I'd like to use this on the desktop itself, it would be really cool if there was a DLL I can just use instead of having a VBS file but if not i'm sure its possible in VBS.
I'm busy searching where the actual open dialog box comes from, it should come from some DLL file somewhere.
I might even consider stopping the windows shell from opening all together and just using this open window as the shell on some computers.
Regards, Rocklore
What version of Windows are you on?
"UserAccounts.CommonDialog" was the way to do this in XP. But it no longer exists in Windows 7. You may be able to use some of the flags available for the BrowseForFolder() method to make it look like a file open dialog. See this page for an example.
XP Edit:
Here's an XP example using UserAccounts.CommonDialog.
With CreateObject("UserAccounts.CommonDialog")
.InitialDir = CreateObject("WScript.Shell").SpecialFolders("Desktop")
.Filter = "All Files|*.*"
' Show the dialog. If [Open] is clicked, save the name of the selected file...
If .ShowOpen Then strFile = .FileName
End With

Where do default MessageBox caption in Windows applications come from?

MessageBox.Show (.NET framework) or MessageBox (e.g. VBA) opens a modal message box from the window of the current application.
My questions are:
If I do not specify the caption (i.e. what appears in the top-left hand corner) of the message box in the arguments, does the default vary according to the application being run?
For example, if a message box pops up in Internet Explorer, would the default caption always say "Microsoft Internet Explorer"? Is this also true for other Microsoft applications such as Excel, Word, etc.?
Where does the default caption come from? Where does the system get the name "Microsoft Internet Explorer" from? Does the name come from the caption of the application window, or does it come from the register in task manager? I cannot find any documentation in the Microsoft website.
If you don't specify a caption nothing appears. There is no default.
By default, the message box displays an OK button. The message box does not contain a caption in the title.
Source
If an application is showing a title then it must be calling the overload that requires the caption as well as the message.
Thank you. I have just done a simple experiment using VBA on Excel. A statement like the following was added to the macro:
MsgBox("Test")
As you can see, the title was not specified (it is the 3rd variable). The title came up as "Microsoft Excel".
So the conclusion seems to be that there is a default, and it is the name of the application which invokes the message box.

Resources