I'm even new to AutoIT and just occupied myself with a little script, that should replace some variables in a script.
It works like this:
You put your script into the clipboard. Then you tell the GUI what to replace e.g. $a should be replaced with $bb
The problem is, that i didnt find out, how to make string replace just replacing EXACT MATCHES.
E.g.:
$a = 55
$ab = 10
replace $a with $b
=> he returns
$b = 55
$bb = 10
But that's wrong :( I want to replace just $a and not $ab
=>
$b = 55
$ab = 10
Pleace help me :)
Here's the Script:
#cs Code-Variable replacer by BennyBB #ce #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 625, 445, 192, 124) $Input1 = GUICtrlCreateInput("", 60, 40, 185, 21) $Input2 = GUICtrlCreateInput("", 370, 40, 185, 21) $Input6 = GUICtrlCreateInput("", 60, 90, 185, 21) $Input3 = GUICtrlCreateInput("", 370, 90, 185, 21) $Input7 = GUICtrlCreateInput("", 60, 140, 185, 21) $Input4 = GUICtrlCreateInput("", 370, 140, 185, 21) $Input8 = GUICtrlCreateInput("", 60, 190, 185, 21) $Input5 = GUICtrlCreateInput("", 370, 190, 185, 21) $input9 = GUICtrlCreateInput("", 60, 240, 185, 21) $input10 = GUICtrlCreateInput("", 370, 240, 185, 21) $input11 = GUICtrlCreateInput("", 60, 290, 185, 21) $input12 = GUICtrlCreateInput("", 370, 290, 185, 21) $Label1 = GUICtrlCreateLabel("$", 15, 40, 36, 17) $Label2 = GUICtrlCreateLabel("$", 15, 90, 36, 17) $Label3 = GUICtrlCreateLabel("$", 15, 140, 36, 17) $Label4 = GUICtrlCreateLabel("$", 15, 190, 36, 17) $Label5 = GUICtrlCreateLabel("wird zu $", 300, 40, 76, 17) $Label6 = GUICtrlCreateLabel("wird zu $", 300, 90, 60, 17) $Label7 = GUICtrlCreateLabel("wird zu $", 300, 140, 60, 17) $Label8 = GUICtrlCreateLabel("wird zu $", 300, 190, 60, 17) $Label9 = GUICtrlCreateLabel("$", 15, 240, 36, 17) $label10 = GUICtrlCreateLabel("wird zu $", 300, 240, 60, 17) $label11 = GUICtrlCreateLabel("$", 15, 290, 36, 17) $label12 = GUICtrlCreateLabel("wird zu $", 300, 290, 60, 17) $Button1 = GUICtrlCreateButton("Start", 176, 304, 273, 73, $WS_GROUP) $Button2 = GUICtrlCreateButton("Add", 24, 248, 121, 33, $WS_GROUP) GUICtrlSetState($input9,$GUI_HIDE) GUICtrlSetState($input10,$GUI_HIDE) GUICtrlSetState($input11,$GUI_HIDE) GUICtrlSetState($input12,$GUI_HIDE) GUICtrlSetState($label9,$GUI_HIDE) GUICtrlSetState($label10,$GUI_HIDE) GUICtrlSetState($label11,$GUI_HIDE) GUICtrlSetState($label12,$GUI_HIDE) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $add = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $input1 = "$" & GUICtrlRead($input1) $input2 = "$" & GUICtrlRead($input2) $input3 = "$" & GUICtrlRead($input3) $input4 = "$" & GUICtrlRead($input4) $input5 = "$" & GUICtrlRead($input5) $input6 = "$" & GUICtrlRead($input6) $input7 = "$" & GUICtrlRead($input7) $input8 = "$" & GUICtrlRead($input8) If $add = 1 Then $input9 = "$" & GUICtrlRead($input9) $input10 = "$" & GUICtrlRead($input10) $input11 = "$" & GUICtrlRead($input11) $input12 = "$" & GUICtrlRead($input12) EndIf GUIDelete($form1) replace () Case $button2 Guictrlsetstate($label9,$GUI_SHOW) GUICtrlSetState($input10,$GUI_SHOW) GUICtrlSetState($label11,$GUI_SHOW) GUICtrlSetState($label12,$GUI_SHOW) GUICtrlSetState($input9,$GUI_SHOW) GUICtrlSetState($input12,$GUI_show) GUICtrlSetState($input11,$GUI_SHOW) GUICtrlSetState($label10,$GUI_SHOW) GUICtrlSetPos($button1,176,354) GUICtrlSetState($button2,$GUI_HIDE) Dim $add = 1 EndSwitch WEnd Func replace () $code = CliPGet() MsgBox (0,"",$code) If $code = 1 Then ToolTip ("No text in clipboard") ElseIf IsString($code) = 1 Then $code = StringReplace ($code,$input1,$input2,0,1) $code = StringReplace ($code,$input3,$input4,0,1) $code = StringReplace ($code,$input5,$input6,0,1) $code = StringReplace ($code,$input7,$input8,0,1) $code = StringReplace ($code,$input9,$input10,0,1) $code = StringReplace ($code,$input11,$input12,0,1) MsgBox (0,"",$code) ClipPut($code) EndIf Exit EndFunc

Sign In
Register
Help
MultiQuote
