I want to start an application (hh.exe) (Windows Help) in VBScript but I want to give that app a specific window size anb possibly a position where to open
to start the app I use this code :
Set hh = CreateObject( "WScript.Shell" )
hh.Run("hh.exe -800 C:\Users\me\Desktop\HELP_I_CREATED.CHM")
This works but I can't find a way to give that application a size. If anybody has an idea it would be very apreciated.
Thank you
Here is the spec for this function:
http://msdn.microsoft.com/en-us/library/d5fk67ky(v=vs.84).aspx
You can see from the list of options that there is no way to specify a specific window size other than "minimized", "maximized", "original", "most recent".
Related
Sorry if this seems like a dumb question but im curious to see if this would work?
So my plan was to create a .vbs script to send keys to go to a website, but my plan was to have a blank black screen over top of it so you couldnt see the process. Obviously it would not be hard to make the full black screen (it would be done in a different language, most likely an exe file) but then I completely forgot... would it even be possible? I tested it out with other full screen programs and obviously it sent the "sendkeys" command to the program that was in front.
Still confused? Here is an example
Set WshShell = CreateObject("WScript.shell") for i = 0 to 50 WshShell.SendKeys(chr(175)) next Process.Start("CMD", "/C start chrome.exe http://www.bing.com")
WScript.Sleep 2000
WshShell.SendKeys "this is an example of text being put into the search bar"
So my question is, would it be possible to have a fullscreen application open while this command runs in the background? it could be any fullscreen application, just anything to "hide" or cover this process.
Or would it even be possible to create a fullscreen program specifically to cover this?
Thank you for reading!
We just got a new win 7 64 computer and one very old program does not display properly on launch - it doesn't draw itself completely until I change the size of its window. I'd like to write a small script program that launches the old program, then changes its size (for example, minimize then restore or maximize then restore its window) or otherwise forces the program to redraw itself.
That way a user could click on the program icon and it would flicker a moment and display properly.
I tried:
Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("""c:\Program Files (x86)\VideoLan\VLC\vlc.exe""")
objShell.SendKeys "% x"
objShell.SendKeys "% r"
Set objShell = Nothing
Based on How can I maximize, restore, or minimize a window with a vb script? That worked to launch vlc (test program, not the problem program), but did not change its size.
EDIT: adding a slight delay after run (wscript.sleep(200)) fixed the problem. I'd still like to know if there's a better way.
Not sure if this will work, but you could give it a try:
CreateObject("Shell.Application").Namespace(0).Self.InvokeVerb "R&efresh"
The above invokes a "Refresh" of the desktop, which may or may not update your application window as well.
I would like to open my video using VBS and So far I have this and it works fine
Set wmp = CreateObject("WMPlayer.OCX")
wmp.openPlayer("C:\Users\myvideo.mp4")
I would also like to add one more line to make it full screen. How would one do that?
Also, my second question is probably more useful.
Is there a collective website to describe how to manipulate these objects?
When I played around with Matlab, I can at least press tab and see what can options are available under that object and I learned a lot that way (the website was also very helpful).
Is there a comparable way in VBS or for example, where can I find a extensive lists of command I could send to WM Player?
Thanks!
For switching the window to a full screen window you have to use Alt+Enter. This can be done using sendKeys method of the Shell object. Here's the code:
set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 1000
WshShell.SendKeys "%{ENTER}"
Hope this suits you need. For further help check the documentation for SendKeys.
I would like to know if it's possible to simulate the process: Right click on an image -> Click on "Save image as.." on the popup menu -> save the image in local.
I tried CaptureBitmap() function, but the result is just a screenshot taken by QTP, not the same image file obtained as the procedure above.
Are there other ways? Many thanks in advance.
Allen
I suppose it depends what you want to do. If you want to compare the bitmap then the CaptureBitmap options should work. If you want to compare the path to the image you can use Image("x").GetROProperty("src").
If you really want to save the src image file then unfortunately QTP doesn't supply a way to interact with the browser's context menu. You can try to use some third-party mechanism to download the image from the src URL (e.g. wget).
Edit: I just had another thought, I'm not at work so I can't verify that it will work but I'm pretty sure it will.
First cause the context menu to appear, in order to do this you have to change the replay mode to device and run a RightClick operation.
replayType = Setting.WebPackage("ReplayType") ' Store old replay mode
Setting.WebPackage("ReplayType") = 2 ' change to device replay mode
Browser("b").Page("p").Image("I").RightClick
Setting.WebPackage("ReplayType") = replayType ' Revert to old mode
Then send the letter v to the browser which will select the Save menu item (on both IE and Firefox) by using the device replay object
Set deviceReplay = CreateObject( “Mercury.DeviceReplay” )
deviceReplay.SendString "v"
Now interact with the save dialog as a usual Win32 control.
Moral: Never underestimate what QTP will let you do if you try hard enough
I've found a few tutorials that explain how to use the windows API to get a custom icon in the system tray.
These are all for Visual Basic, and they don't seem to be scaling to VBA well.
I'm following this short tutorial:
http://atchoo.org/vb/systray.php
Basically, you have to set the hIcon value (a 'long' variable) but it does not work.
I've tried to use the LoadPicture() function, which does not give me any errors, but also fails to add a new icon.
I can't supply Me.Icon, nor can I set it on Form_Load.
Does anyone have any experience with this?
Using loadpicture was the right approach, but not directly.
I had to define a new variable first, and load that.
Like this:
Dim myPicture As IPictureDisp
strPath = "F:\Databank\Icons\stone.ico"
Set myPicture = LoadPicture(strPath)
And then, somewhere along the way, I could set hIcon without problems:
.hIcon = myPicture
When I change the trayicon (like, say, adding a balloontip) I have to supply the icon information again, too.