here is my next question and i hope some one can help me :-)
Is it possible to position a msgbox in wsh/vbs?
alt text http://www.4freeimagehost.com/uploads/a9b04cde0527.jpg
I need the msgbox everytime in the foreground. I know that how to position a inputbox, but not a msgbox.
Thanks for help.
Greetings,
matthias
You cannot do that with a WSH MsgBox using VBS alone.
InputBox is the only build in dialog function that allows you to set a position.
You can use a WshShell.Popup and make it disappear after a few seconds, however it will be centered.
Edit; here is something using IE.
This is possible. Here is a link to a code sample (VB5, so it should work for you):
http://support.microsoft.com/kb/180936
Basically, you set up a hook so that your application gets a notification whenever you pop up a message box. Inside the handler, you move the message box to the desired location on the screen.
Related
In Excel VBA, is it possible to change the window style of a shelled program?
Here's the situation in detail:
At the click of a command button, the user should be able to load a third-party scanning program. The software path and file are specified in a named cell called settings_scanningsoftware, as you can see below. However, I'm using the Shell program, which doesn't wait for the third-party software to load before continuing. If it did, my life would be easier. For that reason, I throw up a dialog box in Excel telling the user to wait for the software to load and then ready the item to be scanned before they click Ok. And, since I throw up a dialog box, I load the scanning program minimized so they can see the dialog box (instead of it being hidden behind the software window and they're wondering why nothing's happening). With me so far?
However, once they click Ok, I want Excel to give control to the scanning software and give it a regular-sized window. There's my problem: once the software is loaded minimized, I can't seem to change the window style to give it a regular window.
Here's my code:
On Error Resume Next
Dim ScannerShell As Integer
ScannerShell = Shell(Range("settings_scanningsoftware").Value, **vbMinimizedNoFocus**)
If (ScannerShell <> 0) Then
Dim MessageBoxValue As Integer
MessageBoxValue = MsgBox("When you're ready to scan the receipt, click Ok.", vbOKCancel, "Scan receipt")
If (MessageBoxValue = vbOK) Then
ScannerShell = Shell(Range("settings_scanningsoftware").Value, **vbNormal**)
AppActivate ScannerShell, False
SendKeys ("{TAB}{TAB}{TAB} ")
End If
End If
Notice I've got the vbMinimizedNoFocus bolded above so that the software loads minimized and the user can see the upcoming dialog box. Once they click Ok, though, the software's window should be normalized. But Excel won't do me that favour.
Is there a way to change the window style after it's loaded?
Never mind the SendKeys command. I put that in there to get the scanner to automatically scan once everything is in place (the key sequence is incomplete, but one problem at a time). I know SendKeys is not a great way of sending commands to a program, but I'll figure that out once I get this window style thing fixed.
Does anyone have any solutions for me? Thanks.
I literally only started using Applescript today trying to write macros for an audio program I use so I really don't know a lot and am stumbling through this.
All I need to do is monitor when a certain window is open within the software and then most importantly, when it closes.
When I export a file from my software, a window comes up image of window The window has no identifier other than the static text "Bouncing..." In the screenshot there is a cancel button, but this doesn't apply to every instance of the window (depends on what options are selected) so it's the only thing I have to work with.
So far I have this:
tell application "System Events"
tell process "Pro Tools" to set myvalue to value of every static text of front window
repeat with i from 1 to count of myvalue
if (item i of myvalue = "Bouncing...") then repeat
end repeat
delay 1
end repeat
end tell
Testing this with a popup instead of the repeat stating it has found the static text works. So I'm halfway there.
All I need to do is to repeat this entire process over and over until the window disappears. Obviously when "myvalue" is "Bouncing..." I need to go back to the start, collect the static text values from the window again and then only exit the loop when the static text value of "Bouncing..." doesn't exist.
Currently it seems to exit the loop before the window has closed
Thanks for any help given here, I've spent hours on this and I'm just not knowledgeable enough to figure it out.
Found another way around it. It seems it does default to "window 1":
try
tell application "System Events"
repeat while (value of first static text of window 1 of application process "Pro Tools" = "Bouncing...")
delay 1
end repeat
end tell
end try
I'm trying to launch a dialog box with a checkbox already selected, but no amount of research is showing me how to do this. Included is my script that brings up the dialog box:
mount volume "smb://xyz-server/user-share/servervolume"
mount volume "smb://xyz-server/useradmin-share/servervolume"
There is no checkbox dialog in Applescript's Standard dialogs. You can use a Choose from List here, perhaps? Something like:
property serverList : {"smb://xyz-server/user-share/servervolume", "smb://xyz-server/useradmin-share/servervolume"}
set serverChoice to (choose from list serverList with prompt "Please select the volume(s) to mount" default items (item 1 of serverList) OK button name {"Mount"} cancel button name {"Cancel"} with multiple selections allowed)
repeat with thisPath in serverChoice
tell application "Finder"
mount volume thisPath
end tell
end repeat
Yea sorry, but there is no checkbox featured in simple AppleScript dialog boxes, etc, but you could use a dialog box with custom buttons eg.
set isOver13 to the button returned of (display dialog "Are you 13 or older?" buttons {"Cancel", "No", "Yes"})
(returns "Yes" or "No" for the button selected)
or like "jweaks" said, you could also use something like choose from list, eg.
set isOver13 to item 1 of (choose from list {"Yes", "No"})
(returns "Yes" or "No" for the item choosen)
but if you desperatly want to use a checkbox then, there is 1 other way :-o
you will need to cross over to cocoa-applescript (ASObjC), this is basicly the next step in applescript coding, ASObjC is pretty much Objective-C actions, commands etc... but in AppleScript coding language :o. To do this, you need to get Xcode, and look up AppleScript Objective-C tutorials ;)
Hope this Helped :D
The window belongs to the process NetAuthAgent, you can click the checkbox only with GUI scripting.
tell application "System Events"
repeat until exists window 1 of process "NetAuthAgent"
delay 0.2
end repeat
tell process "NetAuthAgent"
click checkbox 1 of window 1
end tell
end tell
I have a Macro which takes 45 seconds to complete. When the macro starts I want a Countdown timer to pop up like a message box which will countdown until Macro completion. I have searched but so far cant find any answers to this. Is this possible?
As #Thrum correctly mentioned in his comment this is not possible with a message box.
A MsgBox is modal and therefore blocks the entire Excel application. Nothing else can happen / be done while that message box window is open and waits for you to close it. Actually, you can even make message boxes system-wide modal. In that case no other Windows application will respond unless you close that little message box in Excel (check the option vbSystemModal within the VBA help regarding MsgBox).
However, with forms on the other hand you have a choice. You can make the form not modal.
UserForm1.Show (False)
In that case the code continues to run in the background while the form is shown to the user and permits the running VBA code to make changes to the form while it is shown to the user.
I have a VBA form that when I click on it, performs some long calculations (a few seconds to several seconds long) and then displays the results on frames in the form. However, once every so often, the form hides on me and I need to click around to the VBA editor and back to the sheet to make it display again
I have
Me.Repaint
at the end of the calculations on the form
but it still doesn't help
I also tried disabling the "EnableCalculation" attribute of the main sheet, but still no use
Anyone ever run into something like this? Do I need to load the form in some special way?
I have had the same problem. When saving an Excel workbook by clicking on a command button on a modeless Userform, the form disappears as the code completes.
I read that the problem was due to some inter-compatible changes that Microsoft has made and found some very elaborate solutions involving a lot of complex code that I was unable to integrate into my project. However, I did find a very quick workaround.
In my case the Userform only disappeared when the code executed the End Sub command of the command button's code. I simply added an Exit Sub immediately before it and the Userform no longer disappears.
Have you tried turning off and on screen updating so Excel is not redrawing the screen with each change.
sub doSomthing()
Application.ScreenUpdating = False
'do something
Application.ScreenUpdating = True
end sub
The form disappears because Microsoft has changed the model by which forms are owned by a 'superior' process (Excel in your case). I have the same problem and also cannot overcome it.
Just sit tight until Microsoft decides that it is worth their effort to fix yet another introduced and untested problem by making changes to something that already worked.
The problem is a side effect of the SDI (Single Document Interface) that was introduced with Excel 2013. The various suggestions that invoke DoEvents, ScreenUpdating, etc. may help in certain scenarios, but they do not cure the behavior.
There is a full solution posted here: Keeping Userforms on top of SDI windows in Excel 2013 and up
If that is too involved for your needs, a quick-and-dirty solution is to minimize and restore the active window, which forces the userform back on top of the stack.
'Do long-winded process first, then:
Application.ScreenUpdating = False
ActiveWindow.WindowState = xlMinimized
ActiveWindow.WindowState = xlNormal
Application.ScreenUpdating = True
This doesn't prevent the form from disappearing, but it makes it reappear the end of the process.
Try experimenting with the following two lines of code instead of the repaint.
Me.Show
And/Or:
Me.SetFocus
Hopefully, one of these will work for you!
In my case I had to use all these to make it happen. (frmGUI is my form)
DoEvents
frmGUI.Repaint
frmGUI.Show
With Office 2013 and Windows 7, simply adding DoEvents right before the end of the sub (where the form disappeared) kept the form open. Nothing else needed....for my situation.