Jump to content

< SOLVED> I need some help to Autoit code


Borje
 Share

Recommended Posts

Hi all AutoIt users

Please I need help.

I hope someone can help me to convert from one of this two examples Delphi or C + + to AutoIt code.

The first example is from Delphi:

day = (520161244 shr 24) and 256;

month = (520161244 shr 16) and 256;

year = 520161244 and 65535;

the Same, written in C + + Would be:

day = (520161244>> 24) & 256;

month = (520161244>> 16) & 256;

year = 520161244 & 65535;

Does Autoit supports bytes shift operations?

Edited by Borje
Link to comment
Share on other sites

  • Moderators

Hi, Borje. AutoIT does indeed support shifting. Check out BitShift in the help file.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

Borje, I think it would be best if you try explaining a little more about what you're trying to accomplish. What is your end goal?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

I want to have this Delphi code translated to Autoit code...

day = (520161244 shr 24) and 256;

month = (520161244 shr 16) and 256;

year = 520161244 and 65535;

I am not shure how to do that. The result of this should be day month and year.

Link to comment
Share on other sites

  • Moderators

Again, what is the output you expect? Are you trying to get the current day month and year? I'm not much into Delphi, so you have to give us an idea what you're trying to accomplish.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

Borje,

Where did you get those expressions? Because I do not think they are correct.

The number 520161244 is obviously an encoded date DDMMYYYY where each element is expressed in Hex. To extract the values we need to do the following:

For the day, BitShift right 24 - that just leaves the DD part

For the mon we BitShift right 16 - which leaves DDMM. We only want the MM part so we need to BitAND with 0x00FF to leave just the MM

For the yr we just need the final YYYY - so we BitAnd with 0xFFFF

In AutoIt that translates as:

$iDTG = 520161244

ConsoleWrite(Hex($iDTG) & @CRLF)

$iDay = BitShift($iDTG, 24)

ConsoleWrite($iDay & @CRLF)

$iMon = BitAnd(BitShift($iDTG, 16),0xFF)

ConsoleWrite($iMon & @CRLF)

$iYear = BitAnd($iDTG, 0xFFFF)

ConsoleWrite($iYear & @CRLF)

So I reckon we are looking at 31 Jan 2012. :)

As I said above, I think your expressions are wrong - they certainly did not work for me. ;)

M23

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

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

Borje,

Look at StringFormat in the Help file. When you are thoroughly confused by the function and its complicated parameters, come back and I will explain. :)

M23

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

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

Borje,

I did warn you it was a very complicated function - but here we need only concern ourselves with the simple problem of adding leading zeroes to the day and month if required. ;)

To do that with your date values we use the parameter %02i:

%  -  It is a format
0  -  Pad with zeroes if required to be at least...
2  -  The minimum width
i  -  It is an integer so the width affects the digits before the decimal point

So you need:

$iDTG = 520161244

ConsoleWrite(StringFormat("%02i", BitShift($iDTG, 24)) & "-" & StringFormat("%02i", BitAnd(BitShift($iDTG, 16),0xFF)) & "-" & BitAnd($iDTG, 0xFFFF) & @CRLF)

Clearer now? :)

M23

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

Open spoiler to see 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

 

Link to comment
Share on other sites

Borje,

I did warn you it was a very complicated function - but here we need only concern ourselves with the simple problem of adding leading zeroes to the day and month if required. ;)

To do that with your date values we use the parameter %02i:

%  -  It is a format
0  -  Pad with zeroes if required to be at least...
2  -  The minimum width
i  -  It is an integer so the width affects the digits before the decimal point

So you need:

$iDTG = 520161244

ConsoleWrite(StringFormat("%02i", BitShift($iDTG, 24)) & "-" & StringFormat("%02i", BitAnd(BitShift($iDTG, 16),0xFF)) & "-" & BitAnd($iDTG, 0xFFFF) & @CRLF)

Clearer now? :)

M23

Continuing on with Melba23's example (of post #12), we have another two simple, valid methods to format a string for display purposes.

Local $iDTG = 520161244

; Melba23's (Combination of StringFormat functions and string concatenation.)
ConsoleWrite(StringFormat("%02i", BitShift($iDTG, 24)) & "-" & StringFormat("%02i", BitAND(BitShift($iDTG, 16), 0xFF)) & "-" & BitAND($iDTG, 0xFFFF) & @CRLF)

; Using one StringFormat function.
ConsoleWrite(StringFormat("%02i-%02i-%4i", BitShift($iDTG, 24), BitAND(BitShift($iDTG, 16), 0xFF), BitAND($iDTG, 0xFFFF)) & @LF)

; String concatenation. (StringRight function used to add leading zero - if only one digit exists.)
ConsoleWrite(StringRight("0" & BitShift($iDTG, 24), 2) & "-" & StringRight("0" & BitAND(BitShift($iDTG, 16), 0xFF), 2) & "-" & BitAND($iDTG, 0xFFFF) & @LF)

#cs
    Console output:-
    31-01-2012
    31-01-2012
    31-01-2012
#ce
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...