Jump to content

Potential Script Issues


mr-es335
 Share

Recommended Posts

Good day,

May i ask what is wrong with this script?

The script is what I believe to be an "automation installation script".

My current issue is that the first time this script is run after a system restart/reboot, the  "Launch Application" and "Configure Application" portions do not function properly and the script  will often launch twice. Any assistance in this matter would be greatly appreciated!

Func Install_SAW()
    Local $App_SAW = "G:\Software\AutoIt\Scripts\Menu_Routines\Menu_Dialogs\Menus\SAW_MWS_Customizer\Data\SAWStudio64Demo_V1_4.exe"
    Local $src_folder = "C:\Users\Dell\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\SAWStudio64 Demo"
    ; ------
    Local $src_app1 = "C:\Windows\toggleTaskbarAutohide.exe"
    Local $src_app2 = "C:\SAWStudio64Demo\SAWStudio64Demo.exe"
    ; ------
    Local $PID = "SAWStudio64Demo.exe"
    ; Install Application
    Run($App_SAW)
    WinWaitActive("WinZip Self-Extractor - SAWStudio64Demo_V1_4.exe")
    Send("{ENTER}")
    WinWaitActive("Setup Utility - 2.8")
    Send("{ENTER}")
    WinWaitActive("Setup Utility - 2.8")
    Send("{ENTER}")
    WinWaitActive("Setup Utility - 2.8")
    Send("{ENTER}")
    WinWaitActive("Setup Utility - 2.8")
    Send("{ENTER}")
    WinWaitActive($src_folder)
    WinClose($src_folder)
    DirRemove($src_folder, $DIR_REMOVE)
    Sleep(500)
    ; Launch Application
    Run($src_app1)
    Sleep(100)
    ; ------
    Run($src_app2)
    Sleep(100)
    Send("{Enter}")
    Sleep(100)
    Send("{Enter}")
    ; Configure Application
    Send("{alt}")
    Sleep(100)
    Send("{O}")
    ClipPut("1920")
    Send("{UP}")
    Send("{Enter}")
    Sleep(100)
    Send("^{v}")
    Send("{Enter 2}")
    Send("{alt}")
    Sleep(100)
    Send("{F}")
    Sleep(100)
    Send("{P}")
    Sleep(100)
    Send("{S}")
    Send("{Enter}")
    ; Exit the application
    $PID = ProcessExists($PID)
    ProcessClose($PID)
    If $PID Then ProcessClose($PID)
    ; ------
    Run($src_app1)
    Sleep(100)
EndFunc   ;==>Install_SAW

 

Edited by mr-es335
Link to comment
Share on other sites

Add some debug output.  For example: ConsoleWrite('WinWaitActive finished') after the line:

  WinWaitActive("WinZip Self-Extractor - SAWStudio64Demo_V1_4.exe")

Would look like this:

WinWaitActive("WinZip Self-Extractor - SAWStudio64Demo_V1_4.exe")
ConsoleWrite("WinZip Self-Extractor - SAWStudio64Demo_V1_4.exe COMPLETED")

You very likely will need more of these ConsoleWrite() outputs.  Find how far the script reaches when it fails and we'll debug that problem specifically.

Here is a function to make ConsoleWrite() output easier to manage:

; Debug function to simplify ConsoleWrite() output lines
Func out($out1 = "", $out2 = "", $out3 = "", $out4 = "", $out5 = "", $out6 = "", $out7 = "", $out8 = "", $out9 = "", $out10 = "", $out11 = "", $out12 = "", $out13 = "", $out14 = "", $out15 = "")
    ConsoleWrite($out1 & " " & $out2 & " " & $out3 & " " & $out4 & " " & $out5 & " " & $out6 & " " & $out7 & " " & $out8 & " " & $out9 & @CRLF)
EndFunc   ;==>out

The function above will allow you to append strings and variables all on a single line then move the output text cursor to the next line after the function call.  So you are not constantly adding "& @CRLF" to the end of every ConsoleWrite manually.

Edited by Xandy
Link to comment
Share on other sites

I see that you believe the script to fail at the configuration section.  Perhaps Running the application twice is the problem.  We could check to see if the app is running before running the app.  We could apply some effort in that direction, if you also think that could be the problem.

Edited by Xandy
Link to comment
Share on other sites

Xandy,

May I ask where to put the function you mentioned? Thanks.
• Neophyte here...

Note: I do believe that figured out where to put the function calls...

WinWaitActive("WinZip Self-Extractor - SAWStudio64Demo_V1_4.exe")
    out()

Would this placement be correct?

1) I separated script into two part a) Install and b) Config
2) Following are the output results...

Install
WinZip Self-Extractor - SAWStudio64Demo_V1_4.exe COMPLETED        
+>12:17:39 AutoIt3.exe ended.rc:0
+>12:17:39 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 4.638

Config
+>12:18:52 AutoIt3.exe ended.rc:0
+>12:18:52 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 1.893

So, if the two functions appear to work independently, then it must be the connection between the two that is failing?

Edited by mr-es335
Link to comment
Share on other sites

Xandy,

Well..."Will wonders never cease!"

I do believe that I have found the potential solution to this anomaly?

As noted previously, if the two functions appear to work independently, then it must be the connection between the two that is failing? Thus, I deduced that the second launched application [SAWStudio64 Demo] was "losing focus". Thus, the insertion of WinWaitActive() function as noted below:

; Launch Application
    Run($src_app1)
    Sleep(100)
    ; ------
    Run($src_app2)
    WinWaitActive("SAWStudio64 Demo") ; Insertion here!!

After 2 test runs...no issues.

Conclusion
I know...I know, that I really do need to focus on such things as "return statements" and "error checking" - as doing so would have assisted me in potentially resolving the above issue.

Xandy, please let me know your thoughts. I very much appreciate your assistance here!

Edited by mr-es335
Link to comment
Share on other sites

6 hours ago, mr-es335 said:

Will wonders never cease!

Probably not before we do :) 

 

The only way I learn is through trail and error.  You are doing great.  As for where to put the body of the debug function out(), that is difficult for me to specify.  You could make a new script called Debug.au3 and copy the function definition there (to the new script).  Then you can:

#include "Debug.au3"; Quotes "" because it's a custom include file

Inside any script you wish to use your custom debug functions.  However you can name the Debug.au3 any unique name you wish.  You could alternatively copy the function body to any script that would call 'out()'.

I don't see the need to tell you how to structure your code at this time.  I also do not want to pigeon hole you into my coding practices, as they might not be right for you at this stage of your development.  It's your code, Sir. 

Edited by Xandy
Link to comment
Share on other sites

It seems a simple program to setup. The setup file is an SFX, this installs all the files into a single directory (default C:\SAWStudioDemo). You could install the program, set your preferences and save them. The preference file is SAWStudio.prf. Then create your own SFX that extracts the files to wherever you want.

I can guess from the name what the toggleTaskbarAutohide.exe does but don't know the function in this scenario.

If your scripting it to learn, then ignore me :)

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...