Jump to content

To take between hyphens?


Recommended Posts

Hi everyone, I have specified the my question in the in gui codes :closedeyes:

Thank you

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 741, 318)

$Input1 = GUICtrlCreateInput("DE536F150981EE9-843246755A584A645957686A5A58526C634756415A3231686157777559323973-6304D0584A4C0CB072A2E120A4ADBCB6", 74, 48, 649, 21)
$Input2 = GUICtrlCreateInput("",74, 88, 649, 21)
$Input3 = GUICtrlCreateInput("",74, 128, 649, 21)

$Button1 = GUICtrlCreateButton("Button1", 288, 264, 75, 25)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
$aReadinput1 = GUICtrlRead($Input1)
;I want to delete 15 characters here : --> DE536F150981EE9-
;GUICtrlSetData($Input2,"843246755A584A645957686A5A58526C634756415A3231686157777559323973")
;GUICtrlSetData($Input3,"6304D0584A4C0CB072A2E120A4ADBCB6")
    EndSwitch
WEnd

 

Link to comment
Share on other sites

Please check the help file for StringSplit or StringInStr combined with StringMid.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I looked at the help file but could not :(

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 741, 318)

$Input1 = GUICtrlCreateInput("DE536F150981EE9-843246755A584A645957686A5A58526C634756415A3231686157777559323973-6304D0584A4C0CB072A2E120A4ADBCB6", 74, 48, 649, 21)
$Input2 = GUICtrlCreateInput("",74, 88, 649, 21)
$Input3 = GUICtrlCreateInput("",74, 128, 649, 21)

$Button1 = GUICtrlCreateButton("Button1", 288, 264, 75, 25)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
$aReadinput1 = GUICtrlRead($Input1)
$aSplit = StringSplit($aReadinput1, "-")
    For $i = 1 To $aSplit[0]
        $aTrimRight = StringTrimRight($aSplit,32)
        $aStr = StringInStr ($aSplit[$i], "-" )
    Next
    $sString = StringMid($aStr,15)
    GUICtrlSetData($Input2,$sString)
    GUICtrlSetData($Input3,$aTrimRight)
    EndSwitch
WEnd

 

Link to comment
Share on other sites

  • Moderators

You obviously didn't look that hard, then, as there are a half-dozen ways documented in the help file to accomplish this. Try this and see what you get:

#include <Array.au3>

Local $sString = "DE536F150981EE9-843246755A584A645957686A5A58526C634756415A3231686157777559323973-6304D0584A4C0CB072A2E120A4ADBCB6"
Local $aSplit = StringSplit($sString, "-")
    _ArrayDisplay($aSplit)

;=======OR=======

MsgBox(0, "StringMid Example", StringMid($sString, 16)) ;skip 15 chars

;=======OR=======

MsgBox(0, "StringTrimLeft Example", StringTrimLeft($sString, 15))

;=======OR=======

MsgBox(0, "StringRight Example", StringRight($sString, (StringLen($sString) - 15)))

 

"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

Try (untested):

GUICtrlSetData($Input2, $aSplit[2])
GUICtrlSetData($Input3, $aSplit[3])

And delete the for-next-loop.

Conrad

Edited by Simpel
Spelling
SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   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.

Link to comment
Share on other sites

using just stringinstr and stringmid

$str = "DE536F150981EE9-843246755A584A645957686A5A58526C634756415A3231686157777559323973-6304D0584A4C0CB072A2E120A4ADBCB6"

consolewrite(stringmid($str , stringinstr($str , "-" , 0 , 1) + 1 , (stringinstr($str , "-" , 0 , 2) - stringinstr($str , "-" , 0 , 1) - 1))  & @CR & stringmid($str , stringinstr($str , "-" , 0 , -1) + 1) & @CR)

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 741, 318)
$sString = "DE536F150981EE9-843246755A584A645957686A5A58526C634756415A3231686157777559323973-6304D0584A4C0CB072A2E120A4ADBCB6"
$Input1 = GUICtrlCreateInput($sString, 74, 48, 649, 21)
$Input2 = GUICtrlCreateInput("",74, 88, 649, 21)
$Input3 = GUICtrlCreateInput("",74, 128, 649, 21)

$Button1 = GUICtrlCreateButton("Button1", 288, 264, 75, 25)
GUISetState(@SW_SHOW)
$aResult = StringRegExp($sString, "([[:xdigit:]]+)-([[:xdigit:]]+)-([[:xdigit:]]+)", 3)
GUICtrlSetData($Input2, $aResult[1])
GUICtrlSetData($Input3, $aResult[2])

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
$aReadinput1 = GUICtrlRead($Input1)
;I want to delete 15 characters here : --> DE536F150981EE9-
;GUICtrlSetData($Input2,"843246755A584A645957686A5A58526C634756415A3231686157777559323973")
;GUICtrlSetData($Input3,"6304D0584A4C0CB072A2E120A4ADBCB6")
    EndSwitch
WEnd

Or

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 741, 318)
$sString = "DE536F150981EE9-843246755A584A645957686A5A58526C634756415A3231686157777559323973-6304D0584A4C0CB072A2E120A4ADBCB6"
$Input1 = GUICtrlCreateInput($sString, 74, 48, 649, 21)
$Input2 = GUICtrlCreateInput("",74, 88, 649, 21)
$Input3 = GUICtrlCreateInput("",74, 128, 649, 21)

$Button1 = GUICtrlCreateButton("Button1", 288, 264, 75, 25)
GUISetState(@SW_SHOW)

$iPosL = StringInStr($sString, "-")
$iPosR = StringInStr($sString, "-", 0, -1)

GUICtrlSetData($Input2, StringMid($sString, $iPosL + 1, $iPosR - $iPosL - 1))
GUICtrlSetData($Input3, StringMid($sString, $iPosR + 1, StringLen($sString) - $iPosR))

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
$aReadinput1 = GUICtrlRead($Input1)
;I want to delete 15 characters here : --> DE536F150981EE9-
;GUICtrlSetData($Input2,"843246755A584A645957686A5A58526C634756415A3231686157777559323973")
;GUICtrlSetData($Input3,"6304D0584A4C0CB072A2E120A4ADBCB6")
    EndSwitch
WEnd

 

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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...