Enhancement for AutoComplete function

Everything else that doesn't fall into one of the other PB categories.
User avatar
Michael Vogel
Addict
Addict
Posts: 2820
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Enhancement for AutoComplete function

Post by Michael Vogel »

Hi,

my "AutoComplete for PureBasic" script is a little bit better now, so it can add open brackets to functions...

How it works?
- the script works with AutoHotkey, just save it to autohotkey.ini and start the program
- if you use the script, disable the autocomplete function within the PureBasic IDE
- the script gets active by pressing [windows]-p, a red symbol is seen in the tray
- the script remembers all keyboard input until [tab], [enter] or [space] is pressed
- if you are in the PureBasic IDE (or you have also pressed [shift]) the input gets investigated
- if the last characters of the input match with "keywords" they are replaced by it's associated text (you have to adapt these to your prefered key words)
- if the new text does NOT end with an open bracket, the [tab], [enter] or [space] will be added

Code: Select all

#p::				; Hotkeys für Purebasic aktivieren
				; V1.02 - written by Michael Vogel
if Purekeys
{
	Purekeys:=0
  	SetTimer,PureBasic,Off
	menu,tray,Icon,%A_AhkPath%,6
}
else
{	; <<<< change the next line to your prefered key words >>>>
	p=pro#Procedure#line#LineXY(#endp#EndProcedure#retp#ProcedureReturn#th#Then#ei#EndIf#fo#For#ne#Next#sel#Select#cas#case#ends#EndSelect#def#Default#deb#Debug#glo#Global#rep#Repeat#unt#Until#wh#While#we#Wend#getevent#WaitWindowEvent()#wparam#EventwParam()#startd#StartDrawing(#stopd#StopDrawing()#winout#WindowOutput(#winid#WindowsID(#gettick#GetTickCount_()#bcol#BackColor(#fcol#FrontColor(#text#DrawText(#del#Delay(#openw#OpenWindow(
	StringSplit,p,p,#
	pp:=p0/2
	Purekeys:=1
	SetTimer,PureBasic,100
	menu,tray,Icon,%A_AhkPath%,4
	menu,tray,Icon
}
return

;----------------------------------------------:

PureBasic:
SetTimer,PureBasic,Off

Input,UserInput,*V,{Return}{Tab}{Space}

; <<<< choose here, if the script is only active within Purebasic or if the [shift] key is pressed >>>>
;IfWinActive, PureBasic
If GetKeyState("Shift")
{
If Instr(ErrorLevel,"EndKey:")>0
	{	index=0
		StringLen,path,UserInput
		Loop, %pp%
		{	index++
			temp:=p%index%
			index++
			StringLen,dummy,temp
			dummy:=path-dummy
			{
				If InStr(UserInput,temp,0,dummy)
				{
					StringLen,dummy,temp
					dummy++
					temp:=p%index%
					Send,{Backspace %dummy%}%temp%

					StringLen,dummy,temp
					if instr(temp,"(")<>dummy
					{
						taste:=""
						stringmid,taste,errorlevel,8,10
						send {%taste%}
					}
					break
				}
			}
		}
	}
}
SetTimer,PureBasic,On
Return