Left Mouse Button Click in vbs - vbscript

I'm trying to create a program that clicks on a button in my web browser.
The current code:
set sh=createobject("wscript.shell")
sh.SendKeys "{Click, 669 , 674}"
wscript.sleep 100
sh.sendkeys "{Click, 669 , 674}"
I think there is something wrong with the command for the left mouse button.
Thanks for help.

SendKeys can only send keystrokes.
Check out nircmd (specifically the sendmouse command) or another third-party utility.

Related

How can I run and close an exe file with a mouse key?

I have an exe file and I want to run it and close it by pressing a mouse button or a keyboard button. For eg. say it is a music.exe and I want to open it while I am gaming/doing spread sheet by pressing the key 'm' or mouse button.
I have access to a logitech macro supported mouse. Also a no macro generic microsoft mouse. I am thinking about some kind of macro , or tasker or some script that can do this easily. ( not that I dont want to directly click the exe file or close the exe file by clicking x on the window)
Any suggestion would be helpful ;)
I did it with AutoHotKey software. If anyone is interested , here is the code
XButton2:: if WinExist("WindowName") WinClose ; else Run *runas "%directory%\Music.exe" return
This code will run and close the Music app with admin previlages. ( Change "Run *runas" to "run" if you want it to run normally)

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.

Need a startup script in windows to send ALT+F11 keys?

We are using a shared desktop on thin clients. By default it comes with windowed screen, but by pressing the Alt + F11 keys it will restore to full screen. So, we want a script to execute at Windows log-on with some delay.
Hopefully a login vbscript will work for you. Either append this to an existing login script or save it as a ".vbs" file. Microsoft has some good tutorials if you are unfamiliar with login scripts.
Set WshShell = CreateObject("Wscript.Shell") 'Create wshell object
WScript.Sleep(5000) 'Lets wait 5 seconds
WshShell.AppActivate "EXACT TITLE OF THE WINDOW YOU WANT" 'EDIT THIS LINE!
'The line above selects the window so we make sure the keystrokes are sent to it
WshShell.SendKeys "%{F11}" 'Send ALT+F11
Wscript.Quit 'Quit the script

disable message box for programs that was run from cmd

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.

How do I click a control button with ID using AutoHotkey?

How do I click a control button with ID using AutoHotkey?
I tried Click and ControlClick, but no luck!
ControlClick Button40
Click Button40
You need to give it some information about the window that the control is on. For example, to close the About screen in Notepad on Windows you could use
ControlClick, Button1, About Notepad ahk_class #32770
The format of the command from the docs is
ControlClick [, Control-or-Pos, WinTitle, WinText, WhichButton, ClickCount, Options, ExcludeTitle, ExcludeText]

Resources