Jump to content

URL


Go to solution Solved by Andreik,

Recommended Posts

hello everyone I started a project but I'm getting lost and as I'm starting out it's quite complicated here I have a form of url and I have to modify it with a click and copy it to the clipboard and. or open it directly through the browser

the 1er URL for example is

 

https://www1.essaiessai.frc/testeer/seconders/test/1050500-pkoi-passere-2020-tester-ceci-old-renewv4587

the url once modified must recover the number (for this exemple 1050500 ) and be in this way

https://www1.essaiessai.frc/rss/download?id=1050500&passkey=1t45y84x68z214gh12589j5k12lo7855

I spent 10 days on it but now I'm drying up

https://www1.essaiessai.frc/rss/download?id=s://www1.essaiessai.frc/testeer/seconders/test/1050500-pkoi-passere-2020-tester-ceci-old-renewv4587&passkey=Cy3Fw7Qp6Ka2Jr3Rg5Qu1Ko3Es6Oe3Pm8Jj0Ip2Ym1Nt1It5Du4Wb6Yn1Yj5Cx8Fi1Kw6Or3Dg4Uu0Nj2Wo3Rp3Nb6Hv6Jd1

this is what i get i suck

 

 

URL-test-EN.au3

Link to comment
Share on other sites

  • Solution
Posted (edited)

Try this:

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

$hGUI = GUICreate("Change URL", 601, 221, 192, 125)
$input = GUICtrlCreateInput("", 10, 10, 380, 21)
$output = GUICtrlCreateInput("", 10, 50, 380, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY))
$buttonModify = GUICtrlCreateButton("Change URL", 410, 10, 180, 30)
$buttonCopy = GUICtrlCreateButton("Copy l'URL changed", 410, 50, 180, 30)
$buttonOpenBrowser = GUICtrlCreateButton("Open with the browser", 410, 90, 180, 30)
$buttonClear = GUICtrlCreateButton("Delete", 410, 130, 180, 30)
$buttonExit = GUICtrlCreateButton("Exit", 410, 170, 180, 30)
GUISetState(@SW_SHOW)


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $buttonExit
            ExitLoop
        Case $buttonModify
            Local $originalUrl = GUICtrlRead($input)
            ConsoleWrite("URL d'origine : " & $originalUrl & @CRLF)

            ; Trouver la position du premier chiffre dans l'URL
;~             Local $startIndex = StringInStr($originalUrl, "https://") + 4
            Local $number = StringRegExp($originalUrl, '(?:.*\/)(\d+)(?:.*)', 3)
            $number = IsArray($number) ? $number[0] : ''
            ConsoleWrite("Numéro extrait : " & $number & @CRLF)

            ; Générer une chaîne aléatoire de 32 caractères
            Local $randomString = ""
            For $i = 1 To 32
                $randomString &= Chr(Random(Asc("A"), Asc("Z"))) & Chr(Random(Asc("a"), Asc("z"))) & Chr(Random(Asc("0"), Asc("9")))
            Next
            ConsoleWrite("Chaîne aléatoire : " & $randomString & @CRLF)

            ; Modifier l'URL avec les valeurs récupérées
           Local $modifiedUrl = "https://www1.essaiessai.frc/rss/download?id=" & $number & "&passkey=" & $randomString


           GUICtrlSetData($output, $modifiedUrl)


        Case $buttonCopy
            Local $modifiedUrl = GUICtrlRead($output)
            ClipPut($modifiedUrl)
            MsgBox(64, "Information", "The modified URL has been copied to the clipboard.")

        Case $buttonOpenBrowser
            Local $modifiedUrl = GUICtrlRead($output)
            If $modifiedUrl <> "" Then
                ShellExecute($modifiedUrl)
            Else
                MsgBox(16, "Error", "No modified URL was generated.")
            EndIf

        Case $buttonClear
            GUICtrlSetData($input, "")
            GUICtrlSetData($output, "")
    EndSwitch
WEnd

GUIDelete($hGUI)
Exit

Basically this regex extract the first sequence of numbers from your link.

Edited by Andreik

When the words fail... music speaks.

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