ravenfyre Posted March 12, 2004 Share Posted March 12, 2004 (edited) I would like to make a clock for a game and would like to display it on my desktop. The game is FFXI and there are sites that have clocks for this game but I want something that is small and runs in the corner. I'm planning to use tooltip for this. I know how to work with autoit and to figure out how the clock is calculated I ripped it of one of the clock sites in javascript format . This is for my own use and I don't intend to distribute this so I guess it's alright .To give credit, this is the actual site I got the script fromCLICK HERENow here is what my ripped script looks likeCLICK HEREAs you can see it's just a clock. Earth time isn't important but the javascript still depends on the earth time to calculate the vanadiel time.I don't know squat about javascript but I can somewhat see how the clock is calculated. Problem is gettime() is a preset command and calculates the date/time into milliseconds, there is no such thing in autoit . The autoit language is pretty much the only thing I know lol, well that and maybe just a tiny little of html .Since I don't think I can convert it myself without a functionality of gettime() in autoit, would it be possible to get autoit to check the website and read the clock? That is of course without opening the website itself, I don't want to have the page open all the time. Any ideas to what I can do? The javascript is below. expandcollapse popup<!-- EarthDay = new Array("SUN","MON","TUE","WED","THU","FRI","SAT"); VanaDay = new Array("Fire", "Earth", "Water", "Wind", "Ice", "Thunder", "Light", "Darkness", "Fire" ); // Earth time :2002/06/23 08:00:00 Pacific TIme // Vana'diel time:0898/02/01 00:00:00 // ÈÌð³ÉvZB vlocaltime = (898 * 360 + 30) * 24 * 60 * 60 * 1000 / 25; Bday = new Date("Jun 23, 2002 8:00:03"); //GMT //var timenow = new Date(); //tz = timenow.getTimezoneOffset(); //Bday.setTime(Bday.getTime() + tz*60*1000); elocaltime = Bday.getTime(); Diff = vlocaltime - elocaltime; function printTime() { // nÔæ¾ Now = new Date(); eYear = Now.getFullYear(); eMon = Now.getMonth() + 1; eDate = Now.getDate(); eHour = Now.getHours(); eMin = Now.getMinutes(); eSec = Now.getSeconds(); eDay = Now.getDay(); eTime = Now.getTime(); // 10ȺÉÍ0¯ܵå if (eMon < 10) { eMon = "0" + eMon; } if (eDate < 10) { eDate = "0" + eDate; } if (eHour < 10) { eHour = "0" + eHour; } if (eMin <10) { eMin = "0" + eMin; } if (eSec < 10) { eSec = "0" + eSec; } EarthTxt = eYear + "/" + eMon + "/" + eDate + "(" + EarthDay[eDay] + ") "; EarthTxt += eHour + ":" + eMin + ":" + eSec + "\n"; // @iÔæ¾ vTime = (eTime + Diff) * 25; vYear = Math.floor(vTime / (360 * 24 * 60 * 60 * 1000)); vMon = Math.floor((vTime % (360 * 24 * 60 * 60 * 1000)) / (30 * 24 * 60 * 60 * 1000)) + 1; vDate = Math.floor((vTime % (30 * 24 * 60 * 60 * 1000)) / (24 * 60 * 60 * 1000)) + 1; vHour = Math.floor((vTime % (24 * 60 * 60 * 1000)) / (60 * 60 * 1000)); vMin = Math.floor((vTime % (60 * 60 * 1000)) / (60 * 1000)); vSec = Math.floor((vTime % (60 * 1000)) / 1000); vDay = Math.floor((vTime % (8 * 24 * 60 * 60 * 1000)) / (24 * 60 * 60 * 1000)); // 0¯ܵå if (vYear < 1000) { VanaYear = "0" + vYear; } else { VanaYear = vYear; } if (vMon < 10) { VanaMon = "0" + vMon; } else { VanaMon = vMon; } if (vDate < 10) { VanaDate = "0" + vDate; } else { VanaDate = vDate; } if (vHour < 10) { VanaHour = "0" + vHour; } else { VanaHour = vHour; } if (vMin < 10) { VanaMin = "0" + vMin; } else { VanaMin = vMin; } if (vSec < 10) { VanaSec = "0" + vSec; } else { VanaSec = vSec; } VanaTxt = VanaYear + "/" + VanaMon + "/" + VanaDate + "(" + VanaDay[vDay] + ") "; VanaTxt += VanaHour + ":" + VanaMin + ":" + VanaSec + "\n"; // òóðÌo`Ô // Wm|oX (04:10,10:10,16:10,22:10) // Wm|Th(01:10,07:10,13:10,19:10) // Wm|EB(02:45,08:45,14:45,20:45) // Wm|JU(05:40,11:40,17:40,23:40) // oX |Wm(01:10,07:10,13:10,19:10) // Th|Wm(04:10,10:10,16:10,22:10) // EB|Wm(05:45,11:45,17:45,23:45) // JU|Wm(05:45,11:45,17:45,23:45) thisTime = vHour * 60 + vMin; // \¦ document.Times.Earth.value = EarthTxt; document.Times.Vana.value = VanaTxt; setTimeout("printTime()", 50); } // --> Edited March 12, 2004 by ravenfyre Link to comment Share on other sites More sharing options...
Valik Posted March 12, 2004 Share Posted March 12, 2004 The very very very first thing you should do is a simple test to make sure a tooltip will appear on top of the screen when you have the game running. I am betting, in fact, I would almost guarantee it will not appear by Microsoft's design. This is assuming you mean run the game full-screen and not in windowed mode. Link to comment Share on other sites More sharing options...
scriptkitty Posted March 12, 2004 Share Posted March 12, 2004 I run my tooltip timer in my games. I have a hotkey that the game doesn't capture to turn it on and off. It helps me remember to stop playing. Most games use DirectX these days and are quite friendly to AutoIt. AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
ravenfyre Posted March 12, 2004 Author Share Posted March 12, 2004 (edited) Yes tooltip will show up in FFXI but that's not really when I want it to show. If I'm in the game I can already see the in-game clock, I want this for windows.I kinda figured out how the javascript gets the clock. The key part is when the script finds the difference between one date and the other by using gettime(), a javascript command which returns the number of milliseconds since January 1, 1970, 00:00:00 GMT. From what I have read about gettime() it is mostly used to see how much time has passed from one date to the next and that is exactly what it's used for in this clock script.This is how it generates the game time from earth time,1) It converts the game's birthdate in Vanadiel time into milliseconds and divides that by 25, Vana'diel birth:0898/02/01 00:00:00vlocaltime = (898 * 360 + 30) * 24 * 60 * 60 * 1000 / 25;2) It converts the game's birthdate in Earth time into millisecondsBday = new Date("Jun 23, 2002 8:00:03"); //GMTelocaltime = Bday.getTime();3) It finds the difference between the birth time of vanadiel and earth timeDiff = vlocaltime - elocaltime;4) It converts the current Earth's time into millisecondsNow = new Date();eTime = Now.getTime();5) It calculates the current game time into millisecondsvTime = (eTime + Diff) * 25;From there on it gets the the year, month, day etc as you can easily see from the script.As I said before the key function in all of this is gettime(), autoit doesn't have anything like this does it? Anyone made a script that tells the difference between one date the another and doesn't mind sharring? If not, then I would like to Request a new autoit preset function, gettime(), to find the difference between one date and another Edited March 12, 2004 by ravenfyre Link to comment Share on other sites More sharing options...
Valik Posted March 12, 2004 Share Posted March 12, 2004 Have you look at the standard library functions in the help file? I think there are several date-related functions there. Link to comment Share on other sites More sharing options...
ravenfyre Posted March 13, 2004 Author Share Posted March 13, 2004 (edited) The Macro Reference - Time And Date functions are only usefull for the *current* date/time. They are no good if I want to convert an old date, like the birthdate of the game.If I were to write my own date/time difference script one particular macro would be usefull if I could specify the actual date. The macro is @YDAY. It gives the current day of year, range is 1 to 366 (or 365 if not a leap year). If I were to get the day of the year for a specific date I could work out everything else but this macro is only usefull for the current date, one cannot specify a different date. Edited March 13, 2004 by ravenfyre Link to comment Share on other sites More sharing options...
Valik Posted March 13, 2004 Share Posted March 13, 2004 (edited) There are date related functions. From the help file:#include <Date.au3> _DateDayOfWeek Returns the name of the weekday, based on the specified day. _DateDaysInMonth Returns the number of days in a month, based on the specified month and year. _DateIsLeapYear Returns 1 if the specified year falls on a leap year and returns 0 if it does not. _DateIsValidMonthNum Returns 1 if the specified month number is valid and returns 0 if it is not. _DateIsValidWeekdayNum Returns 1 if the specified weekday number is valid and returns 0 if it is not. _DateIsValidYear Returns 1 if the specified year is valid and returns 0 if it is not. _DateLastMonthNum Returns previous month number, based on the specified month. _DateLastMonthYear Returns previous month's year, based on the specified month and year. _DateLastWeekdayNum Returns previous weekday number, based on the specified day of the week. _DateMonthOfYear Returns the name of the month, based on the specified month. _DateNextMonthNum Returns next month number, based on the specified month. _DateNextMonthYear Returns next month's year, based on the specified month and year. _DateNextWeekdayNum Returns next weekday number, based on the specified day of the week. _TicksToTime Converts the specified tick amount to hours, minutes, and seconds. _TimeIsValidHour Returns 1 if the specified hour is valid and returns 0 if it is not. _TimeIsValidMinute Returns 1 if the specified minute is valid and returns 0 if it is not. _TimeIsValidSecond Returns 1 if the specified second is valid and returns 0 if it is not. _TimeToTicks Converts the specified hours, minutes, and seconds to ticks. Edited March 13, 2004 by Valik Link to comment Share on other sites More sharing options...
ravenfyre Posted March 13, 2004 Author Share Posted March 13, 2004 lol I just stumbled upon the same thing in the help file. This one looks particularily interesting, _TimeToTicks Converts the specified hours, minutes, and seconds to ticks. Not sure what it means by ticks by hey this is a learning process lol. I'm sure I can work with this, thanks Valik. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now