Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Emulate Keystrokes - set input speed?

If you have a question or need help, this is the place to be.
Post Reply
PaulBags
Posts: 14
Joined: Fri Oct 21, 2016 2:49 am

Emulate Keystrokes - set input speed?

Post by PaulBags »

Hi, I'm looking for a way to set the input speed for emulated keystrokes. I've searched everywhere and can't find any mention of it.
eirik226
Experienced User
Posts: 142
Joined: Wed Nov 07, 2012 5:22 pm

Re: Emulate Keystrokes - set input speed?

Post by eirik226 »

edit: never mind.
PaulBags
Posts: 14
Joined: Fri Oct 21, 2016 2:49 am

Re: Emulate Keystrokes - set input speed?

Post by PaulBags »

I'm using this for text input not menus/hotkeys, so I switched to setting the string to the clipboard and sending {ctrl+v} instead.

Input speed still would be nice to have though :).
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Emulate Keystrokes - set input speed?

Post by kgschlosser »

it's easy. you would use the keyboard emulator and set a key to it. then create another action called Wait. with Wait you can punch in a specific amount of time like 0.0001 if you want. you would have to do this between each key press you wish emulate.
If you like the work I have been doing then feel free to Image
PaulBags
Posts: 14
Joined: Fri Oct 21, 2016 2:49 am

Re: Emulate Keystrokes - set input speed?

Post by PaulBags »

Would that get faster input speed than default? For what I'm doing I think I'd have to get the length of the string I want to type, and set up a loop to get and send each charactor.
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Emulate Keystrokes - set input speed?

Post by kgschlosser »

faster? No. but it should be pretty instantaneous as it is. do this copy the marco and past it into the forum as code make sure you use the code markers by pressing the button above the forum entry window and place the code between the markers. that way i can see exactly what you are trying to acomplish and how you are going about it. to see if there might be something amiss
If you like the work I have been doing then feel free to Image
PaulBags
Posts: 14
Joined: Fri Oct 21, 2016 2:49 am

Re: Emulate Keystrokes - set input speed?

Post by PaulBags »

The goal is to get from a file name such as: "series.title.s01e23.blah.blah.blah.blah.file" to: "Series Title - S01E23 - Episode Title.file", with "Episode Title" copied and then cleaned up by EG. I use so many hotkeys because I don't always know the number of words in Series Title, or the numbering format used (s01e23 vs 123), so at a couple of stages I may have to manually move the text cursor or even edit something.

Hotkeys F3 & F8 are where I notice text input speed the most (examples taken from F8). Where I was doing this (currently commented out):

Code: Select all

# eg.plugins.Window.SendKeys(u'{ctrl+a}{eg.globals.temp_var}{enter}', False, 2)
I now do this to speed things up, because sending a variable results in individual characters being entered at a speed that would be great for human input but is a tad slow for a macro:

Code: Select all

win32clipboard.OpenClipboard()
win32clipboard.SetClipboardData(win32clipboard.CF_UNICODETEXT, unicode(eg.globals.temp_var))
win32clipboard.CloseClipboard()
eg.plugins.Window.SendKeys(u'{ctrl+a}{ctrl+v}{enter}', False, 2)
Maybe I'm just impatient?


Whole folder:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1722">
    <Folder Name="Media Renaming (Toggled by F18)" id="100" Enabled="False" Expanded="True">
        <Macro Name="Get show_name (F9)">
            <Event Name="Keyboard.F9" />
            <Action>
                EventGhost.PythonScript(u"import win32clipboard\n\neg.plugins.Window.SendKeys(u'{ctrl+c}', True, 2)\n\n# Get windows clipboard data into EG\nwin32clipboard.OpenClipboard()\neg.globals.epi_name = win32clipboard.GetClipboardData()\nwin32clipboard.CloseClipboard()\n\n# And edit out leading/trailing whitespace & illegal charactors for clean epi_name\neg.globals.epi_name = eg.globals.epi_name.strip().replace('/','&').replace(':',';').replace('!','').replace('*','').replace('?','').replace('|','')")
            </Action>
        </Macro>
        <Macro Name="Unrar 1 (F3)">
            <Event Name="Keyboard.F3" />
            <Action>
                EventGhost.PythonScript(u"import win32clipboard\n\neg.plugins.Window.SendKeys(u'{Apps}c', False, 2)\neg.plugins.EventGhost.Wait(0.5)\neg.plugins.Window.SendKeys(u'{ctrl+a}{ctrl+c}', True, 2)\n\n# Get windows clipboard data into EG\nwin32clipboard.OpenClipboard()\neg.globals.rar_str = win32clipboard.GetClipboardData()\nwin32clipboard.CloseClipboard()\n\neg.globals.rar_str = eg.globals.rar_str.replace('.',' ').replace('E:\\\\Download\\\\Bittorrent\\\\','')\n# eg.plugins.Window.SendKeys(u'{eg.globals.rar_str}{home}F:\\{ctrl+right}', True, 2)\n\nwin32clipboard.OpenClipboard()\nwin32clipboard.SetClipboardData(win32clipboard.CF_UNICODETEXT, unicode(eg.globals.rar_str))\nwin32clipboard.CloseClipboard()\neg.plugins.Window.SendKeys(u'{ctrl+v}{home}F:\\{ctrl+right}', True, 2)")
            </Action>
        </Macro>
        <Macro Name="Unrar 2 (F4)">
            <Event Name="Keyboard.F4" />
            <Action>
                Window.SendKeys(u'{left}\\{Shift+End}Season \\{left}', True, 2)
            </Action>
        </Macro>
        <Macro Name="Unrar 3 (F10)">
            <Event Name="Keyboard.F10" />
            <Action>
                EventGhost.PythonScript(u"import win32clipboard\n\neg.plugins.Window.SendKeys(u'{ctrl+a}{ctrl+c}{enter}', True, 2)\n\n# Get windows clipboard data into EG\nwin32clipboard.OpenClipboard()\neg.globals.rar_explore = win32clipboard.GetClipboardData()\nwin32clipboard.CloseClipboard()")
            </Action>
            <Action>
                System.Execute(u'explorer.exe', u'{eg.globals.rar_explore}', 2, False, 2, u'', False, False, u'', False, False, False, False)
            </Action>
        </Macro>
        <Macro Name="File Rename 1 (F5)">
            <Event Name="Keyboard.F5" />
            <Action>
                EventGhost.PythonScript(u"import win32clipboard\n\neg.plugins.Window.SendKeys(u'{f2}{ctrl+c}', False, 2)\n\n# Get windows clipboard data into EG\nwin32clipboard.OpenClipboard()\neg.globals.temp_var = win32clipboard.GetClipboardData()\nwin32clipboard.CloseClipboard()\n\neg.globals.temp_var = eg.globals.temp_var.replace('.',' ').title()\n# eg.plugins.Window.SendKeys(u'{eg.globals.temp_var}{home}{ctrl+right}', False, 2)\n\nwin32clipboard.OpenClipboard()\nwin32clipboard.SetClipboardData(win32clipboard.CF_UNICODETEXT, unicode(eg.globals.temp_var))\nwin32clipboard.CloseClipboard()\neg.plugins.Window.SendKeys(u'{ctrl+v}{home}{ctrl+right}', False, 2)")
            </Action>
        </Macro>
        <Macro Name="File Rename 2 (F6)">
            <Event Name="Keyboard.F6" />
            <Action>
                Window.SendKeys(u'- S0{right}E{right}{right}', True, 2)
            </Action>
        </Macro>
        <Macro Name="File Rename 3 (F7)">
            <Event Name="Keyboard.F7" />
            <Action>
                Window.SendKeys(u'{del}- S{right}{right}{del}E{right}{right}', True, 2)
            </Action>
        </Macro>
        <Macro Name="File Rename 4 (F8)">
            <Event Name="Keyboard.F8" />
            <Action>
                EventGhost.PythonScript(u"import win32clipboard\n\neg.plugins.Window.SendKeys(u'.{ctrl+a}{ctrl+c}', False, 2)\n\n# Get windows clipboard data into EG\nwin32clipboard.OpenClipboard()\neg.globals.temp_var = win32clipboard.GetClipboardData()\nwin32clipboard.CloseClipboard()\n\neg.globals.temp_var = eg.globals.temp_var.split('.')\neg.globals.temp_var = eg.globals.temp_var[0]+' - '+eg.globals.epi_name+'.'+eg.globals.temp_var[2]\n# eg.plugins.Window.SendKeys(u'{ctrl+a}{eg.globals.temp_var}{enter}', False, 2)\n\nwin32clipboard.OpenClipboard()\nwin32clipboard.SetClipboardData(win32clipboard.CF_UNICODETEXT, unicode(eg.globals.temp_var))\nwin32clipboard.CloseClipboard()\neg.plugins.Window.SendKeys(u'{ctrl+a}{ctrl+v}{enter}', False, 2)")
            </Action>
        </Macro>
    </Folder>
</EventGhost>
For reference this is how I was previously doing it in AutoHotKey:

Code: Select all

#Persistent
menu, tray, Icon, mushroom.ico
F8::send {shift down}{end}{left 4}{shift up} - %EpiName%{enter}
F7::send {del}- S{right 2}{del}E{right 2}
F6::send - S0{right}E{right 2}
F5::
send {f2}{ctrl down}c{ctrl up}
StringReplace, clipboard, clipboard, ., %A_SPACE%, All
StringUpper clipboard, clipboard, T
send {ctrl down}v{ctrl up}{home}{ctrl down}{right}{ctrl up}
return
;<^<#c::
F9::
send {ctrl down}c{ctrl up}
			;This section recursively checks for leading spaces
SpaceCheck:
StringGetPos, pos, clipboard, %A_SPACE%
if pos = 0
	{
	StringReplace, clipboard, clipboard, %A_SPACE%
	Goto, SpaceCheck
	}
			;Space check end
StringReplace, clipboard, clipboard, /, -, All
EpiName := clipboard
return
F3::
send {appskey}c
sleep 500
send {ctrl down}ac{ctrl up}
StringReplace, clipboard, clipboard, ., %A_SPACE%, All
send {ctrl down}v{ctrl up}{home}{ctrl down}{shift down}{right 3}{ctrl up}{right}{shift up}F:\{ctrl down}{right}{ctrl up}
return
F4::send {left}\{shift down}{end}{shift up}Season \{left}
F10::
send {ctrl down}ac{ctrl up}{enter}
ShowDir := clipboard
run, explore %ShowDir%
P.S. While we're talking about emulate keystrokes inline key down/up and key multipliers al a AHK would be pretty awesome.
Post Reply