Jump to content
Sign in to follow this  
Tinutron

GUICtrlRead Edit and reverse Strings line by line

Recommended Posts

Tinutron

Hey guys! I just started to work on a script to convert/encrypt strings in a simple GUI. First of all, here is my code:

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

$Form1 = GUICreate("Form1", 615, 438, 574, 290)
$Text = GUICtrlCreateEdit("", 8, 40, 601, 353)
GUICtrlSetData(-1, "")
$Convert = GUICtrlCreateButton("Convert", 8, 400, 297, 33)
$Close = GUICtrlCreateButton("Close", 312, 400, 297, 33)
$StringReverse = GUICtrlCreateRadio("String Reverse", 16, 8, 89, 17)
$StringEncrypt = GUICtrlCreateRadio("String Encrypt", 128, 8, 89, 17)
$Frame1 = GUICtrlCreateGroup("", 8, 0, 105, 33)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Password = GUICtrlCreateInput("", 216, 8, 385, 21)
$Frame2 = GUICtrlCreateGroup("", 120, 0, 489, 33)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Close
            Exit
        Case $Convert
            If GUICtrlRead($StringReverse) = 1 Then
                $ReadText = GUICtrlRead($Text)
                $ReverseText = _StringReverse($ReadText)
                GUICtrlSetData($Text, $ReverseText)
            ElseIf GUICtrlRead($StringEncrypt) = 1 Then
                $ReadText = GUICtrlRead($Text)
                $ReadPassword = GUICtrlRead($Password)
                If $ReadPassword = Not 0 Then
                    $TextEncrypt = _StringEncrypt(1, $ReadText, $ReadPassword)
                    GUICtrlSetData($Text, $TextEncrypt)
                Else
                    MsgBox(0,"Error","String encryption requires a password")
                EndIf
            Else
                MsgBox(0,"Error","No manipulation method specified")
            EndIf
    EndSwitch
WEnd

The problem with this is, if i want to convert for example somthing like this:

"String1"

"String2"

"String3"

GUICtrlRead will read it as "String1""String2""String3". I tried to mess around with StringSplit, but can't get it to work. Any indeas? :)

Share this post


Link to post
Share on other sites
FireFox

Hi,

How do you want the output to be?

Input:

String1

String2

String3

Output:

String3

String2

String1

??

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Tinutron

I want the output to look like this:

"1gnirtS"

"2gnirtS"

"3gnirtS"

Basicly i just dont want the script to put everything in the same line, which would look like this:

"3gnirtS""2gnirtS""1gnirtS"

Thank you!

Share this post


Link to post
Share on other sites
FireFox

Or...

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <String.au3>
 
$Form1 = GUICreate("Form1", 615, 438, 574, 290)
$Text = GUICtrlCreateEdit("", 8, 40, 601, 353)
$Convert = GUICtrlCreateButton("Convert", 8, 400, 297, 33)
$Close = GUICtrlCreateButton("Close", 312, 400, 297, 33)
$StringReverse = GUICtrlCreateRadio("String Reverse", 16, 8, 89, 17)
$StringEncrypt = GUICtrlCreateRadio("String Encrypt", 128, 8, 89, 17)
$Frame1 = GUICtrlCreateGroup("", 8, 0, 105, 33)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Password = GUICtrlCreateInput("", 216, 8, 385, 21)
$Frame2 = GUICtrlCreateGroup("", 120, 0, 489, 33)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
 
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Close
            Exit
        Case $Convert
            If GUICtrlRead($StringReverse) = 1 Then
                $ReadText = GUICtrlRead($Text)
                GUICtrlSetData($Text, "")
 
                $aText = StringSplit($ReadText, @CRLF, 1)
                $sText = ""
                For $i = 1 To $aText[0]
                    $sText &= _StringReverse($aText[$i]) & @CRLF
                Next
                GUICtrlSetData($Text, StringTrimRight($sText, 2))
            ElseIf GUICtrlRead($StringEncrypt) = 1 Then
                $ReadText = GUICtrlRead($Text)
                $ReadPassword = GUICtrlRead($Password)
                If $ReadPassword = Not 0 Then
                    $TextEncrypt = _StringEncrypt(1, $ReadText, $ReadPassword)
                    GUICtrlSetData($Text, $TextEncrypt)
                Else
                    MsgBox(0, "Error", "String encryption requires a password")
                EndIf
            Else
                MsgBox(0, "Error", "No manipulation method specified")
            EndIf
    EndSwitch
WEnd
Br, FireFox.
  • Like 1

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Tinutron

Thank you very,very much! :*

Share this post


Link to post
Share on other sites
FireFox

huh, you're welcome.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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
Sign in to follow this  

  • Similar Content

    • nooneclose
      By nooneclose
      I need help turning this string "20180913221626" into a formatted time string.
      I need to go from this: 20180913221626
      to this: 09/13/2018 10:16 PM
      I do not always know what the date will be so I can not just use a variable I need to actually convert/format. 
      I did see an older post in the forms that was basically the same question only the other guy did not post the working code and I can not figure out how to use _AD_GetObjectProperties properly to get what I want. 
      As always any help would be appreciated. 
      Here is the code I use to find the date, but it always gives me the unformatted version. 
      ;retrieve the items object $oItem = $oOutlook.Session.GetItemFromID($aItems[1][0], Default) $oItem.GetInspector $eSentOn = $oItem.SentOn ; When was the email sent? MsgBox("", "Sent On of the email", $eSentOn) ;******************************************************************************* ; Formats the date and time from the email ;******************************************************************************* ;Local $fDatenTime = _DateTimeFormat($eSentOn, 1) ;MsgBox("", "Formatted email time", $fDatenTime) $aProperties = _AD_GetObjectProperties($eSentOn) _ArrayDisplay($aProperties, "Did the conversion work?")  
    • Xandy
      By Xandy
      Special thanks: AdmiralAlkex, Melba23, MrCrearoR, Dragon Warrior 3, SDL
      MapIt is a tile world editor.  MapIt was built around the concept of reversing Dragon Warrior map images.  MapIt can take image input and produce a tile and world array.  
      Changing and replacing tile / world data is easy.  B/c tile world editor.

      CTRL+R in image above to signal replace tile action and I use "G" to Get the tile under mouse.
      A full list of hotkeys can be assigned in the: Help Menu\Hotkeys
       
      MapParser is a C++ project that scans images for unique tiles. 
      MapIt can be downloaded without MapParser. MapParser can be toggled off in the Scan_Image dialog. Without MapParser, MapIt will use the Scan_Tiles() function written in AutoIt ; which is 100 * slower Idk. If MapParser.exe will not run for you:      Installing Visual C++ Redistributable for Visual Studio 2015 should fix it: https://www.microsoft.com/en-us/download/details.aspx?id=48145   
      You can start with example world and tiles.
      Example world was made following these steps:
      Started with a tile map image of DragonWarrior3 town of: Reeve From MapIt World Menu \ New \ Scan_Image dialog, I set the area to exclude the key legend to the far right of image. After scanning the map image to world and tile array.  I removed a few of the map artifacts.  More work could be done on this world; removing unwanted tiles, but it is fine for now. I saved my world to disk.  This creates folder: Worldname: Containing folder of Tiles and a Worldname.txt. Using The Gimp, I edited some tiles to have a transparent color: Stairs, Trees, Desk Tables, Chest-of-drawers, Chairs, Signs, Doors, Beds. I changed the world layers to 2: World Menu \ Properties. F9 Finds all selected tile on current layer and changes to a new selected tile on new layer. I used F9 to change all Trees on layer: 0 to Trees on layer: 1. Then I used F9 to change all Trees on layer: 0 to Grass on layer: 0  
      In this video you can see how I used the Tile Menu \ Replace From Disk option to remap tile images to my custom tiles.  Conveniently my tiles already have a transparent pixel.
      See video for how that was done:
      To use the example world:
      First unzip the world save file: http://songersoft.com/programming/mapit/worlds/Reeve_Swapped.zip From the World Menu: choose \Load Navigate to the Reeve_Swapped.txt located in the extracted zip. Or you can scan any image.
      The map images I used are here: http://www.realmofdarkness.net/dq/games/nes/dw3/maps/world
      For download, videos, and example of created world file data; please visit the MapIt webpage: http://songersoft.com/programming/mapit/mapit_about.phtml
    • Miliardsto
      By Miliardsto
      I got that func
      Func makeHelpImgGUI($title,$width,$height,$img) $img = GUICtrlCreatePic("",20,40,$width,$height) _ResourceSetImageToCtrl($img, "HERE") EndFunc and I call this func like that
      makeHelpImgGUI("Image",1190, 800,$SETTINGS_JPG)  
      so what is the problem in the parameter where is - "HERE" I need value of img but passed as string
      so $img = $SETTINGS_JPG and how make it "SETTINGS_JPG"
       
      I tried something like that but not work
      Func makeHelpImgGUI($title,$width,$height,$img) $name_str = String($img) $name_str = StringTrimLeft ($name_str, 1 ) $img = GUICtrlCreatePic("",20,40,$width,$height) _ResourceSetImageToCtrl($img, $name_str) EndFunc  
    • Skeletor
      By Skeletor
      Hi All,
      While creating a few excel spreadsheets using AutoIt, I came across something which to my limiting time to research the forums I don't anyone has mentioned. 
      The color pallettes are reversed. 
      Huge shock to me.
       
      I wanted to produce a red row but kept on getting blue. 
      Seems like 0xFF0000 was red on the charts but when running the script, I got blue. 
      I then played around with the colors, and after a few tries, I finally got Red. 
      Reversed the FF0000 and the result is 0000FF.
       
      So for Excel compared to Html
      0000FF (Red) - Excel
      0000FF (Blue) - Html

      FFFF00 (Cyan) - Excel
      FFFF00(Yellow) - Html
       
    • liagason
      By liagason
      Hello everyone,
      How can I display in ascending  sequence some numbers stored in a string variable?
      $str = "18,03,48,23" MsgBox(0,"test",$str) I would like it to display "03,18,23,48"
×