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

    • 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
       
    • 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 (*I recently changed this path) 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
    • 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"
    • Rskm
      By Rskm
      Hi, I have the following line in a text file 'input.txt'. I know the line number - say '6'. I wish to replace the text 'WWW' in the below line with a random number (I can generate that with random()).
      WERIS  WWWJP   3.83  8.330  1.000                1097.RAXX 
      The WWW is a 3 digit integer (could be any number between 0 to 999), I can use stringtrimleft and get the numerical value of WWW in this file
      so, basically, I know the string to replace (ie; WWW stored in a variable), I know the line number to work on and the file location/name and the replacement variable (through random()). My requirement is to fill that 3 spaces with my random number (which Is a integer between 1 and 999)
      please put ur suggestions
       
    • nacerbaaziz
      By nacerbaaziz
      Hello Members of this best Forum
      i have a question please
      for example if i have a long string
      and i want to extract a text between two tag
      what i can do to make that?
      note :
      i know that there is a
      StringRegExp function
      it's do that work
      but it result is be as an array
      i want the result to be a string
      is there any function on autoit can do that?
      Thanks in advance.
×