Jump to content

AutoIt3ExecuteLine quotes/syntax


Recommended Posts

id be able to shellexecute a url into a gui i create?

hmm hows that possible?

No. You shellexecute a second AutoIt script that creates the GUI and embeds the IE object. As you now have two independant AutoIt scripts running at the same time both are responsive.

Or do I misinterpret something?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

nah not at all.

so basically i can just leave my script intact and just create a new one that executes this one?

i can do a fileinstall from the new one (script 1) to add the second script?

Link to comment
Share on other sites

i just tried it... i keep having the same problem *sigh*

if i click onto other windows back and forth then click my gui, it becomes unresponsive.

ive already tried running it uncompiled to see if i get a reading from the console - no error

tried turning on debug too.. nothing

script 1

FileInstall("U:\scripts\Camera\Camera.exe", @TempDir & "\Camera.exe", 1) ShellExecute(@TempDir & "\Camera.exe")

script 2

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=webcam.ico
#AutoIt3Wrapper_Outfile=Camera.exe
#AutoIt3Wrapper_Res_Fileversion=0.8.0.0
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Run_Debug_Mode=Y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <array.au3>
#include <ComboConstants.au3>
#include <StaticConstants.au3>
#include <Constants.au3>
#include <Misc.au3>
#include <ButtonConstants.au3>

Opt("GUIOnEventMode", 1)

Global $script_version = ("Camera v" & FileGetVersion(@ScriptName))
Global $tools_dir = "\\Server\Share\Application\"
Global $log_dir = "\\Server\Share\Log\"
Global $log_file = $log_dir & "log.txt"
Global $multi_enabled, $URL, $users[4][3]
Global $always_on_top, $default_camera, $switch_count = 0
Global $GUI, $IE, $URL_combo, $always_on_top_checkbox, $background, $set_default_btn
Global $x_position, $y_position
Global $Custom_COM_Error, $COM_Error = 0

_IEErrorHandlerRegister("Custom_COM_Error")

;~ CheckRequirements()
BuildUserArray()
AssignCamera()
ReadSettings()

$IE = _IECreateEmbedded()

If $multi_enabled = False Then
    If $always_on_top = "True" Then
        $GUI = GUICreate($script_version, 325, 310, $x_position, $y_position, -1, $WS_EX_TOPMOST)
    Else
        $GUI = GUICreate($script_version, 325, 310, $x_position, $y_position)
    EndIf

    $refresh_btn = GUICtrlCreateButton("", 3, 3, 20, 21, $BS_ICON)
    GUICtrlSetOnEvent(-1, "CameraRefresh")
    GUICtrlSetImage(-1, "xpsp2res.dll", -54, 0)
    GUICtrlSetTip(-1, "Refresh current camera")

    GUICtrlCreateObj($IE, -13, 25, 370, 285)
EndIf

If $multi_enabled = True Then
    If $always_on_top = "True" Then
        $GUI = GUICreate($script_version, 325, 325, $x_position, $y_position, -1, $WS_EX_TOPMOST)
    Else
        $GUI = GUICreate($script_version, 325, 325, $x_position, $y_position)
    EndIf

    $refresh_btn = GUICtrlCreateButton("", 160, 10, 20, 21, $BS_ICON)
    GUICtrlSetOnEvent(-1, "CameraRefresh")
    GUICtrlSetImage(-1, "xpsp2res.dll", -54, 0)
    GUICtrlSetTip(-1, "Refresh current camera")

    GUICtrlCreateObj($IE, -13, 40, 370, 285)
EndIf

$always_on_top_checkbox = GUICtrlCreateCheckbox("Always on Top", 242, 5, 77, 12)
GUICtrlSetOnEvent(-1, "SetTopMost")
GUICtrlSetFont(-1, 7)
GUICtrlSetTip(-1, "Set this window to be on top of all other windows")

If $always_on_top = "True" Then
    GUICtrlSetState(-1, $GUI_CHECKED)
EndIf

If $multi_enabled = True Then
    $URL_combo = GUICtrlCreateCombo("", 3, 3, 95, 15, $CBS_DROPDOWNLIST)
    GUICtrlSetData(-1, "COMPANY2 - SITE1|COMPANY1 - SITE1|COMPANY1 - SITE2|COMPANY2 - SITE2", $default_camera)
    GUICtrlSetOnEvent(-1, "SetCamera")

    $set_default_btn = GUICtrlCreateButton("Set As Default", 3, 25, 95, 15)
    GUICtrlSetOnEvent(-1, "SetDefault")
    GUICtrlSetFont(-1, 7)
    GUICtrlSetTip(-1, "Set current camera as default")
EndIf

SetCamera()

GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
GUISetOnEvent($GUI_EVENT_CLOSE, "Xbutton")
GUISetState()

While 1
    Sleep(100)
WEnd

Func CheckRequirements()

    Local $get_output = Run(@ComSpec & " /c java.exe -version", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    Local $line

    While 1
        $line = StderrRead($get_output)
        If @error Then ExitLoop
        If $line <> "" Then
            $first_line = StringStripWS(StringReplace($line, "java version", ""), 8)
            $java_version = StringTrimRight(StringReplace($first_line, '"', ""), 3)
            ExitLoop
        EndIf
    WEnd

    $version_compare = _VersionCompare("1.6.0", $java_version)

    If $version_compare = 1 Then
        MsgBox(262144, $script_version, "You need to update JAVA client.")
        Exit
    EndIf

EndFunc   ;==>CheckRequirements

Func BuildUserArray()

    ;User
    ;Location
    ;Access

    $users[0][0] = "USER1"
    $users[0][1] = "SITE1"
    $users[0][2] = "BOTH_COMPANIES"

    $users[1][0] = "USER2"
    $users[1][1] = "SITE1"
    $users[1][2] = "COMPANY1"

    $users[2][0] = "USER3"
    $users[2][1] = "SITE2"
    $users[2][2] = "COMPANY1"

    $users[3][0] = "USER3"
    $users[3][1] = "SITE1"
    $users[3][2] = "COMPANY2"


EndFunc   ;==>BuildUserArray

Func AssignCamera()

    $user_found = False
    $multi_enabled = False

    $class_B_subnet = StringLeft(@IPAddress1, 5)

    For $x = 0 To UBound($users) - 1
        If @UserName = $users[$x][0] Then
            $user_found = True

            If $users[$x][1] = "SITE1" Then
                If $users[$x][2] = "COMPANY1" Then
                    $company = "COMPANY1"
                    If $class_B_subnet = "192.163" Then
                        $city = "SITE1"
                    Else
                        $city = "SITE2"
                    EndIf
                EndIf

                If $users[$x][2] = "COMPANY2" Then
                    $company = "COMPANY2"
                    If $class_B_subnet = "192.163" Then
                        $city = "SITE1"
                    Else
                        $city = "SITE2"
                    EndIf
                EndIf
            EndIf

            If $users[$x][1] = "SITE2" Then
                If $users[$x][2] = "COMPANY1" Then
                    $company = "COMPANY1"
                    If $class_B_subnet = "192.160" Then
                        $city = "SITE2"
                    Else
                        $city = "SITE1"
                    EndIf
                EndIf

                If $users[$x][2] = "COMPANY2" Then
                    $company = "COMPANY2"
                    If $class_B_subnet = "192.160" Then
                        $city = "SITE2"
                    Else
                        $city = "SITE1"
                    EndIf
                EndIf
            EndIf

            If $users[$x][2] = "BOTH_COMPANIES" Then
                $multi_enabled = True
            EndIf

        EndIf
    Next

    If $user_found = False Then
        MsgBox(262144, $script_version, "You do not have access to view any cameras.")
        Return
    EndIf

    If $multi_enabled = False Then
        CreateHtml($company, $city)
    EndIf

EndFunc   ;==>AssignCamera

Func CreateHtml($company, $city)

    If $company = "COMPANY2" And $city = "SITE1" Then
        $ip = "http://192.160.22.201:80/"
    EndIf

    If $company = "COMPANY2" And $city = "SITE2" Then
        $ip = "http://192.163.8.230:80/"
    EndIf

    If $company = "COMPANY1" And $city = "SITE1" Then
        $ip = "http://192.160.10.200:80/"
    EndIf

    If $company = "COMPANY1" And $city = "SITE2" Then
        $ip = "http://192.163.56.220:80/"
    EndIf

    $URL = @TempDir & "\Camera.html"

    If FileExists($URL) Then
        FileDelete($URL)
    EndIf

    $text = '<html>' & @CRLF
    $text &= '<title>' & $company & '-' & $city & ' Camera</title>' & @CRLF
    $text &= '<style>' & @CRLF
    $text &= '<!--' & @CRLF
    $text &= ' /* Style Definitions */' & @CRLF
    $text &= ' p.MsoNormal, li.MsoNormal, div.MsoNormal' & @CRLF
    $text &= '  {mso-style-parent:"";' & @CRLF
    $text &= '  margin:0in;' & @CRLF
    $text &= '  margin-bottom:.0001pt;' & @CRLF
    $text &= '  mso-pagination:widow-orphan;' & @CRLF
    $text &= '  font-size:12.0pt;' & @CRLF
    $text &= '  font-family:"Times New Roman";' & @CRLF
    $text &= '  mso-fareast-font-family:"Times New Roman";}' & @CRLF
    $text &= 'p.style8, li.style8, div.style8' & @CRLF
    $text &= '  {mso-style-name:style8;' & @CRLF
    $text &= '  mso-margin-top-alt:auto;' & @CRLF
    $text &= '  margin-right:0in;' & @CRLF
    $text &= '  mso-margin-bottom-alt:auto;' & @CRLF
    $text &= '  margin-left:0in;' & @CRLF
    $text &= '  mso-pagination:widow-orphan;' & @CRLF
    $text &= '  font-size:12.0pt;' & @CRLF
    $text &= '  font-family:Arial;' & @CRLF
    $text &= '  mso-fareast-font-family:"Times New Roman";' & @CRLF
    $text &= '  color:whitesmoke;' & @CRLF
    $text &= '  font-weight:bold;}' & @CRLF
    $text &= 'span.style81' & @CRLF
    $text &= '  {mso-style-name:style81;' & @CRLF
    $text &= '  font-family:Arial;' & @CRLF
    $text &= '  mso-ascii-font-family:Arial;' & @CRLF
    $text &= '  mso-hansi-font-family:Arial;' & @CRLF
    $text &= '  mso-bidi-font-family:Arial;' & @CRLF
    $text &= '  color:whitesmoke;' & @CRLF
    $text &= '  font-weight:bold;}' & @CRLF
    $text &= '@page Section1' & @CRLF
    $text &= '  {size:8.5in 11.0in;' & @CRLF
    $text &= '  margin:1.0in 1.25in 1.0in 1.25in;' & @CRLF
    $text &= '  mso-header-margin:.5in;' & @CRLF
    $text &= '  mso-footer-margin:.5in;' & @CRLF
    $text &= '  mso-paper-source:0;}' & @CRLF
    $text &= 'div.Section1' & @CRLF
    $text &= '  {page:Section1;}' & @CRLF
    $text &= '-->' & @CRLF
    $text &= '</style>' & @CRLF
    $text &= '</head>' & @CRLF
    $text &= '' & @CRLF
    $text &= '<body bgcolor="#E8E8E8" lang=EN-US style="tab-interval:.5in">' & @CRLF
    $text &= '' & @CRLF
    $text &= '<div class=Section1>' & @CRLF
    $text &= '<div align=center>' & @CRLF
    $text &= '<table class=MsoNormalTable border=0 cellpadding=0 width=365 style="width:3.3in;' & @CRLF
    $text &= ' mso-cellspacing:1.5pt;mso-padding-alt:0in 5.4pt 0in 5.4pt">' & @CRLF
    $text &= ' <tr style="mso-yfti-irow:0;mso-yfti-firstrow:yes">' & @CRLF
    $text &= '  <td style="background:#006699;padding:.75pt .75pt .75pt .75pt">' & @CRLF
    $text &= '  <p class=MsoNormal align=center style="margin-right:7.4pt;text-align:center"><span' & @CRLF
    $text &= '  class=style81>' & $company & '-' & $city & ' Trading</span></p>' & @CRLF
    $text &= '  </td>' & @CRLF
    $text &= ' </tr>' & @CRLF
    $text &= ' <tr style="mso-yfti-irow:1">' & @CRLF
    $text &= '  <td style="padding:.75pt .75pt .75pt .75pt">' & @CRLF
    $text &= '  <p class=MsoNormal><span style="font-size:10.0pt">' & @CRLF
    $text &= '  <applet codebase="' & $ip & '-wvdoc-01-/LiveApplet/" height="240" archive="LiveApplet.zip" width="320" code="LiveApplet.class" VIEWASTEXT>' & @CRLF
    $text &= '        <param name="url" value="' & $ip & '" />' & @CRLF
    $text &= '        <param name="cabbase" value="LiveApplet.cab" />' & @CRLF
    $text &= '        <param name="capture_size" value="320x240" />' & @CRLF
    $text &= '        <param name="video_width" value="340" />' & @CRLF
    $text &= '        <param name="bg_color" value="#ececec" />' & @CRLF
    $text &= '        <param name="controller_style" value="no_pantilt" />' & @CRLF
    $text &= '  </applet>' & @CRLF
    $text &= '  </span></p>' & @CRLF
    $text &= '  </td>' & @CRLF
    $text &= ' </tr>' & @CRLF
    $text &= '</table>' & @CRLF
    $text &= '</div>' & @CRLF
    $text &= '</div>' & @CRLF
    $text &= '</body>' & @CRLF
    $text &= '</html>' & @CRLF

    FileWrite($URL, $text)

EndFunc   ;==>CreateHtml

Func ReadSettings()

    $always_on_top = RegRead("HKLM\Software\Camera", "TopMost")
    $default_camera = RegRead("HKLM\Software\Camera", "Default")

    If $default_camera = "" Then
        $default_camera = "COMPANY2 - SITE2"
    EndIf

    $x_position = RegRead("HKLM\Software\Camera", "X_Position")

    If $x_position = "" Then
        $x_position = "0"
    EndIf

    $y_position = RegRead("HKLM\Software\Camera", "Y_Position")

    If $y_position = "" Then
        $y_position = "0"
    EndIf

EndFunc   ;==>ReadSettings

Func SetTopMost()

    If BitAND(GUICtrlRead($always_on_top_checkbox), $GUI_CHECKED) Then
        $topmost = True
        WinSetOnTop($script_version, "", 1)
    EndIf

    If BitAND(GUICtrlRead($always_on_top_checkbox), $GUI_UNCHECKED) Then
        $topmost = False
        WinSetOnTop($script_version, "", 0)
    EndIf

    RegWrite("HKLM\Software\Camera", "TopMost", "REG_SZ", $topmost)

EndFunc   ;==>SetTopMost

Func SetDefault()

    $default = GUICtrlRead($URL_combo)
    RegWrite("HKLM\Software\Camera", "Default", "REG_SZ", $default)

    MsgBox(262144, $script_version, $default & " has been set as default.")

EndFunc   ;==>SetDefault

Func SetPosition()

    $position_array = WinGetPos($script_version, "")

    $x_position = $position_array[0]
    $y_position = $position_array[1]

    RegWrite("HKLM\Software\Camera", "X_Position", "REG_SZ", $x_position)
    RegWrite("HKLM\Software\Camera", "Y_Position", "REG_SZ", $y_position)

EndFunc   ;==>SetPosition

Func SetCamera()

    If $multi_enabled = False Then
        If Not FileExists($URL) Then
            MsgBox(262144, $script_version, "Unable to find " & $URL)
            Exit
        EndIf
    EndIf

    If $multi_enabled = True Then
        If GUICtrlRead($URL_combo) = "COMPANY1 - SITE2" Then
            $company = "COMPANY1"
            $city = "SITE2"
        EndIf

        If GUICtrlRead($URL_combo) = "COMPANY2 - SITE2" Then
            $company = "COMPANY2"
            $city = "SITE2"
        EndIf

        If GUICtrlRead($URL_combo) = "COMPANY1 - SITE1" Then
            $company = "COMPANY1"
            $city = "SITE1"
        EndIf

        If GUICtrlRead($URL_combo) = "COMPANY2 - SITE1" Then
            $company = "COMPANY2"
            $city = "SITE1"
        EndIf

        CreateHtml($company, $city)

        If Not FileExists($URL) Then
            MsgBox(262144, $script_version, "Unable to find " & $URL)
            Exit
        EndIf
    EndIf

    _IENavigate($IE, $URL, 0)

EndFunc   ;==>SetCamera

Func CameraRefresh()
    _IEAction($IE, "refresh")
EndFunc   ;==>CameraRefresh

Func Custom_COM_Error()

    $HexNumber = Hex($Custom_COM_Error.number, 8)
    MsgBox(0, "", "We intercepted a COM Error !" & @CRLF & _
            "Number is: " & $HexNumber & @CRLF & _
            "Windescription is: " & $Custom_COM_Error.windescription & @CRLF & _
            "Source is: " & $Custom_COM_Error.source & @CRLF & _
            "Description is: " & $Custom_COM_Error.description & @CRLF & _
            "Help file is: " & $Custom_COM_Error.helpfile & @CRLF & _
            "Help context is: " & $Custom_COM_Error.helpcontext & @CRLF & _
            "Last DLL error: " & $Custom_COM_Error.lastdllerror & @CRLF & _
            "Script line: " & $Custom_COM_Error.scriptline)


    $COM_Error = 1

    CameraRefresh()

EndFunc   ;==>Custom_COM_Error

Func Xbutton()
    FileDelete($URL)
    SetPosition()
    Exit
EndFunc   ;==>Xbutton
Edited by gcue
Link to comment
Share on other sites

i can do a fileinstall from the new one (script 1) to add the second script?

I think you can. Compile your second script to an exe and include it into Script1.

FileInstall('script2.exe', @TempDir & '\') Then
Run(@TempDir & "\script2.exe")

should work. Some additional error checking is necessary!

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Shellexecute makes the two scripts completely independant!

I think the unresponsiveness has some other reason.

To debug you could write the debug lines to a file.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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