kcvinu

A script for Automatically insert "EndIf / EndFunc" etc..

13 posts in this topic

Hi all,

This script is working. But i don't know how to limit it only for SciTE window. Here is the code. I think it will be useful for somebody. And if somebody helps to limit this function only for SciTE, this will useful for me. That's sure.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=D:\AotoIt Works\EXEs\AutoFiller32.Exe
#AutoIt3Wrapper_Outfile_x64=D:\AotoIt Works\EXEs\AutoFiller64.Exe
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

    AutoIt Version: 3.3.12.0
    Author:         kcvinu

    Script Function: This program will paste EndIf / EndFunc / WEnd / Next / EndSwitch / Until / EndSelect automaticlly right after you hit enter

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here


#include <Array.au3>
#include <String.au3>
#include <StringConstants.au3>
#include <WinAPISys.au3>

HotKeySet("{ENTER}", "AutoFiller")
HotKeySet("{ESC}", "Exiter")

While 1
    Sleep(5)

WEnd


Func AutoFiller()
    Global $Words_array
    Global $FW_array
    Global $LW_array
    Global $First_word
    Global $Index
    Global $Last_word
    Global $Parenthesis


    Global $title = WinGetTitle("[CLASS:SciTEWindow]")

    If WinGetState($title) = 47 Or WinGetState($title) = 15 Then

        Global $Current_line = ControlCommand($title, "S", 350, "GetCurrentLine", "")
        Global $Text = ControlGetText($title, "S", 350)
        Global $Text_Array = StringSplit($Text, @LF)
        Global $Current_lineRaw = $Text_Array[$Current_line]
        Global $Current_lineText = StringStripWS($Current_lineRaw, 2)
        $Current_lineText = StringStripWS($Current_lineText, 1)
        $Last_word = StringRight($Current_lineText, 4)

        $Parenthesis = StringRight($Current_lineText, 2)

        If StringInStr($Current_lineText, " ") Then

            $FW_array = StringRegExp($Current_lineText, "(^\w+)", 1)
            $First_word = $FW_array[0]
            If @error Then
                ControlSend($title, "S", 350, "{ENTER}")

            EndIf


            If $First_word == "If" And Not ($Last_word == "Then") Then
                ControlSend($title, "S", 350, " Then {ENTER}{HOME}{ENTER}EndIf {UP}{TAB}", 0)

            ElseIf $First_word == "If" And $Last_word == "Then" Then
                ControlSend($title, "S", 350, "{ENTER}{HOME}{ENTER}EndIf {UP}{TAB}", 0)

            ElseIf $First_word == "Func" And Not ($Parenthesis = "()") Then
                ControlSend($title, "S", 350, "(){ENTER}{HOME}{ENTER}EndFunc {UP}{TAB}", 0)

            ElseIf $First_word == "Func" And $Parenthesis = "()" Then
                ControlSend($title, "S", 350, "{ENTER}{HOME}{ENTER}EndFunc {UP}{TAB}", 0)

            ElseIf $First_word == "For" Then
                ControlSend($title, "S", 350, "{ENTER}{HOME}{ENTER}Next {UP}{TAB}", 0)

            ElseIf $First_word == "While" Then
                ControlSend($title, "S", 350, "{ENTER}{HOME}{ENTER}WEnd {UP}{TAB}", 0)

            ElseIf $First_word == "Do" Then
                ControlSend($title, "S", 350, "{ENTER}{HOME}{ENTER}Until {UP}{TAB}", 0)

            ElseIf $First_word == "Switch" Then
                ControlSend($title, "S", 350, "{ENTER}Case {ENTER} {HOME}EndSwitch {UP}{SPACE}", 0)

            ElseIf $First_word == "Select" Then
                ControlSend($title, "S", 350, "{ENTER}{HOME}{ENTER}EndSelect {UP}{TAB}", 0)

            Else
                ControlSend($title, "S", 350, "{ENTER}")

            EndIf
        Else
            ControlSend($title, "S", 350, "{ENTER}")

        EndIf
    Else
        Local $hnd = _WinAPI_GetActiveWindow()
        WinActivate($hnd)
        Send("{ENTER}")

    EndIf

EndFunc   ;==>AutoFiller



Func Exiter()
    Exit
EndFunc   ;==>Exiter
;~ AF()
;~ _ArrayDisplay($Words_array)

I know lines 103 to 105 are not working.

1 person likes this

My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites



What about when you slowdown a little and lower the average "threads created per day on the same topic" to 1? ;)

You shoot questions like crazy, glue it all together and post it in examples without any proper testing or finishing the development and even telling us that 3 lines aren't working.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I am giving up. All this effort was to make this feature available in SciTE. There is a dissappoinment in one side for what i am trying to do is not going to be success. On the other side you peaple are Pointing me a sword of dicspline. I am fed up. 


My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites

@

jaberwacky, I don't know... I need a feature. Tried my best. But ...

My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I am giving up. All this effort was to make this feature available in SciTE. There is a dissappoinment in one side for what i am trying to do is not going to be success. On the other side you peaple are Pointing me a sword of dicspline. I am fed up. 

SciTE is not intended to be a IDE for AutoIt3 in the same way as MS Visual Studio and will never be that type of development environment!

There are many things implemented that makes coding in SciTE for AutoIt3 much easier, but it remains a generic Editor.

To build what you want needs way more code and logic then what you posted here. logic like "only adding it one time" is not there and is not trivial.

Again... this could be a fun project but you need to be serious about it and think it through properly.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

@Jos, It is working. But i need to limit it only for SciTE. I think i need to learn more about keyboard hooking for that. 

And If SciTE is not for AutoIt, then do we need a good IDE for AutoIt ?


My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites

And If SciTE is not for AutoIt, then do we need a good IDE for AutoIt ?

An IDE can only be build when AutoIt3 has the hooks to do debugging etc.

It would be nice but honestly: This is not a complex language and it it probably isn't worth the effort it would take.

Jos

1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

@Jos, Thanks for pointing me the direction to ISN. I have it. But i thought SciTE is the "Original" IDE and sticked to it. In my short life, i havn't seen a simple language like AutoIt. In my humble opinion, if the creator of autoit can make this like the way it is, he/ she can make it worth the effort it would take. I hope.


My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites

@Jos, Thanks for pointing me the direction to ISN. I have it. But i thought SciTE is the "Original" IDE and sticked to it. In my short life, i havn't seen a simple language like AutoIt. In my humble opinion, if the creator of autoit can make this like the way it is, he/ she can make it worth the effort it would take. I hope.

I haven't pointed you in the direction of ISN since I support another setup, that was JohnOne.

Already commented about the IDE and the likelihood of that ever happening.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hi Admins,

I request you to lock this topic since i started another topic related to this script. It is a new and better version of this script. 


My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.