nazirm Posted September 19, 2013 Share Posted September 19, 2013 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 More sharing options...
allSystemsGo Posted September 19, 2013 Share Posted September 19, 2013 Applications in the start menu are basically shortcuts to executables in the program files directory. Therefore, you could try something like this: $file=("C:\Program Files\path\to\exe") If FileExists($file) Then RunWait($file,"") EndIf Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 19, 2013 Moderators Share Posted September 19, 2013 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 More sharing options...
allSystemsGo Posted September 19, 2013 Share Posted September 19, 2013 (edited) Does autoit ignore windows security settings or have a way around them? Under normal circumstances the start menu has a deny rule for read/listing of data. (Not saying the above doesn't work, just curious) Edited September 19, 2013 by allSystemsGo Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 19, 2013 Moderators Share Posted September 19, 2013 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 More sharing options...
allSystemsGo Posted September 19, 2013 Share Posted September 19, 2013 Yeah, it did for me too. If you were to manually follow the path you would be presented with a deny permission, and unless you edit or remove it you can't access the Start Menu directory. Interesting.... Link to comment Share on other sites More sharing options...
nazirm Posted September 19, 2013 Author Share Posted September 19, 2013 Hi JLogan3o13Hi 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 More sharing options...
nazirm Posted September 22, 2013 Author Share Posted September 22, 2013 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now