Sign in to follow this  
Followers 0
SmOke_N

_Au3ExecuteConvertString()

1 post in this topic

#1 ·  Posted (edited)

I've noticed more and more people using /AutoIt3ExecuteScript or /AutoIt3ExecuteLine, I've also seen some nice ways to manipulate those options from fellow forum members. It seems ... as was the case with myself initially ... that people have a hard time converting the string to be useable with them.

This is just a stab at making a conversion utility that will convert your strings for you, I can't remember for the life of me if MHz has already done it, if he has, I'm sure his is more efficient for mine was done on fatigue stamina.

If you'd like to better it, or make it more efficient please feel free, I don't know how it will handle every circumstance, but with the proper string submission it should do ok.

Example:

$str = 'msgbox(0, """title""", "apple")'
_Au3ExecuteConvertString($str)

Func _Au3ExecuteConvertString($sString)
    Local $sSQ, $sDQ, $sHold
    $sString = StringReplace($sString, "''", '@@')
    $sString = StringReplace($sString, '""', '^^')
    While StringLen($sString) > 0
        $sSQ = StringInStr($sString, "'")
        $sDQ = StringInStr($sString, '"')
        If Not $sSQ And Not $sDQ Then ExitLoop
        If $sSQ > 0 And ($sDQ > $sSQ Or $sDQ = 0) Then
            $sHold &= '"' & StringReplace(StringLeft($sString, _
                StringInStr($sString, "'", 0, 2)), '@@', "''") & '" & '
            $sString = StringTrimLeft($sString, StringInStr($sString, "'", 0, 2))
        Else
            $sHold &= "'" & StringReplace(StringLeft($sString, _
                StringInStr($sString, '"', 0, 2)), '^^', '""') & "' & "
            $sString = StringTrimLeft($sString, StringInStr($sString, '"', 0, 2))
        EndIf
    WEnd
    If StringLen($sString) > 0 Then
        $sHold &= "'" & StringReplace(StringReplace($sString, '^^', '""'), '@@', "''") & "'"
    EndIf
    Local $Au3ExCsGUI = GUICreate('Au3Execute Conversion', 400, 300)
    Local $Au3ExCsEdit = GUICtrlCreateEdit($sHold, 0, 0, 400, 240)
    Local $Au3ExCsButt = GUICtrlCreateButton('Ok', 175, 250, 50, 30)
    GUISetState()
    While 1
        Switch GUIGetMsg()
            Case -3, $Au3ExCsButt
                ClipPut($sHold)
                GUIDelete($Au3ExCsGUI)
                ExitLoop
        EndSwitch
    WEnd            
    Return 1
EndFunc

The theory was all you had to do was copy and paste from the Edit control directly to your Run() command or variables for your Run() command, it's put in the clipboard anyway, but the option is still there to copy manually or see what it turned out like before doing so.

Edit:
I never even looked at the GUI before posting it, I forgot to exit the loop :P

Edit2:
After looking at this, this very well could be absolutely USELESS! :D I'm too tired to even tell :)

Edited by SmOke_N
fixed broken autoit tag

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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  
Followers 0