Page 1 of 1

AutoTyper

Posted: 14 Apr 2020, 12:25
by indest
This is an alternative to a paid program called Breevy:

Code: Select all

#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir% 
#Persistent
#SingleInstance force
#IfWinActive
#Hotstring c0 r0


;Global variables
;Left-click and right-click menus are not open when script begins
LeftClickMenuOpen := 0
RightClickMenuOpen := 0



;Program Start
gosub CreateLeftClickMenu
gosub CreateRightClickMenu
OnMessage(0x404, "AHK_NOTIFYICON")

fileread, savedtemplates, templates.txt
loop, parse, savedtemplates,\, `n`r 
{
	hs:=strsplit(a_loopfield,"|"," `n`r")
	hotstring(hs[1],StrReplace(hs[2],"`n",""))
}


return


CreateLeftClickMenu:
Menu, LeftClickMenu, add, Add Template, Template
Menu, LeftClickMenu, add
Menu, LeftClickMenu, add, % "Exit", ExitProgram
return

CreateRightClickMenu:
Menu, tray, NoStandard
Menu, tray, add, Add Template, Template
Menu, tray, add
Menu, tray, add, % "Exit", ExitProgram
return


Template:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Template start
Gui, Add, Text, x6 y17 w180 h20 , Template Keyword
Gui, Add, Edit, x6 y37 w180 h20 vName
Gui, Add, Text, x6 y67 w180 h20 , More Info 
Gui, Add, Edit, x6 y97 w610 h270 vInfo
Gui, Add, Button, x296 y387 w100 h30 gClear, Clear 
Gui, Add, Text, x6 y387 h20, Add ^b between words you want to bold, ie: ^bHEENT^b
Gui, Add, Text, x6 y407 h20, Add ^i between words you want to italicize, ie: ^iHEENT^i
Gui, Add, Button, x406 y387 w100 h30 gSubmitMore, Submit + Add More 
Gui, Add, Button, x516 y387 w100 h30 gSubmitExit, Submit + Exit
Gui, Show, x231 y199 h427 w623, New GUI Window 
Return 

Clear:
GuiControl,, Name
GuiControl,, Info
Gui, Submit, NoHide
returnClear:
GuiControl,, Name
GuiControl,, Info
Gui, Submit, NoHide
return

SubmitMore:
Gui, Submit, NoHide
if Name is space
{
	Msgbox, Please insert some data first!
	return
}
	if FileExist("templates.txt")
		{
		FileAppend, `n\::%Name%|%Info%, templates.txt
		}
	Else
		{
		FileAppend, ::%Name%|%Info%, templates.txt
		}
GuiControl,, Name
GuiControl,, Info
return

SubmitExit:
Gui, Submit, NoHide
if Name is space
{
Msgbox, Please insert some data first!
return
}
	if FileExist("templates.txt")
		{
		FileAppend, `n\::%Name%|%Info%, templates.txt
		}
	Else
		{
		FileAppend, ::%Name%|%Info%, templates.txt
		}
Reload
return

Esc::
GuiClose: 
Gui Destroy
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Template End

return

/*
Lexikos method of detecting Left mouse click on ToolTray (modified)


If left click and left-click menu open, close left-click menu
If left click and left-click menu not open, open left-click menu
    (and close right-click menu, if open)

If right click and right-click menu open, close right-click menu
If right click and right-click menu not open, open right-click menu
    (and close left-click menu, if open)
*/

AHK_NOTIFYICON(wParam, lParam)
{
    global LeftClickMenuOpen, RightClickMenuOpen

    if (lParam = 0x202) ; WM_LBUTTONUP
    {
        ;Close right-click menu
        RightClickMenuOpen := 0

        if (LeftClickMenuOpen)
        {
            ;If left-click menu is open, close it
            Send {Esc}
        }
        else
        {
            ;If left-click menu is not open, open it
            Menu, LeftClickMenu, Show
        }

        ;Toggle state of left-click menu
        ;Open to close
        ;Close to open
        LeftClickMenuOpen := !LeftClickMenuOpen
    }
    else if (lParam = 0x205) ; WM_RBUTTONUP
    {
        ;Close left-click menu
        LeftClickMenuOpen := 0

        if (RightClickMenuOpen)
        {
            ;If right-click menu is open, close it
            Send {Esc}
        }
        else
        {
            ;If right-click menu is not open, open it
            Menu, Tray, Show
        }

        ;Toggle state of right-click menu
        ;Open to close
        ;Close to open
        RightClickMenuOpen := !RightClickMenuOpen
    }

    return 0
}

ExitProgram:
The tray icon has a menu that opens up a GUI for template creation and also allows you to kill the script.

Re: AutoTyper

Posted: 17 Apr 2020, 09:58
by payaAHK
hello;
when running i get:
L:\ap2\Downloads\abv 000.ahk (26) : ==> Call to nonexistent function.
Specifically: hotstring(hs[1],StrReplace(hs[2],"
",""))
>Exit code: 2 Time: 0.8294

:oops:

Re: AutoTyper

Posted: 17 Apr 2020, 10:02
by payaAHK
sorry
working with last version of AHK
thanks

Re: AutoTyper

Posted: 24 Apr 2020, 22:35
by indest
payaAHK wrote:
17 Apr 2020, 10:02
sorry
working with last version of AHK
thanks
Glad you got it to work. Hope you like it :).

Re: AutoTyper

Posted: 25 Apr 2020, 13:45
by Cerberus
Hmm what does this script do? Even more people might try it if the first post had a little description.

Re: AutoTyper

Posted: 26 Apr 2020, 06:56
by submeg
Is this similar to a text expander?

Re: AutoTyper

Posted: 26 Apr 2020, 11:40
by adegard
very nice, thanks :bravo:

...anyway I have an issue with symbols (like #)

Re: AutoTyper

Posted: 27 Apr 2020, 03:28
by ozzii
submeg wrote:
26 Apr 2020, 06:56
Is this similar to a text expander?
Yes

Re: AutoTyper

Posted: 20 May 2020, 20:14
by F1nn_069
do i just paste the code into an AutoHotkey file? if so its not working for me