AutoTyper

Post your working scripts, libraries and tools for AHK v1.1 and older
indest
Posts: 5
Joined: 12 Apr 2020, 21:00

AutoTyper

14 Apr 2020, 12:25

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.
payaAHK
Posts: 106
Joined: 30 Oct 2016, 15:28

Re: AutoTyper

17 Apr 2020, 09:58

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:
payaAHK
Posts: 106
Joined: 30 Oct 2016, 15:28

Re: AutoTyper

17 Apr 2020, 10:02

sorry
working with last version of AHK
thanks
indest
Posts: 5
Joined: 12 Apr 2020, 21:00

Re: AutoTyper

24 Apr 2020, 22:35

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 :).
User avatar
Cerberus
Posts: 172
Joined: 12 Jan 2016, 15:46

Re: AutoTyper

25 Apr 2020, 13:45

Hmm what does this script do? Even more people might try it if the first post had a little description.
User avatar
submeg
Posts: 326
Joined: 14 Apr 2017, 20:39
Contact:

Re: AutoTyper

26 Apr 2020, 06:56

Is this similar to a text expander?
____________________________________
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey :ugeek:
User avatar
adegard
Posts: 90
Joined: 24 Nov 2017, 05:58
Contact:

Re: AutoTyper

26 Apr 2020, 11:40

very nice, thanks :bravo:

...anyway I have an issue with symbols (like #)
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: AutoTyper

27 Apr 2020, 03:28

submeg wrote:
26 Apr 2020, 06:56
Is this similar to a text expander?
Yes
F1nn_069
Posts: 7
Joined: 18 May 2020, 04:30

Re: AutoTyper

20 May 2020, 20:14

do i just paste the code into an AutoHotkey file? if so its not working for me

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: fiendhunter and 71 guests