Sign in to follow this  
Followers 0
swstrau118

Time People Schedule Help!

3 posts in this topic

I am trying to write a script that will eventually go into a GUI but for now I'm just trying to get the script to run. I am trying to see "Who's Working" according to the times. I am having trouble with the overlap. If the end of someone's shift is 3pm but you're coming in at 1pm I can't view the two people only one. Also Trying to figure out how correlate people with dates (haven't been able to figure out how to put that in for the whole month) and when I'm calling the times can I do 17:30? I have issues with that as well. Any help would be greatly appreciated! 

Attached is the txt file that should be on the Desktop and the au3 code. but I'll paste the code in here as well.

; Determine workgroup and shift  (These are hardcoded here but can be determined any way you want)
Local $workgroupName = _WorkGroup()
Local $shift = _Time()

; Build header to search the text file for
Local $contactHeader = $workgroupName & $shift

; Declare variable to hold the body of the contact info to display
Local $contactBody = ""

; Create file handle
Local $file = FileOpen(@DesktopDir & "\ContactInfo.txt", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in lines of text until the EOF is reached
While 1
    ; Read line
    Local $line = FileReadLine($file)
    ;Handle Error
    If @error = -1 Then ExitLoop
    
    ; search for workgroup header
    if $line = $contactHeader then
    
        ; Read next line
        $line = FileReadLine($file)
        
        ; Build contact info body until terminator is reached
        Do      
            ; Add current line to contact body plus a carriage return ASCII code 
            ;   so that a new line begins next time through the loop
            $contactBody = $contactBody & $line & chr(13)
            ; Read next line
            $line = FileReadLine($file)
        
        Until $line = ";"
    
        ; Exit while loop to read file
        ExitLoop
    
    EndIf
    
WEnd

; Close file
FileClose($file)

; Populate label for message box
Local $contactString = "Workgroup: " & _WorkGroup() & chr(13)
$contactString = $contactString & "Shift: " & _Time() & chr(13) & chr(13)
$contactString = $contactString & $contactBody

; Display message box
MsgBox(4096, "Contact Info", $contactString)

Func _Time()
    Local $AMPM, $hour
    If @HOUR <= 05 Then
        $hour = ("Night")
    ElseIf @hour >= 18 Then
        $hour = ("Night")
    ElseIf
        $hour = ("Day")
    EndIf
    Return $hour
EndFunc ;==>_Time

Func _WorkGroup()
    Local $AMPM, $hour
    If @HOUR >= 02 And @HOUR <=11 Then
        $hour = ("Workgroup2")
    ElseIf @HOUR >= 10 And @HOUR <= 19  Then
        $hour = ("Workgroup3")
    ElseIf @HOUR >= 23 And @HOUR <= 08 Then
        $hour = ("Workgroup1")
    EndIf
    Return $hour
EndFunc ;==>_Time

ContactInfo.au3

ContactInfo.txt

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

It sounds like you're trying to manage employee times and contact data.  Wouldn't you be better off using MS Access, MS Excel, or another program to view/manage all that data?  I have personally used both Access & Excel, and they're good at what they do (and VB has a built-in datatype for handling time/dates).  You can do this in AutoIt if you like, but it's usually better not to reinvent the wheel.  If you want to use AutoIt anyway, check out the UDF called Date.au3 in your Include directory (or Help File -> UDFs -> Date Management).  You'll find lots of useful functions there.

Edited by Artisan

Share this post


Link to post
Share on other sites

See I get all that information sent every month that is on an Excel spreadsheet with 6 different tabs. I was going to have all that information put on one tab then pull that data into a text file and you could hit a button and it wil show you these people (according to the time[i got that figured out] and date[no clue how to do this one] display who is working. The information needs to be access quickly and would be put into a GUI that i created that houses buttons that link to different information so it's easier and faster to access. I'm just stuck on how to refer this to the dates for each month..

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  
Followers 0

  • Similar Content

    • TotalAuto
      By TotalAuto
      Howdy All
      I've gone around and around in circles wasting hours trying to fix this problem to no avail so I thought I would try posting for help given there are some real smart people in this forum.
      Background
      I have 5 separate .au3 scripts that all do different basic tasks. For example:
      1.au3 = opens Chrome browser to obtain information from a specific website then closes
      2.au3 = opens an Excel workbook to run a macro then saves and closes
      3.au3 = Open two seperate workbooks and transfers data from one to the other then saves and closes
      4.au3 = .......etc
      5.au3 = .......etc
      These 5 separate scripts, doing completely different tasks, need to each run once per day at 5 different designated times within a day and then close. For example:
      1.au3 = 10am
      2.au3 = 12pm
      3.au3 = 2pm
      4.au3 = 4pm
      5.au3 = 5pm
      Problem
      I can not get these different scripts to reliably run at their designated times. When I manually run these scripts individually by using 'Go F5' they work perfectly. If I convert these scripts to an .exe and manually run each one they work about 98% of time.
      How can I schedule these different .au3 files or associated .exe files to reliably run each day at different times?
      Attempts To Fix The Issue
      1. I have tried converting each .au3 script into their own .exe file and use Window's Task Scheduler to run these .exe files at their designated time but the success rate  of running each .exe in full, to completion, without error is very low at about 30%. Things that commonly go wrong include a browser not opening but movement still continues on the desk top. Other times things just do not happen at all.
      2. I have Windows 7 64 bit and have tried creating and running both (x86) and (x64) .exe files but again reliability problems exist;
      3. I have also tried moving each .exe file to the My Documents folder as I read someone that keeping your files on your desktop ties your files to individual Windows user profiles which can cause AutoIt operating errors. Not sure if this is correct but thought I would try it anyway. It did not fix my issue.
      4. I installed a program called AlwaysUp which supposedly always reliably runs in the background and will reliably execute your AutoIt script or .exe files. Still have significant reliability issues.
      Therefore, can someone please provide advice on how I can get my 5 different .au3 files to run at 5 designated times through the day, every day, without fail? Overtime I will be creating more and more different .au3 files to run certain tasks throughout the day and do not want to create one large AutoIt file that continually runs and attempts to do all the different tasks itself.
      Any help is very appreciated.
      Thanks
      Dan
       
       
    • houser747
      By houser747
      I have previously used _IEFormElementGetObjByName and _IEFormElementSetValue to enter text into a search box on a form and then submit the form.
      I am now trying to enter text into a search box which is not part of a form. 
      Here is the HTML from the website that i'm trying to enter the data on and then submit the search.
      <div class="row">
          <div class="form-group col-xs-12">
              <span id="FullWidthWithSubmenuContent_FullWidthContent_MainContent_AircraftRegistry_lblSearchText" for="input-search">Registreringsbeteckning</span>
              <div class="input-group col-xs-12">
                  <span id="FullWidthWithSubmenuContent_FullWidthContent_MainContent_AircraftRegistry_preSearchText" class="input-group-addon">SE -</span>
                  <input name="ctl00$FullWidthWithSubmenuContent$FullWidthContent$MainContent$AircraftRegistry$txtSearchText" type="text" value="DTH" id="FullWidthWithSubmenuContent_FullWidthContent_MainContent_AircraftRegistry_txtSearchText" class="form-control" />
              </div>
          </div>
      </div>
      <div class="row">
          <div class="form-group col-xs-12">
              <label class="sr-only" for="">Sök</label>
              <input type="submit" name="ctl00$FullWidthWithSubmenuContent$FullWidthContent$MainContent$AircraftRegistry$btnSearch" value="Sök" id="FullWidthWithSubmenuContent_FullWidthContent_MainContent_AircraftRegistry_btnSearch" class="btn btn-primary ladda-button" data-style="expand-right" />
          </div>
      </div>
      Many thanks in advance
      cheers
      Roger
    • robcull
      By robcull
      Hello all! I have had some issues reading text from different types of windows, occasionally, specifically with controlgettext. 
      **Before I begin, I know there are better ways to do what I attempt in the example below. That's not the point of this post. The point is my issues with controlgettext. 
      I am about to cite an example with an application you may be familiar with called SpeedFan (v4.52). My problem is not specific to speedfan, it is simply the most recent and easily reproducible example I can think of. 
      So, the goal of the script below is to get a string of text containing the current fan RPMs from the highlighted control in the screenshot below (see "speedfan_control_details.png").

      Now, here's a simple script for grabbing the window handle and reading the text from that control: 
      $wintitle = "SpeedFan 4.52" $controlID = "197934" ;will be reformatted as "[ID:######]" $hwnd = wingethandle($wintitle) if @error<>0 then msgbox(0, "WinGetHandle", "FAILURE. @error="&@error) Exit EndIf $text = ControlGetText($hwnd, "", "[ID:"&$controlID&"]") if @error=1 then msgbox(0, "ControlGetText", "FAILURE. @error="&@error) ;failure returns "" and @error=1 Exit EndIf msgbox (0, "ControlGetText", "SUCCESS. @error="&@error &@CRLF& "$text="&$text) ;success returns string and @error=0 You'll see that the ControlGetText operation runs without error, however it does not capture any text from the control. If you explore the other controls in this one window, you'll find mixed results across the board. Neither the temps nor voltages can be read, while the log field and some other elements can be read. Even when you read the text from the whole window, those elements are not included in the visible nor hidden texts. 
       
      I have run into this issue many times in the past- inconsistencies in the ability of autoit to interact with certain controls. What is it which makes this text different than any other readable texts? Is there an alternate method of reading the text in the window/control which could work? Any and all info to help me solve this mystery and satisfy my curiosity would be greatly appreciated. 
      Thanks  -Rob C
      PS: Running Autoit v3.3.14.2 on Win7 Ultimate x64
    • thoms
      By thoms
      Hello Forum,
      I'm trying to vertically center text in label controls, but no way. The search on the forum returns no result, or I don't search the right way
      When I insert a button and a label of same size close to each other, the text is centered on the button, but top aligned on the label, or edit. Which doesn't look really aesthetic
      Any idea is welcome
      Thanks in advance,
      Thoms
    • nacerbaaziz
      By nacerbaaziz
      Hello my friends
      I am a totally blind young man
      for easier to read books and articles Among the blind
      i has programmed a tool
      This tool converts text to audio with the possibility to save it into a wav or mp3 file
      It is also compatible with all persons, whether blind or ordinary
      I have completed the work of this tool and want to take your opinion
      i Especially published here for anyone looking about how to convert text to speech, I will put this tool open source for you
      I want to know what your think about it
      and if it need any other additions?
      Note :
      This tool converts texts to audio using sapi 5 voices
      so i was also puted a hot keys to control the tool
      Now I put this project to you for public benefit and I am ready to answer any question.
      Apology :
      I am an Arab youth from Algeria
      I do not mastered English very well
      So I apologize to you if there are written mistakes
      With my greetings and best wishes
      My texts to audio converter.zip