Jump to content

Automate start menu clicks


nazirm
 Share

Recommended Posts

Hello:

I want to automate my software testing tasks.  After a software is installed I need to click on "Start" button and then check if the short cut to the application is present, and, if so, click on the shortcut.  How can I automate this task?

So, basically, Start->Click on Application Folder->Click on Application

Regards,

Nazir

Link to comment
Share on other sites

  • Moderators

Try FileGetShortcut. The Helpfile example should put you on the right path (see below, modified slightly from help file):

Local $aDetails = FileGetShortcut("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\7-Zip\7-Zip File Manager.lnk")
If Not @error Then
    MsgBox(0, "FileGetShortcut", "Path: " & $aDetails[0] & @CRLF & _
            "Working directory: " & $aDetails[1] & @CRLF & _
            "Arguments: " & $aDetails[2] & @CRLF & _
            "Description: " & $aDetails[3] & @CRLF & _
            "Icon filename: " & $aDetails[4] & @CRLF & _
            "Icon index: " & $aDetails[5] & @CRLF & _
            "Shortcut state: " & $aDetails[6] & @CRLF)
EndIf

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

It doesn't ignore, but if you mean UAC then there are ways to account for it. The above runs for me on WIN7 without a UAC prompt, though.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Hi JLogan3o13
Hi JLogan3013:
I tried your code.  My version is listed below:
Interestingly, the Path I got in my command window is C:Program Files (x86)7-Zip7zFM.exe, but it should be actually C:Program Files7-Zip7zFM.exe

Any thoughts?

Also, since I am testing the installation of my application my users will prefer to actually see the same steps being executed manually.  So they would like the automated script to click on start, then next click on the desired shortcut in the shortcut menu and then see the application starting.  Would this be possible?

Regards

Nazir

Local $aDetails = FileGetShortcut("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\7-Zip\7-Zip File Manager.lnk")
If Not @error Then
    MsgBox(0, "FileGetShortcut", "Path: " & $aDetails[0] & @CRLF & _
        "Working directory: " & $aDetails[1] & @CRLF & _
        "Arguments: " & $aDetails[2] & @CRLF & _
        "Description: " & $aDetails[3] & @CRLF & _
        "Icon filename: " & $aDetails[4] & @CRLF & _
        "Icon index: " & $aDetails[5] & @CRLF & _
        "Shortcut state: " & $aDetails[6] & @CRLF)
EndIf
Run("C:\Windows\system32\cmd.exe")
WinWaitActive("C:\Windows\system32\cmd.exe","")
Send($aDetails[0])
Send("{ENTER}")
Link to comment
Share on other sites

I solved the problem. I found that AutoIt did not work as expected in Windows 7 64 bit. But, when I installed the same in Windows 2008 Server 64 bit it worked well. Perhaps I will start another thread asking why it does not work on Windows 7 64 bit. When I built the exe in 2008 Server 64 bit and ran it on Windows 7 64 bit, the exe ran OK. But exeution of the program from the AutoIt editor in Windows 7 64 bit behaves erratically.

#include <GuiTreeView.au3>
Send("^{ESC}")
WinWaitActive("Start menu","")
sleep(1000)
ControlClick("Start menu","","[CLASS:Button; INSTANCE:1]")
WinWaitActive("Start menu","")
sleep(1000)
$hTree = ControlGetHandle("Start menu", "", "[CLASS:SysTreeView32; INSTANCE:1]")
$hTree1 = _GUICtrlTreeView_FindItem($hTree,"Accessories")
$hTree2 = _GUICtrlTreeView_FindItem($hTree,"Paint")
_GUICtrlTreeView_ClickItem($hTree, $hTree1)
sleep(1000)
WinWaitActive("Start menu","")
_GUICtrlTreeView_ClickItem($hTree, $hTree2)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...