Hyflex 2 Posted June 27, 2011 I have no idea how to do this macro... some pointers would help a lot. I want to make a GUI with two text boxs and two buttons, Top box is inpuit Bottom box is output Button 1 = Mask Button 2 = Unmask By pressing the Mask it will do some simple text masking so if we put just for an example in the input box: of TEST Test would apear as: &£"! If we were then to put the above symbols in and press unmask it would turn it back to TEST I want to make a custom set of masks not some automatic encryption Share this post Link to post Share on other sites
JoHanatCent 13 Posted June 27, 2011 I have no idea how to do this macro... some pointers would help a lot. I want to make a GUI with two text boxs and two buttons, Top box is inpuit Bottom box is output Button 1 = Mask Button 2 = Unmask By pressing the Mask it will do some simple text masking so if we put just for an example in the input box: of TEST Test would apear as: &£"! If we were then to put the above symbols in and press unmask it would turn it back to TEST I want to make a custom set of masks not some automatic encryption MayBe something like this? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> GUICreate('Masking Example', 485, 285, 282, 117) $Label1 = GUICtrlCreateLabel('Input', 24, 10, 190, 15) $Result1 = GUICtrlCreateLabel('Result', 24, 70, 190, 15) $InPut1 = GUICtrlCreateInput('Test', 24, 32, 145, 25) $Button1 = GUICtrlCreateButton('Mask', 200, 144, 75, 25) $Button2 = GUICtrlCreateButton('Un-Mask', 200, 174, 75, 25) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button1 $try2 = '' $Try = GUICtrlRead($InPut1) $Try = StringSplit($Try, '') For $1 = 1 To UBound($Try) - 1 $try2 &= Chr(Asc($Try[$1]) - 30) Next GUICtrlSetData($Result1, $try2) Case $Button2 $try2 = '' $Try = GUICtrlRead($InPut1) $Try = StringSplit($Try, '') For $1 = 1 To UBound($Try) - 1 $try2 &= Chr(Asc($Try[$1]) + 30) Next GUICtrlSetData($Result1, $try2) EndSwitch WEnd Share this post Link to post Share on other sites
Hyflex 2 Posted June 27, 2011 (edited) That's nearly perfect however I'm trying to make it for example:: A = 5 B = % C = 3 D = * E = ( F = ) H = £ I want to make my own list of modified maskings.. also space's need to be left as spaces not some funky looking thing Edited June 27, 2011 by XxXGoD Share this post Link to post Share on other sites
JohnOne 1,603 Posted June 27, 2011 Make an array example for four letters. Local $amask[4][2] = [["A","5"],["B","%"],["C","3"],["D","*"]] Loop loop through it testing each char in your string against [n][0] and replace it if matched with [n][1] AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Share this post Link to post Share on other sites
JoHanatCent 13 Posted June 27, 2011 That's nearly perfect however I'm trying to make it for example:: A = 5 B = % C = 3 D = * E = ( F = ) H = £ I want to make my own list of modified maskings.. also space's need to be left as spaces not some funky looking thing You can make your own array and search that! expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> GUICreate('Masking Example', 485, 285, 282, 117) $Label1 = GUICtrlCreateLabel('Input', 24, 10, 190, 15) $Result1 = GUICtrlCreateLabel('Result', 24, 70, 190, 15) $InPut1 = GUICtrlCreateInput('ABC', 24, 32, 145, 25) $Button1 = GUICtrlCreateButton('Mask', 200, 144, 75, 25) $Button2 = GUICtrlCreateButton('Un-Mask', 200, 174, 75, 25) Local $myMask[7][2] = [ _ ; <<<<<<<<<< You need to set this as to how many you want!!!! ["A", "5"], _ ["B", "%"], _ ["C", "3"], _ ["D", "*"], _ ["E", "("], _ ["F", ")"], _ ["G", "$"]] ; <<<<<<<<<<< etc. GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button1 $try2 = '' $Try = GUICtrlRead($InPut1) $Try = StringSplit($Try, '') For $1 = 1 To UBound($Try) - 1 $iIndex = _ArraySearch($myMask, $Try[$1], 0, 0, 0, 1) If @error Then MsgBox(0, "Not Found", '"' & $Try[$1] & '" was not found in the array.') $try2 &= $myMask[$iIndex][1] Next GUICtrlSetData($Result1, $try2) Case $Button2 $try2 = '' $Try = GUICtrlRead($InPut1) $Try = StringSplit($Try, '') For $1 = 1 To UBound($Try) - 1 $iIndex = _ArraySearch($myMask, $Try[$1], 0, 0, 0, 2) If @error Then MsgBox(0, "Not Found", '"' & $Try[$1] & '" was not found in the array.') $try2 &= $myMask[$iIndex][0] Next GUICtrlSetData($Result1, $try2) EndSwitch WEnd Share this post Link to post Share on other sites
Hyflex 2 Posted June 27, 2011 I'm not sure how to implement the array now and JoHantCent's script doesn't work: $iIndex = _ArraySearch($myMask, $Try[$1], 0, 0, 0, 1) $iIndex = ^ ERROR Share this post Link to post Share on other sites
JohnOne 1,603 Posted June 27, 2011 Crikey !! how have you scraped through 5 years of autoit without knowing the most basic things? You would probably need to include the Array.au3 UDFs in that example. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Share this post Link to post Share on other sites
JoHanatCent 13 Posted June 27, 2011 I'm not sure how to implement the array now and JoHantCent's script doesn't work: $iIndex = _ArraySearch($myMask, $Try[$1], 0, 0, 0, 1) $iIndex = ^ ERROR If you're still stuck, JohnOne is correct. Just add this line right at the top: #Include <Array.au3> Share this post Link to post Share on other sites
Hyflex 2 Posted June 27, 2011 (edited) Thank you everyone JohnOne I'm really awful at learning things & have awful memory so I forget things For reference purposes, here is the macro in full. Note: The Masks are not done in full yet. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> TraySetClick(8) Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 1) Opt("TrayAutoPause", 0) $Tray_ViewApplication = TrayCreateItem("View Applicaion") TrayItemSetOnEvent(-1, "ViewApplication") $Tray_Exit = TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "Terminate") GUICreate('RDBB J&B Masking - Thanks to JoHanatCent and JohnOne', 290, 130, 280, 100) $InputLabel = GUICtrlCreateLabel('Input', 25, 10, 190, 15) $InputDataBox = GUICtrlCreateInput('', 25, 30, 150, 25) $OutputLabel = GUICtrlCreateLabel('Output', 25, 70, 190, 15) $OutputDataBox = GUICtrlCreateInput('', 25, 90, 150, 25) $MaskingButton = GUICtrlCreateButton('Mask', 200, 30, 70, 25) $UnmaskingButton = GUICtrlCreateButton('Unmask', 200, 60, 70, 25) $CopyOutputData= GUICtrlCreateButton('Copy', 200, 90, 70, 25) Local $myMask[7][2] = [ _ ["A", "5"], _ ["B", "%"], _ ["C", "3"], _ ["D", "*"], _ ["E", "("], _ ["F", ")"], _ ["G", "$"]] GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $MaskingButton $try2 = '' $Try = GUICtrlRead($InputDataBox) $Try = StringSplit($Try, '') For $1 = 1 To UBound($Try) - 1 $iIndex = _ArraySearch($myMask, $Try[$1], 0, 0, 0, 1) If @error Then MsgBox(0, "Not Found", '"' & $Try[$1] & '" was not found in the array.') $try2 &= $myMask[$iIndex][1] Next GUICtrlSetData($OutputDataBox, $try2) Case $UnmaskingButton $try2 = '' $Try = GUICtrlRead($InputDataBox) $Try = StringSplit($Try, '') For $1 = 1 To UBound($Try) - 1 $iIndex = _ArraySearch($myMask, $Try[$1], 0, 0, 0, 2) If @error Then MsgBox(0, "Not Found", '"' & $Try[$1] & '" was not found in the array.') $try2 &= $myMask[$iIndex][0] Next GUICtrlSetData($OutputDataBox, $try2) Case $CopyOutputData ClipPut(GUICtrlRead($OutputDataBox)) EndSwitch WEnd Func ViewApplication() GUISetState(@SW_SHOW) WinActivate("RDBB J&B Masking - Thanks to JoHanatCent and JohnOne") EndFunc Func Terminate() Exit 0EndFunc Edited June 27, 2011 by XxXGoD Share this post Link to post Share on other sites
Hyflex 2 Posted June 27, 2011 How can I edit the above macro so if it finds an error with the IF @error instead of closing after the error for it to simply leave the non-matched part... So if I entered: ABCFK it would give me an error pop up that K isnt found and then the output data would be: 5%3)K Share this post Link to post Share on other sites
AdmiralAlkex 125 Posted June 27, 2011 Like this? $iIndex = _ArraySearch($myMask, $Try[$1], 0, 0, 0, 1) If @error Then MsgBox(0, "Not Found", '"' & $Try[$1] & '" was not found in the array.') $try2 &= $Try[$1] Else $try2 &= $myMask[$iIndex][1] EndIf .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Share this post Link to post Share on other sites
Hyflex 2 Posted June 27, 2011 Like this? $iIndex = _ArraySearch($myMask, $Try[$1], 0, 0, 0, 1) If @error Then MsgBox(0, "Not Found", '"' & $Try[$1] & '" was not found in the array.') $try2 &= $Try[$1] Else $try2 &= $myMask[$iIndex][1] EndIf Yes and no, it puts the input data into the output data... doesn't quite work it out correct :/ Share this post Link to post Share on other sites
JoHanatCent 13 Posted June 27, 2011 (edited) Yes and no, it puts the input data into the output data... doesn't quite work it out correct :/ We'll I tried the solution it works correctly. Did you also fix the Case $UnmaskingButton part? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> TraySetClick(8) Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 1) Opt("TrayAutoPause", 0) $Tray_ViewApplication = TrayCreateItem("View Applicaion") TrayItemSetOnEvent(-1, "ViewApplication") $Tray_Exit = TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "Terminate") TraySetState(); Just in Case. You need this to make the tray thingy also work <<<<<<<<<<<<<<< ================= GUICreate('RDBB J&B Masking - Thanks to JoHanatCent and JohnOne', 290, 130, 280, 100) $InputLabel = GUICtrlCreateLabel('Input', 25, 10, 190, 15) $InputDataBox = GUICtrlCreateInput('', 25, 30, 150, 25) $OutputLabel = GUICtrlCreateLabel('Output', 25, 70, 190, 15) $OutputDataBox = GUICtrlCreateInput('', 25, 90, 150, 25) $MaskingButton = GUICtrlCreateButton('Mask', 200, 30, 70, 25) $UnmaskingButton = GUICtrlCreateButton('Unmask', 200, 60, 70, 25) $CopyOutputData = GUICtrlCreateButton('Copy', 200, 90, 70, 25) Local $myMask[7][2] = [ _ ["A", "5"], _ ["B", "%"], _ ["C", "3"], _ ["D", "*"], _ ["E", "("], _ ["F", ")"], _ ["G", "£"]] GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $MaskingButton $try2 = '' $Try = GUICtrlRead($InputDataBox) $Try = StringSplit($Try, '') For $1 = 1 To UBound($Try) - 1 $iIndex = _ArraySearch($myMask, $Try[$1], 0, 0, 0, 1) If @error Then MsgBox(0, "Not Found", '"' & $Try[$1] & '" was not found in the array.') $try2 &= $Try[$1] Else $try2 &= $myMask[$iIndex][1] EndIf Next GUICtrlSetData($OutputDataBox, $try2) Case $UnmaskingButton $try2 = '' $Try = GUICtrlRead($InputDataBox) $Try = StringSplit($Try, '') For $1 = 1 To UBound($Try) - 1 $iIndex = _ArraySearch($myMask, $Try[$1], 0, 0, 0, 2) If @error Then MsgBox(0, "Not Found", '"' & $Try[$1] & '" was not found in the array.') $try2 &= $Try[$1] Else $try2 &= $myMask[$iIndex][0] EndIf Next GUICtrlSetData($OutputDataBox, $try2) Case $CopyOutputData ClipPut(GUICtrlRead($OutputDataBox)) EndSwitch WEnd Func ViewApplication() GUISetState(@SW_SHOW) WinActivate("RDBB J&B Masking - Thanks to JoHanatCent and JohnOne") EndFunc ;==>ViewApplication Func Terminate() Exit 0 EndFunc ;==>Terminate Edited June 27, 2011 by JoHanatCent Share this post Link to post Share on other sites