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

    • 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
    • Realm
      By Realm
      After Several Minutes searching the forums for a simple solution to calculating for the Unix Time, as required for another project I am working on, I was astonished to not find one clean and universal solution. After looking over the helpfile, I noticed one simple solution given in the example with _DateDiff(). However it did not account for my current timezone or daylight savings time.
      Without further ado... This is my example of Calculating for a current Unix Time stamp or  seconds since Jan, 1st, 1970 00:00:00 GMT.
      This function will account for your timezone as well as for daylight savings time.
      Update: v0.3
      -Added Function to revert a Unix Time stamp into Date form.
      -Added parameter to original _GetUnixTime() allowing for a custom date since Jan 1st 1970 to be passed and converted to Unix Time.
      #include <Date.au3> #include <Array.au3> #include <Constants.au3> Local $iUnixTime1 = _GetUnixTime() MsgBox($MB_SYSTEMMODAL, "Unix Timestamp", "Seconds Since Jan, 1st, 1970 00:00:00 GMT" & @CRLF & $iUnixTime1) Local $sUnixDate1 = _GetDate_fromUnixTime($iUnixTime1) MsgBox($MB_SYSTEMMODAL, "Unix Timestamp", "Get Date from Unix Timestamp in Local Time" & @CRLF & $sUnixDate1) $sUnixDate1 = _GetDate_fromUnixTime($iUnixTime1, False) MsgBox($MB_SYSTEMMODAL, "Unix Timestamp", "Get Date from Unix Timestamp with $iReturnLocal = False which returns UTC Time" & @CRLF & $sUnixDate1) Local $iUnixTime2 = _GetUnixTime('2013/01/01 00:00:00') MsgBox($MB_SYSTEMMODAL, "Unix Timestamp", "Seconds since 2013/01/01 00:00:00" & @CRLF & $iUnixTime2) ; Get timestamp for input datetime (or current datetime). Func _GetUnixTime($sDate = 0);Date Format: 2013/01/01 00:00:00 ~ Year/Mo/Da Hr:Mi:Se Local $aSysTimeInfo = _Date_Time_GetTimeZoneInformation() Local $utcTime = "" If Not $sDate Then $sDate = _NowCalc() If Int(StringLeft($sDate, 4)) < 1970 Then Return "" If $aSysTimeInfo[0] = 2 Then ; if daylight saving time is active $utcTime = _DateAdd('n', $aSysTimeInfo[1] + $aSysTimeInfo[7], $sDate) ; account for time zone and daylight saving time Else $utcTime = _DateAdd('n', $aSysTimeInfo[1], $sDate) ; account for time zone EndIf Return _DateDiff('s', "1970/01/01 00:00:00", $utcTime) EndFunc ;==>_GetUnixTime ;$blTrim: Year in short format and no seconds. Func _GetDate_fromUnixTime($iUnixTime, $iReturnLocal = True) Local $aRet = 0, $aDate = 0 Local $aMonthNumberAbbrev[13] = ["", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] Local $timeAdj = 0 If Not $iReturnLocal Then Local $aSysTimeInfo = _Date_Time_GetTimeZoneInformation() Local $timeAdj = $aSysTimeInfo[1] * 60 If $aSysTimeInfo[0] = 2 Then $timeAdj += $aSysTimeInfo[7] * 60 EndIf $aRet = DllCall("msvcrt.dll", "str:cdecl", "ctime", "int*", $iUnixTime + $timeAdj ) If @error Or Not $aRet[0] Then Return "" $aDate = StringSplit(StringTrimRight($aRet[0], 1), " ", 2) Return $aDate[4] & "/" & StringFormat("%.2d", _ArraySearch($aMonthNumberAbbrev, $aDate[1])) & "/" & $aDate[2] & " " & $aDate[3] EndFunc ;==>_GetUnixDate Enjoy!
      Realm
      Update: >Added some functionality and a suggestion from FireFox
    • FroVN
      By FroVN
      Hi, i want read all text in website doc.google, link : https://docs.google.com/document/d/1ePaOK3w4mOi0fmOF7WQmF5kYvAXQtztVI7018wei_xs/edit (This is all my account , don't remember :v) how i read all text in this web? Tks