Jump to content
sammy1996

Help me create GUI splitting string in hex code and set the data to list

Recommended Posts

sammy1996

 

I need a tool that can read the Model.dat file and retrieve all the strings as shown and then set the data into the list in the GUI. Thanks
Image Link

 

Model.dat

Share this post


Link to post
Share on other sites
Melba23

sammy1996,

Welcome to the AutoIt forums.

What code 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
sammy1996
9 minutes ago, Melba23 said:

sammy1996,

Welcome to the AutoIt forums.

What code have you tried that has not worked?

M23

 

hi you, i need a tool that can fetch strings and set to list in GUI. You can help me complete it, I thank you very much

Share this post


Link to post
Share on other sites
sammy1996

 

I need to take the two strings is Temp and Name as shown above and set to the list of GUI

Share this post


Link to post
Share on other sites
Melba23

sammy1996,

We do not write code to order - we help you get your code working correctly. Think of the old saying: "Give a man a fish, you feed him for a day; give a man a net and you feed him forever". We try to be net makers and repairers, not fishmongers.

So I again ask what you have tried for yourself.

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
sammy1996

my script

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.5
 Author:

 Script Function: Template AutoIt script.

#ce ----------------------------------------------------------------------------
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
;-----------------------------------------------------------------------------------
$Form = GUICreate("Read file dat", 270, 328, 349, 199)
$Input = GUICtrlCreateInput("", 15, 8, 235, 20)
$Progress = GUICtrlCreateProgress(15, 40, 235, 20)
$Browse = GUICtrlCreateButton("Browse", 16, 72, 75, 25)
$Cancel = GUICtrlCreateButton("Cancel", 176, 72, 75, 25)
$List = GUICtrlCreateInput("", 16, 112, 235, 200)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Browse
        $Dialog = FileOpenDialog("Browse File Model .DAT", @ScriptDir & "\", "Model (*.DAT)")
        $FileOpen = FileOpen($Dialog,16)
        $FileRead = FileRead($FileOpen)
        If @error Then
            FileChangeDir(@ScriptDir)
        Else
            $RInput = ""
            GUICtrlSetData($Input, $RInput)
            $RStart = 0
            GUICtrlSetData($Progress, $RStart)
        For $Start = 0 To 100
        Next
            GUICtrlSetData($Progress, $Start)
            Sleep(1000)
            GUICtrlSetData($Input, $Dialog)
;----------------------------------------------
            $Split = StringSplit($FileRead,"00")
            GUICtrlSetData($List, $FileOpen)
        EndIf
        Case $Cancel, $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

 

my I have to do at filename and get temp and temp and name in model.dat file

Share this post


Link to post
Share on other sites
Melba23

sammy1996,

If the string are always "Temp" and "Name" why do you need to extract them? If the strings can very, how do you determine what is a string and what is not within the file content?

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
sammy1996
The model.dat file is for example, I need to read other .dat files that identify and extract all strings of such form into the list of GUIs.
For example here I have image link : Link image
I need to identify the name of the string by looking for "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" and ignore a trailing edge. go left, then take the name of the example string as Temp or Name as the image link on the title and extract the string name into GUICtrlSetData ($ List, $ FileOpen)

Share this post


Link to post
Share on other sites
Bilgus

@sammy1996 I think this should give you an Idea of how to do it

 

Share this post


Link to post
Share on other sites
sammy1996

1 : find for hex "01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 02 00 00 00 01 00 00 00" for length "28" link image for example

2: get string name from right to the left - for example "Temp" or "Name" and extract it to

GUICtrlSetData ($List, $FileOpen)

 

Share this post


Link to post
Share on other sites
Bilgus

here is another example for you that is a little closer to your situation

 

Share this post


Link to post
Share on other sites
sammy1996

I have finished 
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.5
 Author:

 Script Function: Template AutoIt script.

#ce ----------------------------------------------------------------------------
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#include <String.au3>
#Region ### START Koda GUI section ### Form=
;-----------------------------------------------------------------------------------
$Form = GUICreate("Read file dat", 270, 328, 349, 199)
$Input = GUICtrlCreateInput("", 15, 8, 235, 20)
$Progress = GUICtrlCreateProgress(15, 40, 235, 20)
$Browse = GUICtrlCreateButton("Browse", 16, 72, 75, 25)
$Cancel = GUICtrlCreateButton("Cancel", 176, 72, 75, 25)
$List = GUICtrlCreateInput("", 16, 112, 235, 200)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Browse
        $Dialog = FileOpenDialog("", @ScriptDir & "\", "All (*.*)")
        $FileOpen = FileOpen($Dialog,16)
        $FileRead = FileRead($FileOpen)
        If @error Then
            FileChangeDir(@ScriptDir)
        Else
            $RInput = ""
            GUICtrlSetData($Input, $RInput)
            $RStart = 0
            GUICtrlSetData($Progress, $RStart)
        For $Start = 0 To 100
        Next
            GUICtrlSetData($Progress, $Start)
            Sleep(1000)
            GUICtrlSetData($Input, $Dialog)
            $Hex = StringRegExp($FileRead,"(.*?)00(.*?)01000000000000000000000000000000010000000200000001000000",1)
            $String = _HexToString($Hex[1])
            GUICtrlSetData($List, $String)
        Next
        EndIf
        Case $Cancel, $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

but there is a problem with this

$Hex = StringRegExp($FileRead,"(.*?)00(.*?)01000000000000000000000000000000010000000200000001000000",1)

 
I want it to run from the beginning of the line until the end of the line and extract the second hex
(.*?)00(.*?)

convert that second hex into a string
$String = _HexToString($Hex[1])

 

set data in

GUICtrlSetData($List, $String)

 

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

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.