Search the Community
Showing results for tags 'code error'.
-
Hi all, I am trying to make simple function to help coding in SciTE editor. This function will automatically add an "EndIf / EndFunc / WEnd / Next / EndSwitch / EndSelect / Until " after we press the enter key. It checks for first word of that line. And if the first word is " If / Func / While / For / Switch / Select / Do" , then it will work. Otherwise a normal enter key will work. Please look at my code. Unfortunately, this is not working. Please help me to find the error. #include <StringConstants.au3> #include <Array.au3> HotKeySet("{ENTER}", "AutoFiller") HotKeySet("!{ESC}", "Exiter") While 1 Sleep(10) WEnd Func AutoFiller() Local $title = WinGetTitle("[CLASS:SciTEWindow]") ; getting title of SciTE window Local $text = ControlGetText($title, "S", 350) ; getting text from code editor Local $col = ControlGetText($title, "", 353) ; getting text from status bar Local $Get_Digit_from_col = StringRegExp($col, "\d{1,4}", 3) ; an array and put line number and col number Local $Line_number = $Get_Digit_from_col[0] ; this is line number where cursor residing Local $Col_number = $Get_Digit_from_col[1] ; this is col number where cursor residing Local $CodeLines_Array = StringSplit($text, @CR) ; splitting code window text as lines Local $Last_lineText = $CodeLines_Array[$Line_number] ; this is text where cursor residing Local $TempArray = StringSplit($Last_lineText, " ") ; splitting the text into words Local $Start_text = $TempArray[1] ; this is the first word in that line Local $End_text = $TempArray[$TempArray[0]] ; this is the last word in that line If $Start_text = "If" And $End_text = "Then" Then ControlSend($title, "S", 350, "{ENTER}{BACKSPACE}{ENTER}EndIf{ESC}{UP}{TAB}") ElseIf $Start_text = "If" And $End_text <> "Then" Then ControlSend($title, "S", 350, " Then {ENTER}{BACKSPACE}{ENTER}EndIf{ESC}{UP}{TAB}") ElseIf $Start_text = "Func" Then ControlSend($title, "S", 350, "{ENTER}{BACKSPACE}{ENTER}EndFunc{ESC}{UP}{TAB}") ElseIf $Start_text = "While" Then ControlSend($title, "S", 350, "{ENTER}{BACKSPACE}{ENTER}WEnd{ESC}{UP}{TAB}") ElseIf $Start_text = "For" Then ControlSend($title, "S", 350, "{ENTER}{BACKSPACE}{ENTER}Next{ESC}{UP}{TAB}") ElseIf $Start_text = "Do" Then ControlSend($title, "S", 350, "{ENTER}{BACKSPACE}{ENTER}Untill{ESC}{UP}{TAB}") ElseIf $Start_text = "Switch" Then ControlSend($title, "S", 350, "{ENTER}Case {ENTER} {BACKSPACE}EndSwitch{ESC}{UP}{END}") ElseIf $Start_text = "Select" Then ControlSend($title, "S", 350, "{ENTER}Case {ENTER} {BACKSPACE}EndSelect{ESC}{UP}{END}") Else ControlSend($title, "S", 350, "{ENTER}") EndIf EndFunc ;==>AutoFiller Func Exiter() Exit EndFunc ;==>Exiter