/build/static/layout/Breadcrumb_cap_w.png

Vbscript to click a button of any application.

Want to automate few process and when i install some application at the end it ask to click on finish button and then it asks for restart, i want to automate this process, so how can click that button using vbscript and run shutdown -r -t 0 using script..

Please Help!!


0 Comments   [ + ] Show comments

Answers (1)

Posted by: mattski 11 years ago
Second Degree Green Belt
2

Use this code (TEST is the name of the app):

Set oShell = CreateObject("WScript.Shell")

If oShell.AppActivate("TEST") Then

oShell.SendKeys "%{F4}"

oShell.Run "C:\WINDOWS\system32\shutdown.exe -r -t 0"

End If 

Comments:
  • Interesting suggestion mattski - but F4 could be viewed as a forceful exit to the application, and may not return a valid INSTALL_RESULT (if that's being tracked). Perhaps something like AutoIT would be the solution here? - drose23 11 years ago
    • Yes AutoIT can be an option too...I see what you mean in the force key issue...what I would do is find out what is the last button being displayed in the app and then get SendKeys to trigger it. To help out here is a list of keys that can be triggered using my script (thanks to http://ss64.com/vb/sendkeys.html):

      Key SendKey Equivalent Description
      ~ {~} send a tilde (~)
      ! {!} send an exclamation point (!)
      ^ {^} send a caret (^)
      + {+} send a plus sign (+)
      Alt {ALT} send an Alt keystroke
      Backspace {BACKSPACE} send a Backspace keystroke
      Clear {CLEAR} Clear the field
      Delete {DELETE} send a Delete keystroke
      Down Arrow {DOWN} send a Down Arrow keystroke
      End {END} send an End keystroke
      Enter {ENTER} send an Enter keystroke
      Escape {ESCAPE} send an Esc keystroke
      F1 through F16 {F1} through {F16} send the appropriate Function key
      Page Down {PGDN} send a Page Down keystroke
      Space {SPACE} send a Spacebar keystroke
      Tab {TAB} send a Tab keystroke - mattski 11 years ago
      • Great stuff - if you can determine the tab order to arrive at the "Finish" button, I'd say sending the Enter would suffice - drose23 11 years ago
  • Thanks for ur help!! this is very new to me and will implement and get back to you..Thanks Again!! Cheers!! - appfreak 11 years ago
  • mattski can u please suggest me how can i trigger (wait) that click button script untill that last finish button screen appears. suppose any setup.exe process is running but when but that last screen appears at that time also that setup.exe is running so unable to detect when to trigger it - appfreak 11 years ago
  • Add the following two lines below the first line of code I made previously:

    oShell.Run "name of your installer", 9
    WScript.Sleep 500

    Explanation:

    first run your application using the 9 switch for Maximising and Activating the app.
    then sleep for amount of seconds - just tweak the number to suit.

    Coincidentally, what kind of application are you running? Any chance you can make the app run unattended using the silent switches etc? this would save you the above vbscript to run. - mattski 11 years ago

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ