Jump to content
nacerbaaziz

how to get the islamic date using autoit

Recommended Posts

nacerbaaziz


Hello
I have a question please
How to show Islamic date in Autoit
I mean
for example
Ramadan month
And moharam month ... etc
I hope my question is clear for you
Thanks in advance

Share this post


Link to post
Share on other sites
Melba23

nacerbaaziz,

You should know by now that we help you get your script working - not write code from scratch. What have you tried that has not worked?

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
nacerbaaziz

Hello again
my dear  
@Melba23
I do not know if there is a function in the language responsible for providing the islamic date Or another method
So I could not find an entrance to try working
But I am in dire need of this
Please help me by giving me any way to get Islamic date using autoit

Share this post


Link to post
Share on other sites
Melba23

nacerbaaziz,

Quote

is a function in the language responsible for providing the islamic date

No.

Have you searched for an algorithm in any language which will allow you to convert normal dates into islamic dates? If so let us know and we can try and convert it into AutoIt. If not - than I suggest you do so rather then expect us to do it for you.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
nacerbaaziz
Posted (edited)

this is a function to converte the date to hijri date using cpp

 

I do not understand ith cpp language so I hope you will help me in converting this function to autoit language
 

 

void gregorian_to_hijri(int* h_y, int* h_m, int* h_d, int  g_y, int  g_m, int  g_d)
{
    int year, month, day;

    int zyr;
    int zd;
    int zm;
    int zy;

    float zjd;
    int zl;
    int zn;
    int zj;

    year = g_y;
    month = g_m;
    day = g_d;


    zyr = year;
    zd = day;
    zm = month;
    zy = zyr;

    if((zy > 1582) || ((zy == 1582) && (zm > 10)) || ((zy == 1582) && (zm == 10) && (zd > 14)))
    {
        zjd = ((1461 * (zy + 4800 + ((zm - 14) / 12))) / 4)
            + ((367 * (zm - 2 - 12 * (((zm - 14) / 12)))) / 12)
            - ((3 * (((zy + 4900 + ((zm - 14) / 12)) / 100))) / 4) + zd - 32075;
    }
    else
    {
        zjd = 367 * zy - ((7 * (zy + 5001 + ((zm - 9) / 7))) / 4)
            + ((275 * zm) / 9) + zd + 1729777;
    }

    zl = zjd - 1948440 + 10632;
    zn = ((zl - 1) / 10631);
    zl = zl - 10631 * zn + 354;
    zj = (((10985 - zl) / 5316)) * ((int)((50 * zl) / 17719))
        + ((zl / 5670)) * ((int)((43 * zl) / 15238));

    zl = zl - (((30 - zj) / 15)) * (((17719 * zj) / 50))
        - ((zj / 16)) * (((15238 * zj) / 43)) + 29;

    zm = ((24 * zl) / 709);
    zd = zl - ((709 * zm) / 24);
    zy = 30 * zn + zj - 30;

    *h_y = zy;
    *h_m = zm;
    *h_d = zd;
}

Edited by nacerbaaziz

Share this post


Link to post
Share on other sites
jchd

There are many variants of islamic calendar. You should read up the net to choose one "standard" and try to implement it in AutoIt as I don't know of an existing published UDF. For instance the .NET frame work, Java 8 and Visual Basic have made API available for this purpose.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


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

this is a function to converte the date to hijri date using cpp

+

Great, that code is very translatable to AutoIt, try to do so and share your results if you get stuck.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
nacerbaaziz

Sorry but I do not understand CPP language

Share this post


Link to post
Share on other sites
JLogan3o13

Then I guess you have some reading to do. As Melba stated above, we are getting tired of you putting forth zero effort and demanding people write code for you, and do it now. You should be able to step through that code line by line and find an AutoIt equivalent. If you're unwilling to even try to do so, let us know so we can close the topic.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
nacerbaaziz

First I apologize to all administrators and members
I'm asking here because this forum is very compatible with screen readers
Unlike  Lots other sites, most of which use a forums script   that is not compatible enough with the screen reader
And their explanations are mostly pictures
Unfortunately, the screen reader can not read the image
So for that the search methods I can search on the Internet are very limited
I hope you're not bothered by my primitive questions.
and  please try to help me.
I wish you a happy and good life

now I'm going back to the subject of my question, If you don't mind.

I have declared the variables in a function using autoit
But unfortunately no matter how hard I tried I could not understand the if conditional used
Can you help me to converte  only the conditional if section?
That's code what I was able to write.

 

Share this post


Link to post
Share on other sites
nacerbaaziz

func gregorian_to_hijri($g_y = @Year, $g_m = @Mon, $g_d = @mDay, $h_y = "", $h_m = "", $h_d = "")
local $year, $month, $day
local $zyr, $zd, $zm, $zy
$zjd, $zl, $zn, $zj
$year = $g_y
$month = $g_m
$day = $g_d


endFunc

Share this post


Link to post
Share on other sites
Simpel
2 hours ago, nacerbaaziz said:

if((zy > 1582) || ((zy == 1582) && (zm > 10)) || ((zy == 1582) && (zm == 10) && (zd > 14)))
    {
        zjd = ((1461 * (zy + 4800 + ((zm - 14) / 12))) / 4)
            + ((367 * (zm - 2 - 12 * (((zm - 14) / 12)))) / 12)
            - ((3 * (((zy + 4900 + ((zm - 14) / 12)) / 100))) / 4) + zd - 32075;
    }
    else
    {
        zjd = 367 * zy - ((7 * (zy + 5001 + ((zm - 9) / 7))) / 4)
            + ((275 * zm) / 9) + zd + 1729777;
    }

I think this could be translated as:

if ((zy > 1582) Or ((zy = 1582) And (zm > 10)) Or ((zy = 1582) And (zm = 10) And (zd > 14))) Then
        zjd = ((1461 * (zy + 4800 + ((zm - 14) / 12))) / 4) + ((367 * (zm - 2 - 12 * (((zm - 14) / 12)))) / 12) - ((3 * (((zy + 4900 + ((zm - 14) / 12)) / 100))) / 4) + zd - 32075;
    else
        zjd = 367 * zy - ((7 * (zy + 5001 + ((zm - 9) / 7))) / 4) + ((275 * zm) / 9) + zd + 1729777;
endif

This is untested but may give you a hint how to translate that part. 

Regards, Conrad


SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Share this post


Link to post
Share on other sites
nacerbaaziz

this is what's i tried but it give me a errors.

func gregorian_to_hijri($G_year = @Year, $g_month = @Mon, $g_day = @MDay)
local $year = $G_year, $month = $G_month, $day = $g_day
local $zjd, $zl, $zn, $zj
local $zY, $ZM, $ZD
if (($year > 1582) Or (($year = 1582) And ($month > 10)) Or (($year = 1582) And ($month = 10) And ($day > 14))) Then
$zjd = ((1461 * ($year + 4800 + (($month - 14) / 12))) / 4) + ((367 * ($month - 2 - 12 * ((($month - 14) / 12)))) / 12) - ((3 * ((($year + 4900 + (($month - 14) / 12))/ 100))) / 4) + $day - 32075
else
$zjd = 367 * $year - ((7 * ($year + 5001 + (($month - 9) / 7))) / 4) + ((275 * $month) / 9) + $day + 1729777
endif
$zl = $zjd - 1948440 + 10632
$zn = (($zl - 1) / 10631)
$zl = $zl - 10631 * $zn + 354
$zj = (((10985 - $zl) / 5316)) * ((Int((50 * $zl) / 17719)) + (($zl / 5670)) * ((int((43 * $zl) / 15238))
$zl = $zl - (((30 - $zj) / 15)) * (((17719 * $zj) / 50)) - (($zj / 16)) * (((15238 * $zj) / 43)) + 29
$zm = ((24 * $zl) / 709)
$zd = $zl - ((709 * $zm) / 24)
$zy = 30 * $zn + $zj - 30
return $zy & " / " & $zm & " / " & $zd
endFunc

 

can any one from you check it please?

thank you

:)

 

Share this post


Link to post
Share on other sites
Simpel

What error message(s) do you get? Most of them I find very use- and helpful.


SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Share this post


Link to post
Share on other sites
Juvigy

I fixed the errors. I dont know if the function result is correct though:

ConsoleWrite(gregorian_to_hijri()&@CRLF)
Exit
func gregorian_to_hijri($G_year = @Year, $g_month = @Mon, $g_day = @MDay)
local $year = $G_year, $month = $G_month, $day = $g_day
local $zjd, $zl, $zn, $zj
local $zY, $ZM, $ZD
if (($year > 1582) Or (($year = 1582) And ($month > 10)) Or (($year = 1582) And ($month = 10) And ($day > 14))) Then
$zjd = ((1461 * ($year + 4800 + (($month - 14) / 12))) / 4) + ((367 * ($month - 2 - 12 * ((($month - 14) / 12)))) / 12) - ((3 * ((($year + 4900 + (($month - 14) / 12))/ 100))) / 4) + $day - 32075
else
$zjd = 367 * $year - ((7 * ($year + 5001 + (($month - 9) / 7))) / 4) + ((275 * $month) / 9) + $day + 1729777
endif
$zl = $zjd - 1948440 + 10632
$zn = (($zl - 1) / 10631)
$zl = $zl - 10631 * $zn + 354
$zj = (((10985 - $zl) / 5316)) * (Int((50 * $zl) / 17719)) + ($zl / 5670) * (int((43 * $zl) / 15238))
$zl = $zl - (((30 - $zj) / 15)) * (((17719 * $zj) / 50)) - (($zj / 16)) * (((15238 * $zj) / 43)) + 29
$zm = ((24 * $zl) / 709)
$zd = $zl - ((709 * $zm) / 24)
$zy = 30 * $zn + $zj - 30
return $zy & " / " & $zm & " / " & $zd
endFunc
Exit

 

Share this post


Link to post
Share on other sites
Melba23
Posted (edited)

nacerbaaziz,

Here is my version of that algorithm:

#cs
    void gregorian_to_hijri(int* h_y, int* h_m, int* h_d, int  g_y, int  g_m, int  g_d)
    {
    int year, month, day;

    int zyr;
    int zd;
    int zm;
    int zy;

    float zjd;
    int zl;
    int zn;
    int zj;

    year = g_y;
    month = g_m;
    day = g_d;


    zyr = year;
    zd = day;
    zm = month;
    zy = zyr;

#ce


ConsoleWrite(_Greg2Hij() & @CRLF)

Func _Greg2Hij($sGY = @YEAR, $sGM = @MON, $sGD = @MDAY)

    $iZYr = Number($sGY)
    $iZY = Number($sGY)
    $iZM = Number($sGM)
    $iZD = Number($sGD)

    #cs

        if((zy > 1582) || ((zy == 1582) && (zm > 10)) || ((zy == 1582) && (zm == 10) && (zd > 14)))
        {
        zjd = ((1461 * (zy + 4800 + ((zm - 14) / 12))) / 4)
        + ((367 * (zm - 2 - 12 * (((zm - 14) / 12)))) / 12)
        - ((3 * (((zy + 4900 + ((zm - 14) / 12)) / 100))) / 4) + zd - 32075;
        }
        else
        {
        zjd = 367 * zy - ((7 * (zy + 5001 + ((zm - 9) / 7))) / 4)
        + ((275 * zm) / 9) + zd + 1729777;
        }
    #ce

    Local $iZJd

    If ($iZY > 1582) Or ($iZY = 1582 And $iZM > 10) Or ($iZY = 1582 And $iZM = 10 And $iZD > 14) Then

        $iZJd = Int(((1461 * ($iZY + 4800 + (($iZM - 14) / 12))) / 4) + _
                ((367 * ($iZM - 2 - 12 * ((($iZM - 14) / 12)))) / 12) - _
                ((3 * ((($iZY + 4900 + (($iZM - 14) / 12)) / 100))) / 4) + $iZD - 32075)

    Else

        $iZJd = Int((367 * $iZY) - ((7 * ($iZY + 5001 + (($iZM - 9) / 7))) / 4) + _
                ((275 * $iZM) / 9) + $iZD + 1729777)

    EndIf

    #cs
        zl = zjd - 1948440 + 10632;
        zn = ((zl - 1) / 10631);
        zl = zl - 10631 * zn + 354;
        zj = (((10985 - zl) / 5316)) * ((int)((50 * zl) / 17719))
        + ((zl / 5670)) * ((int)((43 * zl) / 15238));

        zl = zl - (((30 - zj) / 15)) * (((17719 * zj) / 50))
        - ((zj / 16)) * (((15238 * zj) / 43)) + 29;

        zm = ((24 * zl) / 709);
        zd = zl - ((709 * zm) / 24);
        zy = 30 * zn + zj - 30;

        *h_y = zy;
        *h_m = zm;
        *h_d = zd;
        }

    #ce

    Local $iZL = Int($iZJd - 1948440 + 10632)
    Local $iZN = Int(($iZL - 1) / 10631)
    $iZL -= (10631 * $iZN) + 354

    Local $iZJ = Int((((10985 - $iZL) / 5316)) * (Int((50 * $iZL) / 17719)) + (($iZL / 5670)) * (Int((43 * $iZL) / 15238)))

    $iZL -= Int((((30 - $iZJ) / 15)) * (((17719 * $iZJ) / 50)) - (($iZJ / 16)) * (((15238 * $iZJ) / 43)) + 29)

    Local $iZM =Int((24 * $iZL) / 709)
    Local $iZD = Int($iZL - ((709 * $iZM) / 24))
    Local $iZY = Int((30 * $iZN) + $iZJ - 30)

    Return $iZY & "/" & $iZM & "/" & $iZD

EndFunc   ;==>_Greg2Hij

It gives the same nonsense result as Juvigy's: 1440.79552344311 / -36.2656331431983 / 0

I think this is caused by a problem with operator precedence in those calculations. Most languages work on roughly the same pattern but in multiple operator chains like this algorithm it is easy to get the parentheses wrong.

Corrected (I think) for the Int typing - now gives: 1462/3273/26

Which is still wrong, but closer to what online convertors give as 1439/09/25

M23

Edited by Melba23
Amended variable typing

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
water

In VB it is quite easy as the following code snippet shows:

Sub test()
Dim a, b As String
a = "2017/7/7"
b = "2017/5/1"
Debug.Print DGreg("1438/12/10")
Debug.Print DHijri(b)
Debug.Print DateDiff("d", a, b)
End Sub

Function DGreg(dtHijDate As String) As Date
VBA.Calendar = vbCalHijri
DGreg = dtHijDate
VBA.Calendar = vbCalGreg
End Function

Function DHijri(dtGregDate As String) As Date
VBA.Calendar = vbCalGreg
DHijri = dtGregDate
VBA.Calendar = vbCalGreg
End Function

https://social.msdn.microsoft.com/Forums/en-US/9d36abaa-8a10-401f-bf38-fe105372049d/vba-code-for-hijri-date-converter?forum=isvvba


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
jchd

The seemingly wrong result is caused by AutoIt variables not being strongly typed.

To work as expected one need to insert Int() everytime an operation yields a partial result as double, while in C when a variable is declared int and assigned a double result, casting to int is automagic.

  • Like 1

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
Melba23

jchd,

Thanks for that tip. I adjusted the algorithm I posted above - but obviously not correctly as it still gives a nonsense answer for the month.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
nacerbaaziz

Welcome, everyone.
First I would like to thank you for the interaction

I tried using the function that Melba23 did it.
it give me this result

1462/3273/26
But the correct date is
1439 / 09 / 23
And I didn't know why it give me a false result
Can any one of you help me to correct it?
Or if someone of you knows the VB language trying to convert the function that mister Water shared with us

Thank you already.
And I apologize to you for my stupidity.

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

  • Similar Content

    • nooneclose
      By nooneclose
      How do I properly convert this to Autoit? This is a VBA macro that I recorded in Excel.
       ActiveSheet.Outline.ShowLevels RowLevels:=2 I need this to close my subtotal once it is finished. 
      any help will be greatly appreciated. 
    • iMacg3
      By iMacg3
      Hi,
      I was looking into a way to delete a registry key (not a specific value, an entire key) if it is present. I was considering using RegRead and RegDelete. However, RegRead appears to only read values, not just keys. Is there a way to delete an entire registry key if it is present? I have heard that the below function may help.
       
      #include-once ; #UDF# ======================================================================================================================= ; Title .........: Reads\Search the name of a Key\Subkey\Value ; AutoIt Version : 3.3.8.1 ; Language ......: English ; Description ...: Lists all Keys\Subkeys\Values in a specified registry key ; Author(s) .....: DXRW4E ; Notes .........: ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ;~ _RegEnumKeyEx ;~ _RegEnumValEx ; =============================================================================================================================== #Region ;**** Global constants and vars **** Global Const $sValueTypes[12] = ["REG_NONE","REG_SZ","REG_EXPAND_SZ","REG_BINARY","REG_DWORD","REG_DWORD_BIG_ENDIAN","REG_LINK","REG_MULTI_SZ","REG_RESOURCE_LIST","REG_FULL_RESOURCE_DESCRIPTOR","REG_RESOURCE_REQUIREMENTS_LIST","REG_QWORD"] #EndRegion ;**** Global constants and vars **** ; #FUNCTION# ======================================================================================================================== ; Name...........: _RegEnumKeyEx ; Description ...: Lists all subkeys in a specified registry key ; Syntax.........: _RegEnumKeyEx($KeyName[, $iFlag = 0[, $sFilter = "*"]]) ; Parameters ....: $KeyName - The registry key to read. ; $iFlag - Optional specifies Recursion (add the flags together for multiple operations): ; |$iFlag = 0 (Default) All Key-SubKeys Recursive Mod ; |$iFlag = 1 All SubKeys Not Recursive Mod ; |$iFlag = 2 Include in ArrayList in the first element $KeyName ; |$iFlag = 16 $sFilter do Case-Sensitive matching (By Default $sFilter do Case-Insensitive matching) ; |$iFlag = 32 Disable the return the count in the first element - effectively makes the array 0-based (must use UBound() to get the size in this case). ; By Default the first element ($array[0]) contains the number of strings returned, the remaining elements ($array[1], $array[2], etc.) ; |$iFlag = 64 $sFilter is REGEXP Mod, See Pattern Parameters in StringRegExp ; |$iFlag = 128 Enum value's name (_RegEnumKeyEx Return a 2D array, maximum Array Size limit is 3999744 Key\Value) ; |$iFlag = 256 Reads a value data, this flag will be ignored if the $iFlag = 128 is not set ; $sFilter - Optional the filter to use, default is *. (Multiple filter groups such as "All "*.XXx|*.YYY|*.ZZZ") ; Search the Autoit3 helpfile for the word "WildCards" For details. ; $vFilter - Optional the filter to use for ValueName, $vFilter will be ignored if the $iFlag = 128 is not set ; default is *. (Multiple filter groups such as "All "*.XXx|*.YYY|*.ZZZ") Search the Autoit3 helpfile for the word "WildCards" For details. ; $iValueTypes - Optional, set Value Types to search (Default $iValueTypes = 0 Read All), $iValueTypes will be ignored if the $iFlag = 128 is not set ; (add the flags together for multiple operations): ; 1 = REG_SZ ; 2 = REG_EXPAND_SZ ; 3 = REG_BINARY ; 4 = REG_DWORD ; 5 = REG_DWORD_BIG_ENDIAN ; 6 = REG_LINK ; 7 = REG_MULTI_SZ ; 8 = REG_RESOURCE_LIST ; 9 = REG_FULL_RESOURCE_DESCRIPTOR ; 10 = REG_RESOURCE_REQUIREMENTS_LIST ; 11 = REG_QWORD ; Return values .: Success - Return Array List (See Remarks) ; Failure - @Error ; |1 = Invalid $sFilter ; |2 = No Key-SubKey(s) Found ; |3 = Invalid $vFilter ; |4 = No Value-Name(s) Found ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: The array returned is one-dimensional and is made up as follows: ; $array[0] = Number of Key-SubKeys returned ; $array[1] = 1st Key\SubKeys ; $array[2] = 2nd Key\SubKeys ; $array[3] = 3rd Key\SubKeys ; $array[n] = nth Key\SubKeys ; ; If is set the $iFlag = 128 The array returned is 2D array and is made up as follows: ; $array[0][0] = Number of Key-SubKeys returned ; $array[1][0] = 1st Key\SubKeys ; $array[1][1] = 1st Value name ; $array[1][2] = 1st Value Type (REG_NONE or REG_SZ or REG_EXPAND_SZ ect ect) ; $array[1][3] = 1st Value Data (If is set $iFlag = 256 Else Value Data = "") ; $array[2][0] = 2nd Key\SubKeys ; $array[2][1] = 2nd Value name ; $array[2][2] = 2nd Value Type (REG_NONE or REG_SZ or REG_EXPAND_SZ ect ect) ; $array[2][3] = 2nd Value Data (If is set $iFlag = 256 Else Value Data = "") ; $array[n][0] = nth Key\SubKeys ; Related .......: _RegEnumValEx() ; Link ..........: ; Example .......: _RegEnumKeyEx("HKEY_CURRENT_USER\Software\AutoIt v3") ; Note ..........: ; =================================================================================================================================== Func _RegEnumKeyEx($KeyName, $iFlag = 0, $sFilter = "*", $vFilter = "*", $iValueTypes = 0) If StringRegExp($sFilter, StringReplace("^\s*$|\v|\\|^\||\|\||\|$", Chr(BitAND($iFlag, 64) + 28) & "\|^\||\|\||\|$", "\\\\")) Then Return SetError(1, 0, "") Local $IndexSubKey[101] = [100], $SubKeyName, $BS = "\", $sKeyList, $I = 1, $sKeyFlag = BitAND($iFlag, 1), $sKeyFilter = StringReplace($sFilter, "*", "") If BitAND($iFlag, 2) Then $sKeyList = @LF & $KeyName If Not BitAND($iFlag, 64) Then $sFilter = StringRegExpReplace(BitAND($iFlag, 16) & "(?i)(", "16\(\?\i\)|\d+", "") & StringRegExpReplace(StringRegExpReplace(StringRegExpReplace(StringRegExpReplace($sFilter, "[^*?|]+", "\\Q$0\\E"), "\\E(?=\||$)", "$0\$"), "(?<=^|\|)\\Q", "^$0"), "\*+", ".*") & ")" While $I $IndexSubKey[$I] += 1 $SubKeyName = RegEnumKey($KeyName, $IndexSubKey[$I]) If @error Then $IndexSubKey[$I] = 0 $I -= 1 $KeyName = StringLeft($KeyName, StringInStr($KeyName, "\", 1, -1) - 1) ContinueLoop EndIf If $sKeyFilter Then If StringRegExp($SubKeyName, $sFilter) Then $sKeyList &= @LF & $KeyName & $BS & $SubKeyName Else $sKeyList &= @LF & $KeyName & $BS & $SubKeyName EndIf If $sKeyFlag Then ContinueLoop $I += 1 If $I > $IndexSubKey[0] Then $IndexSubKey[0] += 100 ReDim $IndexSubKey[$IndexSubKey[0] + 1] EndIf $KeyName &= $BS & $SubKeyName WEnd If Not $sKeyList Then Return SetError(2, 0, "") If BitAND($iFlag, 128) <> 128 Then Return StringSplit(StringTrimLeft($sKeyList, 1), @LF, StringReplace(BitAND($iFlag, 32), "32", 2)) $sKeyList = _RegEnumValEx(StringSplit(StringTrimLeft($sKeyList, 1), @LF), $iFlag, $vFilter, $iValueTypes) Return SetError(@Error, 0, $sKeyList) EndFunc ; #FUNCTION# ======================================================================================================================== ; Name...........: _RegEnumValEx ; Description ...: Lists all values in a specified registry key ; Syntax.........: _RegEnumValEx($KeyName[, $iFlag = 0[, $sFilter = "*"]]) ; Parameters ....: $KeyName - The registry key to read Or one-dimensional array RegKeyList ; use _RegEnumKeyEx() to get $RegKeyList (example $RegKeyList = [3, 1st Key\SubKeys, 2st Key\SubKeys, nth Key\SubKeys]) ; |$iFlag = 16 $sFilter do Case-Sensitive matching (By Default $sFilter do Case-Insensitive matching) ; |$iFlag = 32 Disable the return the count in the first element - effectively makes the array 0-based (must use UBound() to get the size in this case). ; By Default the first element ($array[0]) contains the number of strings returned, the remaining elements ($array[1], $array[2], etc.) ; |$iFlag = 64 $sFilter is REGEXP Mod, See Pattern Parameters in StringRegExp ; |$iFlag = 256 Reads a value data ; $sFilter - Optional the filter to use, default is *. (Multiple filter groups such as "All "*.XXx|*.YYY|*.ZZZ") ; Search the Autoit3 helpfile for the word "WildCards" For details. ; $iValueTypes - Optional, set Value Types to search (Default $iValueTypes = 0 Read All) ; (add the flags together for multiple operations): ; 1 = REG_SZ ; 2 = REG_EXPAND_SZ ; 3 = REG_BINARY ; 4 = REG_DWORD ; 5 = REG_DWORD_BIG_ENDIAN ; 6 = REG_LINK ; 7 = REG_MULTI_SZ ; 8 = REG_RESOURCE_LIST ; 9 = REG_FULL_RESOURCE_DESCRIPTOR ; 10 = REG_RESOURCE_REQUIREMENTS_LIST ; 11 = REG_QWORD ; Return values .: Success - Return Array List (See Remarks) ; Failure - @Error ; |3 = Invalid $sFilter ; |4 = No Value-Name(s) Found ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: The array returned is 2D array and is made up as follows: ; $array[0][0] = Number of Key-SubKeys returned ; $array[1][0] = 1st Key\SubKeys ; $array[1][1] = 1st Value name ; $array[1][2] = 1st Value Type (REG_NONE or REG_SZ or REG_EXPAND_SZ ect ect) ; $array[1][3] = 1st Value Data (If is set $iFlag = 256 Else Value Data = "") ; $array[2][0] = 2nd Key\SubKeys ; $array[2][1] = 2nd Value name ; $array[2][2] = 2nd Value Type (REG_NONE or REG_SZ or REG_EXPAND_SZ ect ect) ; $array[2][3] = 2nd Value Data (If is set $iFlag = 256 Else Value Data = "") ; $array[n][0] = nth Key\SubKeys ; Related .......: _RegEnumKeyEx() ; Link ..........: ; Example .......: _RegEnumValEx("HKEY_CURRENT_USER\Software\AutoIt v3") ; Note ..........: ; =================================================================================================================================== Func _RegEnumValEx($aKeyList, $iFlag = 0, $sFilter = "*", $iValueTypes = 0) If StringRegExp($sFilter, "\v") Then Return SetError(3, 0, "") If Not IsArray($aKeyList) Then $aKeyList = StringSplit($aKeyList, @LF) Local $aKeyValList[1954][4], $iKeyVal = Int(BitAND($iFlag, 32) = 0), $sKeyVal = 1953, $sRegEnumVal, $iRegEnumVal, $RegRead = BitAND($iFlag, 256), $vFilter = StringReplace($sFilter, "*", "") If Not BitAND($iFlag, 64) Then $sFilter = StringRegExpReplace(BitAND($iFlag, 16) & "(?i)(", "16\(\?\i\)|\d+", "") & StringRegExpReplace(StringRegExpReplace(StringRegExpReplace(StringRegExpReplace($sFilter, "[^*?|]+", "\\Q$0\\E"), "\\E(?=\||$)", "$0\$"), "(?<=^|\|)\\Q", "^$0"), "\*+", ".*") & ")" For $i = 1 To $aKeyList[0] $iRegEnumVal = 0 While 1 If $iKeyVal = $sKeyVal Then If $sKeyVal = 3999744 Then ExitLoop $sKeyVal *= 2 ReDim $aKeyValList[$sKeyVal + 1][4] EndIf $aKeyValList[$iKeyVal][0] = $aKeyList[$i] $iRegEnumVal += 1 $sRegEnumVal = RegEnumVal($aKeyList[$i], $iRegEnumVal) If @Error <> 0 Then If $iRegEnumVal = 1 And $vFilter = "" Then $iKeyVal += 1 ExitLoop EndIf $aKeyValList[$iKeyVal][2] = $sValueTypes[@Extended] If BitAND(@Extended, $iValueTypes) <> $iValueTypes Then ContinueLoop If $vFilter And Not StringRegExp($sRegEnumVal, $sFilter) Then ContinueLoop $aKeyValList[$iKeyVal][1] = $sRegEnumVal If $RegRead Then $aKeyValList[$iKeyVal][3] = RegRead($aKeyList[$i], $sRegEnumVal) $iKeyVal += 1 WEnd Next $sRegEnumVal = $iKeyVal - Int(BitAND($iFlag, 32) = 0) If Not $sRegEnumVal Or ($sRegEnumVal = 1 And $vFilter = "" And $aKeyValList[$iKeyVal - $sRegEnumVal][2] = "") Then Return SetError(4, 0, "") ReDim $aKeyValList[$iKeyVal][4] If Not BitAND($iFlag, 32) Then $aKeyValList[0][0] = $iKeyVal - 1 Return $aKeyValList EndFunc Thanks.
       
    • great77
      By great77
      ; put the root in a variable $sRoot = "C:\Project\PHexample\" Global $sCurrentTime = _NowCalc() ; We can use that variable here Global $aList = _FileListToArray($sRoot, Default, 2) If @error Then Exit ;;;;;;MsgBox(0, "Error", "_FileListToArray returned @error = " & @error) ;;;;;;;;;;;This is a loop that runs from 1 to the number of items listed in the first element of the returned  array For $i = 1 To UBound($aList) - 1     MsgBox(0, "Folder date", $sRoot & "" & $aList[$i] & @CRLF & @CRLF & FileGetTime($sRoot & "" & $aList[$i], 1, 1))     MsgBox(0, "Folder date", FileGetTime($sRoot & "" & $aList[$i], 1, 1))      $a_filenew = StringReplace(StringReplace(StringReplace(_NowCalc(), "/", ""), ":", ""), " ", "")       MsgBox(0, "Folder date", $a_filenew) $adex =  _DateDiff('D', FileGetTime($sRoot & "" & $aList[$i], 1, 1), $a_filenew)  MsgBox(0,"ade", $adex) Next I have a code as seen above, but the difference in time is returning zero. I understand that the date yyyymmddhhmmss but how can I find the difference.
      The purpose is to try find the difference in days. Any suggestion?  
    • TrashBoat
      By TrashBoat
      So i have been working on this 2d physics game and added some physics to it but got stuck on this problem that the character ( the cube ) is sliding all the time but it should not do that because of this friction function:
      If $horizontalVelocity > 0 Then If $inAir Then $currFriction = $airFriction $horizontalVelocity -= $currFriction $birbX += $horizontalVelocity EndIf this line "$horizontalVelocity -= $currFriction" should nullify the velocity to 0 but it stays somewhere in 0.09. How do i fix this?
      Here's the game's source code and what i have done so far:
      Now i don't expect you reading my nasty code and understanding what it does but any help would be appreciated.
       
      Edit: I guess the problem is solved, i have updated the source code if anyone needs it.
    • Jemboy
      By Jemboy
      Hi,
      Ones(some times twice) a month I get an e-mail with zip file, which has price updates from a supplier.
      I have to upload the file to an FTP to get it processed.
      When uploading the file, it will get "timestamped" with the time and date at which time the file was uploaded.
      Normally this is fine, because I mostly upload the file the same day.
      Sometimes it may take 1 or 2 days before I can upload the file.
      For historical purpose, I would like to have the file timestamped with the original date.
      I have tried using:  _FTP_Command ( $hFTPSession, "MFCT YYYYMMDDHHMMSS path") 
      however this command does not work or change the timestamp as I expected.
      Does anyone now a way how I can change the timestamp of a FTP-file?
×