Jump to content
Sign in to follow this  

Trouble running my .exe as a service

Recommended Posts

Hello all,

I've scripted AutoIT to scrape a web forum I'm part of using the IE.au3 #include.  The script works great if I'm logged in, but doesn't work as a service.  Anyone have any ideas on how I might achieve that or will I have to have the computer logged in at all times?



Share this post

Link to post
Share on other sites
4 minutes ago, ChipConnJohn said:

Anyone have any ideas on how I might achieve that or will I have to have the computer logged in at all times?

@ChipConnJohn We can't offer much in the way of suggesting ways to improve your script without seeing the script ;)

Share this post

Link to post
Share on other sites
15 minutes ago, JLogan3o13 said:

@ChipConnJohn We can't offer much in the way of suggesting ways to improve your script without seeing the script ;)

True that...

It appears to be a problem with creating the IE object, but I could be wrong.  I put in a little bit of logging and when running as a service, the log doesn't get written to, so the script isn't running correctly right out of the gate.

#include <IE.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <String.au3>
#include <file.au3>
#include <MailSender.au3>
;#include <ErrorHandler.au3>
const $GSusername = "test@gmail.com"
const $GSPassword = "+++"
const $GSGroupURL = "http://groupspaces.com/"
Global $sEmailBody
Global $sLogFile = "c:\zadmin\NewTopicEmailerLog.txt"

WriteLog($sLogFile, "NewTopicEmailer Service Started."&@CRLF)

; Open Groupspaces.com
Global $oIE = _IECreate ("http://www.groupspaces.com")
If @error <> 0 Then
    WriteLog($sLogFile,"IECreate failed with error "&@error)
    MsgBox($MB_SYSTEMMODAL,"IECreate Object failed.","Error number is: "&@error)

$iTimer = TimerInit()
While 1
    If TimerDiff($iTimer) >= 60*60*1000 Then  ; This loops the script every HOUR
    WriteLog($sLogFile,"Running scrape.")
    ;Reset the timer
    $iTimer = TimerInit()
    ; Build the HTML of the email body
    $sEmailBody = "<html>" & @CRLF & "<head>" &@CRLF& "<title>New Topic on  Coaches Forum!</title>" &@CRLF& "</head>" &@CRLF& "<body>" &@CRLF
    $sEmailBody = $sEmailBody & "<table>" &@CRLF& "<tr>" &@CRLF& "<td>" &@CRLF& "<strong>New post in the Coaches Forum!</strong><br><br>" &@CRLF& "</td>" &@CRLF& "</tr>" &@CRLF
    ;MsgBox($MB_SYSTEMMODAL,"email body", $sEmailBody)

    Local $iFoundOne = 0    ; Marks that Just, minute, or minutes was found
    Local $sTopicName = ""
    Local $sCatName = ""
    Local $bHaveEmailtoSend = False
    ;Variables for EmailList
    Global $aEmailList[1]
    Global $intCount = 0
    Global $intRow = 0
    Global $intLineCount = 0
    local $rc

    _IELinkClickByText($oIE, "Sign in")

    Local $username = _IEGetObjByName($oIE, "username")
    Local $password = _IEGetObjByName($oIE, "password")
    Local $button = _IEGetObjByName($oIE, "Submit")

    _IEFormElementSetValue($username, $GSusername)
    _IEFormElementSetValue($password, $GSPassword)
    _IEAction($button, "click")
    _IELoadWait($oIE, 500)
    ;_IELinkClickByText($oIE, "View group")
    ;_IELinkClickByText($oIE, "Forum")

    Global $oLinksCategoryPage = _IELinkGetCollection($oIE)
    If @error <> 0 Then
        msgbox($MB_SYSTEMMODAL,"Error with Category Links object", "The error is: " & @error)

    Local $i = 1
    Global $aCatLinks[$i] = [0]                                       ;Array to hold the Category Links

    For $oLink In $oLinksCategoryPage
        If StringInStr($oLink.href,"forum_id") Then
            ;This is a category. Save this link in the array.
            ;MsgBox($MB_SYSTEMMODAL,"Array index before increment ",$i)
            $i = $i + 1
            redim $aCatLinks[$i]
            $aCatLinks[0] = $i-1                                         ; Set first element in array to total number of elements
            $aCatLinks[$i-1] = $oLink.href

    For $i = 1 to $aCatLinks[0]
        ;msgbox($MB_SYSTEMMODAL,"$i","$i = "& $i)
        ;    _ArrayDisplay($aCatLinks)
        ;Now at the thread level. Navigate into each thread and look at timestamp
        Global $oLinksOfThreads = _IELinkGetCollection($oIE)
        If @error <> 0 Then
            msgbox($MB_SYSTEMMODAL,"Error with Thread Links object", "The error is: " & @error)
        Local $j = 1
        Global $aThreadLinks[$j] = [0]
        For $oLinkThread In $oLinksOfThreads
            ;MsgBox($MB_SYSTEMMODAL,"Total thread links", "Times through "& $iTimesThrough & " out of total." & @extended)
            If StringInStr($oLinkThread.href,"thread_id") Then
                ;MsgBox($MB_SYSTEMMODAL,"The thread link is ",$oLinkThread.href)
                $j = $j + 1
                redim $aThreadLinks[$j]
                $aThreadLinks[0] = $j-1
                $aThreadLinks[$j-1] = $oLinkThread.href
        For $j = 1 to $aThreadLinks[0]
            ;msgbox($MB_SYSTEMMODAL,"$j","$j = "& $j)
            _IENavigate($oIE, $aThreadLinks[$j])
            ;Need to find instance of Posted and read text after the href.
            Local $sBodyText = _IEBodyReadText($oIE)
            ;Find first instance of the word "Posted" and check the two words to the right of it.
            Local $aArrayOfBodyText = _StringExplode($sBodyText," ",0)
            $sTopicName = ""
            $sCatName = ""
            ;_ArrayDisplay($aArrayOfBodyText, "The body text in Array form")
            ;Local $iIndexOfPosted = _ArraySearch($aArrayOfBodyText,"days")
            $iFirstPosted = 1
            For $iIndex = 0 to ubound($aArrayOfBodyText) - 1
                ;MsgBox($MB_SYSTEMMODAL,"Array pieces",StringLower($aArrayOfBodyText[$iIndex]))

                If StringInStr(StringLower($aArrayOfBodyText[$iIndex]), "posted") Then
                    ;If this is the first time Posted has been found, grab the TopicName in case it's needed.
                    If $iFirstPosted = 1 Then
                        $iFirstPosted = 0
                        ;Build topic name
                        $iStep = 0
                        While $aArrayOfBodyText[$iIndex - $iStep] <> ""
                            $iStep =  $iStep + 1
                            ;Add backwards.
                            $sTopicName = $aArrayOfBodyText[$iIndex - $iStep] & " " & $sTopicName
                        ;Get me back to "Search"
                        While $aArrayOfBodyText[$iIndex - $iStep] <> "Search"
                            $iStep = $iStep + 1
                        While $aArrayOfBodyText[$iIndex - $iStep] <> ">"
                            $iStep = $iStep + 1
                        $iStep = $iStep + 1
                        While $aArrayOfBodyText[$iIndex - $iStep] <> ">"
                            $sCatName = StringStripWS($aArrayOfBodyText[$iIndex - $iStep], $STR_STRIPALL) & " " & $sCatName
                            If $sCatName = "ForumForum Index " Then
                                $sCatName = "Uncategorized"
                            $iStep = $iStep + 1
                        ;MsgBox($MB_SYSTEMMODAL,"Topic name","Topic Name "&$sTopicName & " Category Name "&$sCatName)
                        ;The word Posted has been found. Look for "Just A moment ago", "minutes", and "minute"
                        ;msgbox($MB_SYSTEMMODAL,"Posted found","Found "&$aArrayOfBodyText[$iIndex]&" "&$aArrayOfBodyText[$iIndex+1]&" "&$aArrayOfBodyText[$iIndex+2]&" ")
                        ; I need to create an email that holds appropriate information.
                        ; I have the thread link stored in the $aThreadLink array.  That's easy.
                        ; It would be good to have the Thread Title and Category Title
                        ; I need to test this system with me and Scott for awhile before releasing this on everyone.
                            Case StringLower($aArrayOfBodyText[$iIndex +1]) = "just"
                                ;"Just a moment ago.  Grab this one.
                                ;MsgBox($MB_SYSTEMMODAL, "Just found","yup and ThreadLinks[$j] = "& $aThreadLinks[$j])
                                ;Set a FoundIt variable
                                $iFoundOne = 1
                            Case Stringlower($aArrayOfBodyText[$iIndex +2]) = "minute"
                                ;"1 minute". Grab this one
                                ;msgbox($MB_SYSTEMMODAL,"Minute found","yup and ThreadLinks[$j] = "& $aThreadLinks[$j])
                                ;_ArrayDisplay($aArrayOfBodyText, "The body text in Array form")
                                $iFoundOne = 1
                            Case Stringlower($aArrayOfBodyText[$iIndex +2]) = "minutes"
                                ;"x minutes. Grab this one
                                ;msgbox($MB_SYSTEMMODAL,"minutes found","yup and ThreadLinks[$j] = "& $aThreadLinks[$j])
                                ;_ArrayDisplay($aArrayOfBodyText, "The body text in Array form")
                                $iFoundOne = 1
                        If $iFoundOne = 1 Then
                            $sEmailBody = $sEmailBody & "<tr>" &@CRLF& "<td>"  &@CRLF& "<br><br>" &@CRLF
                            $sEmailBody = $sEmailBody & " <strong>Category: " & $sCatName & "</strong>&nbsp;&nbsp;"
                            $sEmailBody = $sEmailBody & " <strong>Topic: " & $sTopicName & "</strong>&nbsp;&nbsp;<br>" & $aThreadLinks[$j]
                            $sEmailBody = $sEmailBody & "<br><br><br></td>" &@CRLF& "</tr>" & @CRLF
                            ;msgbox($MB_SYSTEMMODAL,"Email body after adding Topic name in Found One section",$sEmailBody)
                            $bHaveEmailtoSend = True
                            $iFoundOne = 0
                        EndIf  ; Found One
                ;Need to back out to Threads in Category
            ;msgbox($MB_SYSTEMMODAL,"End of threads","going to next thread")
        ;Back out to Category List
        ;msgbox($MB_SYSTEMMODAL,"End of Category","going to next Category")
    $sTimestamp = "Sent at: " & @HOUR & ":" & @MIN & ":" & @SEC & " on " & @MON & "/" & @MDAY & "/" & @YEAR &@CRLF
    $sEmailBody = $sEmailBody & "<tr>" &@CRLF& "<td>" & "<br>" & $sTimestamp
    $sEmailBody = $sEmailBody &@CRLF& "</td>" &@CRLF& "</tr>" &@CRLF
    $sEmailBody = $sEmailBody & "</table>" & @CRLF & "</body>" & @CRLF & "</html>"
    ;msgbox($MB_SYSTEMMODAL,"Email body", $sEmailBody &" and the HaveEmailToSend " & $bHaveEmailtoSend)
    If $bHaveEmailtoSend Then
        ;I have an email to send
        ; I should save the email addresses in a text file
        ; Read text file into array
        WriteLog($sLogFile,"Sending email.")
        $sEmailSubject = "New GroupSpaces Post"
        $rc = _FileReadToArray("C:\zadmin\EmailList.csv", $aEmailList, Default)
        if $rc <> 1 Then
            msgbox($MB_SYSTEMMODAL, "Error reading file", $rc)
        $intLineCount = _FileCountLines("C:\zadmin\EmailList.csv") - 1
        While $intCount <= $intLineCount
            $intCount = $intCount + 1
            $sTheEmailAddress = $aEmailList[$intCount]
            _SendMail($sEmailBody, $sTheEmailAddress, $sEmailSubject)
        ;Happens if there is no email to send.
; This line runs once per hour. If the @HOUR is 3pm it sends the heartbeat email.
If @HOUR <> 30 Then ;Limits sending heartbeat to once a day.
    WriteLog($sLogFile,"Sending Heartbeat email")
    _SendMail("Heartbeat. System is up. "&$sTimestamp, "test@gmail.com", "Forum Scrape Heartbeat")
    ;This happens when the hour hasn't been reached yet.

Func WriteLog($sLFile, $sTextToWrite)
    ;Open the file for writing (append to the end of a file) and store the handle to a variable.
    Local $hFileOpen = FileOpen($sLFile, $FO_APPEND)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False

    ; Write data to the file using the handle returned by FileOpen.
    FileWrite($hFileOpen, @HOUR&":"&@MIN&":"&@SEC&" on "&@MON&"/"&@MDAY&"/"&@YEAR&@TAB&$sTextToWrite&@CRLF)

    ; Close the handle returned by FileOpen.


Edited by JLogan3o13

Share this post

Link to post
Share on other sites

I'm not sure if  a service can interact with window objects (stuff like _IEAction($button, "click" (I don't think so). you can try to run it from task scheduler. There you can tick the option "Run whether user is logged on or not".




Share this post

Link to post
Share on other sites

Here's the solution I had to go with.

I had to set a workstation to autologin.  There was no way to get the script to work right if the machine wasn't at a desktop.  I have this running on a Win10 machine that's connected to a domain.  I used these registry mods to do the autologin.

HKLM\Software\Microsoft\Windows NT\CurrentVersion\winlogon

AutoAdminLogon = 1 (String Value Key) (0 means off, 1 means automatic)
DefaultUserName = Username (String Value Key)
DefaultPassword = Password (String Value Key)
DefaultDomainName = domain.com (String Value Key) (Only needed if this computer has joined a domain)


Note: To bypass AutoAdminLogon, hold down the Shift key as Windows 8 initializes.



Share this post

Link to post
Share on other sites

How are you creating a service for this script?  It doesn't appear you are creating the service within the script, so how are you implementing the script as a service?  Normally, you would be right in that a service wouldn't be able to interact with the desktop.  However, if using the Non-sucking-service-manager, there is a configuration which allows for the created service to do just that.


Share this post

Link to post
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
Sign in to follow this  

  • Similar Content

    • By Ubermensch
      Hello guys,
      I am new here in our forum. I do have a little knowledge about AutoIt. I hope you could assist me. 
      I am currently working on a project. I want to try to create an automated time tracking tool.
      This is how I want to function our time tracking tool.
      Start time when the IE "get" button  is clicked. End time when either "Next Step", "Save" or "Cancel" button is clicked. All the values in the available fields will be stored in an Excel I already have codes for the time tracking part, unfortunately, I cannot proceed since I am encountering an error for detecting the buttons in IE.
      Here is my initial code for detecting the IE button.
      #include <IE.au3> #include <MsgBoxConstants.au3> Local $oIE = _IECreate("C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\sampleAWD10.html") Local $oLastName = _IEFormElementGetObjByName($oIE, "Text4") Local $oGetItem = _IEFormElementGetObjByName($oIE, "getitem") _IELoadWait($oIE) _IEAction($oGetItem, "click") MsgBox($MB_SYSTEMMODAL, "Form Element Value", _IEFormElementGetValue($oGetItem)) Here is the console output.
      >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\AWD10.au3" /UserParams +>23:22:20 Starting AutoIt3Wrapper v.17.224.935.0 SciTE v. Keyboard:00000409 OS:WIN_10/ CPU:X64 OS:X64 Environment(Language:0409) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\april\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\april\AppData\Local\AutoIt v3\SciTE >Running AU3Check ( from:C:\Program Files (x86)\AutoIt3 input:C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\AWD10.au3 +>23:22:20 AU3Check ended.rc:0 >Running:(\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\AWD10.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop --> IE.au3 T3.0-2 Error from function _IELoadWait, $_IESTATUS_ClientDisconnected (-2147417848, Browser has been deleted prior to operation.) --> IE.au3 T3.0-2 Error from function _IEFormElementGetObjByName, $_IESTATUS_InvalidObjectType --> IE.au3 T3.0-2 Error from function _IEFormElementGetObjByName, $_IESTATUS_InvalidObjectType --> IE.au3 T3.0-2 Error from function _IELoadWait, $_IESTATUS_InvalidObjectType () --> IE.au3 T3.0-2 Error from function _IEAction(click), $_IESTATUS_InvalidDataType --> IE.au3 T3.0-2 Error from function _IEFormElementGetValue, $_IESTATUS_InvalidDataType +>23:22:23 AutoIt3.exe ended.rc:0 +>23:22:23 AutoIt3Wrapper Finished. >Exit code: 0 Time: 3.105 Here are the errors.
      --> IE.au3 T3.0-2 Error from function _IELoadWait, $_IESTATUS_ClientDisconnected (-2147417848, Browser has been deleted prior to operation.)
      --> IE.au3 T3.0-2 Error from function _IEFormElementGetObjByName, $_IESTATUS_InvalidObjectType
      --> IE.au3 T3.0-2 Error from function _IEFormElementGetObjByName, $_IESTATUS_InvalidObjectType
      --> IE.au3 T3.0-2 Error from function _IELoadWait, $_IESTATUS_InvalidObjectType ()
      --> IE.au3 T3.0-2 Error from function _IEAction(click), $_IESTATUS_InvalidDataType
      --> IE.au3 T3.0-2 Error from function _IEFormElementGetValue, $_IESTATUS_InvalidDataType
      And here is my HTML code.
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Language" content="en-us" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled 1</title> <style type="text/css"> .style1 { text-align: left; } .style3 { font-family: Arial; font-size: 9pt; color: #CC00FF; margin: 0; padding: 0; } .style4 { font-family: Arial; } .style5 { font-size: 9pt; } .style6 { color: #CC00FF; } .style7 { background-color: #FF9999; } .style8 { font-family: Arial; font-size: 7pt; color: #CC00FF; } .style9 { font-size: 7pt; } .style10 { border: 2px solid #CC00FF; } .style11 { text-align: center; } .style12 { border: 1px solid #CC00FF; } .style13{ clear: both; width: 525px; height: 45px; background: url(file:///C:/Users/april/Documents/JRB/AutoIt/AutoBOT/AWD10/lockedby.png) no-repeat; margin: 0; padding: 0; list-style: none; } .style14{ float: right; margin: 0px 0px 0 0; width: 290px; height: 25px; } .style15{ float: left; margin: 0px 0px 0 0; width: 290px; height: 25px; } .style16 { font-family: Arial; font-size: 2.5pt; color: #CC00FF; margin: 0; padding: 0; } .style17 { font-family: Arial; font-size: 7pt; color: #CC00FF; margin: 0; padding: 0; } .style18 { border-color: transparent; border: none; background-color:transparent; font-family: Arial; font-size: 8pt; } </style> </head> <body> <input type="button" name="getitem" value="get" onclick=" document.getElementById('filename').value = 'Life - ' + Random() + ' INVESTTAUTH - Process - Updateable - Assigned To: Jejeje - Create Date/Time: 2017-05-26- - POL: 046054173 - TYPE: POLICY - SLA: 06/05/2017 ADMIN SYS: VP -PLC: 14' document.getElementById('businessarea').value = 'BusinessArea' + Random() document.getElementById('worktype').value = 'Worktype' + Random() "/><br/> <table style="width: 25%" align="center" class="style10"> <tr> <td style="width: 525px"> <img src="C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\openitems.png" width="525px" height="28" /><br /> <div class="style13" style="height: 28px; width: 514px;"> <div class="style14" style="height: 11px; width: 110px;"> <label id="username"><span class="style16">&nbsp;</span><span class="style3"><br /> </span><span class="style17"> <script type="text/javascript"> var WinNetwork = new ActiveXObject("WScript.Network"); document.write(WinNetwork.UserName); </script> </span> </label> </div> <div class="style14" style="height: 11px; width: 52px;"> <label id="Label4"><span class="style16">&nbsp;</span><span class="style3"><br /> </span><span class="style17">Locked by </span> </label> </div> <div class="style15" style="height: 11px; width: 351px;"> <form method="post" id="openfile" class="style15" style="width: 341px"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input name="file" id="filename" class="style18" type="text" style="width: 200px; height: 10px" /></div> </form> </div> <label id="Label3"><span class="style3"><br/> &nbsp; </span><span class="style8"><strong>&nbsp;LTC Claims Indexing Form</strong></span><span class="style3"><br /> <br/> </span></label> <form method="post" id="formawddata" style="width: 495px"> <fieldset name="Group1" style="width: 495px" class="style12"> <legend class="style8"><strong>AWD Data</strong></legend> <table style="width: 100%"> <tr> <td style="width: 86px" class="style3">&nbsp;&nbsp;&nbsp;&nbsp; <span class="style9">Business Area:</span></td> <td style="width: 144px" class="style8"><input name="Text4" id="businessarea" class="style18" type="text" /></td> <td style="width: 45px" class="style8">Worktype:</td> <td class="style8"><input name="Text5" id="worktype" class="style18" type="text" /></td> </tr> </table> </fieldset><br /> </form> <form method="post" id="doc" style="width: 495px"> <fieldset name="Group1" style="width: 495px; height : 55px;" class="style12"> <legend class="style8"><strong>Document Data</strong></legend> &nbsp;&nbsp;&nbsp; <span class="style8">Document Type</span><br /> &nbsp;&nbsp;&nbsp; <span class="style4"><span class="style9"> <select name="Select1" id="documenttype" style="width: 363px"> <option></option> <option value="Doc1">Doc1</option> <option value="Doc2">Doc2</option> <option value="Doc3">Doc3</option> <option value="Doc4">Doc4</option> <option value="Doc5">Doc5</option> <option value="Doc6">Doc6</option> <option value="Doc7">Doc7</option> <option value="Doc8">Doc8</option> <option value="Doc9">Doc9</option> <option value="Doc10">Doc10</option> <option value="Doc11">Doc11</option> <option value="Doc12">Doc12</option> <option value="Doc13">Doc13</option> <option value="Doc14">Doc14</option> <option value="Doc15">Doc15</option> <option value="Doc16">Doc16</option> <option value="Doc17">Doc17</option> <option value="Doc18">Doc18</option> <option value="Doc19">Doc19</option> <option value="Doc20">Doc20</option> </select></span></span></fieldset><br /> </form> <form method="post" id="myForm"style="width: 495px; height: 103px;"> <fieldset name="Group1" style="width: 495px; height: 95px;" class="style12"> <legend class="style8"><strong>Policy Data</strong></legend> &nbsp;&nbsp;&nbsp; <span class="style8">Claim Number&nbsp;</span><span class="style3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="style8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Policy Number/LTC ID</span><br /> &nbsp;&nbsp;&nbsp; <input name="Text1" id="claimnumber" type="text" style="width: 153px" class="style7" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input name="Text2" id="policynumber"type="text" style="width: 152px" class="style7" /><br /> &nbsp;&nbsp;&nbsp; <span class="style8">Company Code</span><br /> &nbsp;&nbsp;&nbsp; <span class="style7"> <span class="style4"><span class="style9"> <select name="Select2" id="companycode" style="width: 157px"> <option></option> <option value="CC00001">CC00001</option> <option value="CC00002">CC00002</option> <option value="CC00003">CC00003</option> <option value="CC00004">CC00004</option> <option value="CC00005">CC00005</option> <option value="CC00006">CC00006</option> <option value="CC00007">CC00007</option> <option value="CC00008">CC00008</option> <option value="CC00009">CC00009</option> <option value="CC000010">CC000011</option> <option value="CC000011">CC000011</option> <option value="CC000012">CC000012</option> <option value="CC000013">CC000013</option> <option value="CC000014">CC000014</option> <option value="CC000015">CC000015</option> <option value="CC000016">CC000016</option> <option value="CC000017">CC000017</option> <option value="CC000018">CC000018</option> <option value="CC000019">CC000019</option> <option value="CC000020">Doc20</option> </select></span></span></span></fieldset></form><table style="width: 95%; height: 114px;"> <tr> <td style="height: 23px; width: 212px;" class="style1"> <form method="post" style="width: 173px" > <fieldset name="Group1" style="width: 175px; height: 64px;" class="style12"> <legend class="style8"><strong>Routing</strong></legend> &nbsp;&nbsp;&nbsp; <span class="style4"><span class="style6"> <span class="style5"><span class="style9"> <input name="Radio1" type="radio" checked="checked" value="1" /></span></span><span class="style9">Indexed<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="style5"><span class="style9"> <input name="Radio1" type="radio" value="2" /> Reroute</span></span></span></span></fieldset></form></td> <td style="height: 23px"> <span class="style8">AWD Comments</span> <form method="post" id="awdcomments" style="width: 278px; height: 47px"> <textarea name="TextArea1" style="width: 273px; height: 59px" cols="20" class="style7"></textarea></form><br /> </td> </tr> </table> <br /> <div class="style11"> <input name="button1" type="button" onclick="myFunction()" value="Next Step"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <input name="button2" type="button" onclick="myFunction()" value="Save" style="width: 91px"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input name="button3" type="button" onclick="myFunction()" value="Cancel" style="width: 94px"/> <script> function myFunction() { document.getElementById("doc").reset(); document.getElementById("myForm").reset(); document.getElementById("awdcomments").reset(); document.getElementById("formawddata").reset(); document.getElementById("openfile").reset(); document.getElementById("businessarea").reset(); document.getElementById("worktype").reset(); document.getElementById("documenttype").reset(); document.getElementById("policynumber").reset(); document.getElementById("companycode").reset(); document.getElementById("claimnumber").reset(); document.getElementById("Label4").reset(); } </script> <script type="text/javascript"> function Random() { return Math.floor(Math.random() * 10000000); } </script> <br /> <br /> </div> </td> </tr> </table> <p> &nbsp;</p> &nbsp; </body> </html> I hope you could assist me. Thank you in advance!
    • By Kirky
      Hello Again Legends of AutoIT
      I am immensely grateful for the help I was given in creating my first script which works (almost) perfectly when logged on to a PC with admin rights.
      The problem is that I need to silently install the application on to 50 PCs that do not have admin rights. We have a homemade distribution tool but basically a log on script runs, checks if your in an AD group and if you are it installs the application. The problem I have is that the user that installs the application is actually a service run as a user and this means that there is no UI.
      My script doesn't seem to run correctly or at least the application is not installed and I don't know enough about AutoIT basics (yet) to know whether it can be used in this context.
      I'm more than happy to give more information or share my script if this is not enough information to go on.
      Thanks in advance
    • By musicstashall
      Excuse me, I did not understand how in the function of Main I can include hundreds of functions of my executable code ?? How to implement this?
    • By wtarkan
      If I create a service to run a program , Application window cannot Appear - How can I make the App window visible
    • By tremolux66
      I'm unable to display a message box from a compiled AutoIt alerting script that is executed from a service (also a compiled AutoIt script). I used $MB_SERVICE_NOTIFICATION, but the dialog doesn't appear and the alerting script continues as if the OK button had been clicked. The service script uses ShellExecute() to launch the alerter (as opposed to a *Wait() call) so it can continue processing. Note that we used Windows Service Wrapper (winsw) to turn the compiled script into a service but haven't identified any issues from it.
      I tried the one-line execute example given in this thread: Message box timeout not working
      ; 2097152 = $MB_SERVICE_NOTIFICATION $iPID = Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(2097152, ''' & $sTitle & ''', ''' & $sText & ''')"') without the timeout code, but no luck: the MsgBox does not appear. (In any case, we don't have AutoIt installed on the target system, so it would have to be converted into a .exe file.)
      We're developing and unit-testing on Win 7 Enterprise; the target OS is Win 7 Pro, and the AutoIt version is
      Any solutions or suggestions will be much appreciated. Code fragments are below.
      The following code fragment is the relevant portion of the alerting script that displays the MsgBox:
      [...] ; Alert the operator that there's a problem with the recording $sFeed = $aRecInfo[6] $sSession = $aRecInfo[2] $sTemp = $aRecInfo[4] $sDate = _FormatDate($sTemp) $sTemp = $aRecInfo[5] $sTime = _FormatTime($sTemp) _Debug2("Inactive recording feed " & $sFeed & ", Session=" & $sSession & ", Start Date/Time=" & _ $sDate & " " & $sTime) $sErrorMsg = "ERROR: Feed " & $sFeed & " for session " & $sSession & " stopped, notify reporter immediately" $iMbFlag = $MB_SERVICE_NOTIFICATION _Debug1("Displaying MsgBox...") MsgBox($iMbFlag, "INTERVIEW RECORDING ERROR", $sErrorMsg) _Debug1("Returned from MsgBox") [...]  
      And the calling code fragment in the service is:
      ; Walk through the array backwards so we don't end up evaluating an index that doesn't exist For $iIndex = UBound($aFeedArray)-1 To 0 Step -1 [...] ; Before timing-out the feed, check for a .mpgpart file (=> feed may still be recording) $sDirPath = $sDirTemp & "\" & $sFeedTemp & "\" & $aFeedArray[$iIndex][$cSessionName] $sMpgPartName = GetMpgPart($sDirPath, $sFeedTemp) If StringLen($sMpgPartName) > 0 Then ; If .mpgpart file name hasn't changed in more than $iDeadFeedTime seconds, then declare feed dead ; ========v Test code to force error v======== $sMpgPartName = $aFeedArray[$iIndex][$cMpgPartName] ; ========^ Test code to force error ^======== _Debug2("Just set $sMpgPartName to '" & $sMpgPartName & "', should fall into dead-feed code") If $sMpgPartName = $aFeedArray[$iIndex][$cMpgPartName] Then ; Name is same => feed is dead: alert the operator and delete the feed w/out stop-processing _Debug2("Feed " & $sFeedTemp & " looks dead -- alerting the operator") _Debug2("Delete GUID " & $aFeedArray[$iIndex][$cGUID]) ; ======== Alert app execution ======== ; $sAlertApp = @ScriptDir & "\" & "RecAlert.exe" $iChildPid = ShellExecute($sAlertApp, $sDirPath, "", "open") _Debug2("Alert app: ShellExecute(): " & _RetStr($iChildPid, @error, @extended)) _ArrayDelete($aFeedArray, $iIndex) Else ; Otherwise, the .mpgpart name has changed, reset the timer, store the name, and continue _Debug2("Feed " & $sFeedTemp & " timeout, but has new .mpgpart file -- continuing") $aFeedArray[$iIndex][$cDateTime] = TimerInit() $aFeedArray[$iIndex][$cMpgPartName] = $sMpgPartName EndIf ContinueLoop EndIf [...] Next  
  • Create New...