Add key frame every five frames? Autohotkey? - windows

I am trying to make an AutoHotKey script to smoothen up my After Effects workflow. The deal is i have to make a keyframe, then go 5 keyframes ahead, this ultimately takes me 9 keypresses to do! So I tried to cut this down to just 3.
This is my code:
^+1::
Send, ^ & ! & + & {F1}
Send, ^ & {Right}
Send, ^ & {Right}
Send, ^ & {Right}
Send, ^ & {Right}
Send, ^ & {Right}
return
I want it to press
ctrl+shift+alt+F1 then ctrl+right_arrow 5 times.
What am i missing?
SOLUTION:
So I also asked this question on Reddit, where a user told me that the "Send," command is very literal, so it ended up typing " ^ & {Right}" and " ^ & ! & + & {F1}" in letters, furthermore it was unnecessary to type a & and the spaces between the others, which I also found out using a keyboard tester. So the solution was to type:
^+1::
Send ^!+{F1}
Send ^{Right}
Send ^{Right}
Send ^{Right}
Send ^{Right}
Send ^{Right}
return

For commands do not use the comma after send (this is for text only)

SendInput {ctrl DOWN}{Left 5}{CTRL UP}
This is one method. Rinse and repeat for the other keys, like shift.
Another method is an exclamation point for alt, a cap for ctrl, and a plus for shift.
SendInput ^!+{left 5}
According to the post below, I guess adding a comma converts to send raw? But I'm not sure if that's true. I'll test it out later.
You could also make a function, like a loop or whatever. That might be fun. Pass the keys and the number of times to push them as parameters. Coding challenge!

Related

How to encapsule the following AutoHotKey statements into functions?

I'm using Barrier to control a Windows machine from macOS, and I would like to remap Windows key to Command key to perform more efficient shortcuts.
Traditionally, simple one line statements (e.g. #c::Send ^c) will work, but have one shortcomming: if you hold pressing Command key then press "c" repeatly, you won't get repeating copy actions as expected, you will get one copy action and multiple typing of "c"s, which is annoying and not as natural as genuine "Command+C".
In order to have real "Command+C" & "Command+V" experience (& many other shortcuts perfectly remapped), I figured out a more complex (but working) apporach:
LWin & c::
StateWindowsPressC := true
Send {Ctrl Down}c
#If (StateWindowsPressC)
~*LWin Up::
Send {Ctrl Up}
StateWindowsPressC := false
return
#If
LWin & v::
StateWindowsPressV := true
Send {Ctrl Down}v
#If (StateWindowsPressV)
~*LWin Up::
Send {Ctrl Up}
StateWindowsPressV := false
return
#If
Please note that variables like StateWindowsPressC and StateWindowsPressV should not be the same name or they will cause chaos.
These statements work, but have too many duplicate statements, is there any way to encapsule them into functions?

AppleScript Custom Handler Syntax

I am starting to learn AppleScript. I am running into a couple issues that I could not find document for.
script gt
to sms to someone about m
"sms to " & someone & " about " & m
end
to move pix to pos
"moving " & pix & " to " & pos
end
to resize in pix to size
"resize " & pix & " to " & size
end
end
for the to sms handler, I have to add the "to" after the sms.
but I did not see any document mention the to as part of the
directParamName
for the to move handler, it does not seem like
the directParameter need either of, in or even "to"
for the to
resize handler, I have to add either "in" or "of", or it won't work.
if I add "to", it will complain "to" is used twice.
my question is why the "to sms" handler can have the "to", "to resize" handler must have either "in or of" while the "to move" handler needs none of these?
Thanks!
Here is the document I read a couple times but could not find any reference to any of this
Basically labeled parameters must contain a preposition and an argument.
Direct parameters are indicated by keyword of or in. In this case at least one parameter must follow. The documentation says
directParamName
An identifier for the direct parameter variable. If it is included,
directParamName must be listed immediately after the command name. The
word of or in before directParamName is required in user-defined
handlers, but is optional in terminology-defined handlers (for
example, those defined by applications).
If a user-defined handler includes a direct parameter, the handler
must also include at least one variable parameter.
Regarding your notes:
The preposition to as a labeled parameter is not documented but seems to work.
move is a reserved word of the Standard Suite and expects itself particular parameters. Do not use move as a handler name.
follows the rule about direct parameter. size could be also a reserved word depending on the installed Scripting Additions.
Actually Script Editor shows by syntax coloring the kind of a word. Green words can be safely used as variable names.

How can I write batch output to my text cursor?

In Windows 7, ultimately I want to bind a shortcut key (Ctrl+Alt+D) to spitting out a date-time stamp of the form 20120913 1232.
The step I'm getting hung up on is having a batch file write anything to my text cursor. Currently I'm piping it to clip.exe, then I paste, but I'd like to eliminate the middle step of the clipboard. If this isn't possible, is there another way around my problem?
echo %date:~-4%%date:~4,2%%date:~7,2% %time:~0,2%%time:~3,2% | clip
You can't do it from cmd. You need to use VBS, Js or PowerShell. Here's a simple VBS script that does what you want. Just create a shortcut on the desktop that runs this VBS file and assign a shortcut key to it
Set WshShell = WScript.CreateObject("WScript.Shell")
' Switch back to the previous window. Use Alt+Esc because Alt+Tab sometimes doesn't work
' WshShell.SendKeys "%{TAB}", True
WshShell.SendKeys "%{ESC}", True
' Get the time string
Dim dt, datetime_str
dt = now
datetime_str = Year(dt) & Right("0" & Month(dt), 2) & Right("0" & Day(dt), 2)
datetime_str = datetime_str & " " & Right("0" & Hour(dt), 2) & Right("0" & Minute(dt), 2)
' Send the date string to the target window
WshShell.SendKeys datetime_str
However Autohotkey (AHK) would be a much better solution and works much faster. Here are 2 example functions that will type the datetime string to the current app
; Map Ctrl+Alt+T to send the date string
^!t::
FormatTime, currentdate,, yyyyMMdd HHmm
SendInput %currentdate%
Return
; Map Ctrl+Alt+D to send the date string
^!D::
SendInput %A_YYYY%%A_MM%%A_DD% %A_Hour%%A_Min%
Return
Save the above script as *.ahk and run it. AHK will run in the background and listen to the key sequence to do the desired action
For OP/anyone interested: http://ahkscript.org
Auto Hotkey might be what you were after. Either a vanilla complementary cmd .bat or a standalone AHK script should be able to pull data from STDOUT and SET your date syntax up, AND set the hotkey all from 1 script.
The "hotkey" section of this question might be why it hasn't been answered before, not something that can be done in Windows CLI afaik, you need "Shortcut key remapping software" which is exactly what Auto Hotkey is designed for :)
It has been a long time since I researched Shortcut key remapping in Windows, but I do remember AHK being only a handful of programs able to remap hard-coded shortcut combinations like WinKey + R, unless you code one yourself (in C++ or similar)
I also recommend a thorough dig into Rob van der Woude's site, specifically the 2 articles about redirection:
http://www.robvanderwoude.com/battech_redirection.php
and down the bottom is a link to the "Redirection overview page" which is a particularly good "cheat sheet" for redirection commands/syntax.

RS232c VB6 help

Hey all, i am trying to turn on a A/V Reciever with a RS232 command using the VB6 comm32. To turn it on it says to use:
Command code Parameter code CR Code set example
PW ON <CR> PWON<CR>
And this is my VB6 code i am currently using that doesnt seem to work...
MSComm.CommPort = 2
MSComm.Settings = "9600,n,8,1"
MSComm.PortOpen = True
If Not MSComm.PortOpen Then
MsgBox "not opened"
Else
MSComm.Output = "PWON" & Chr(13)
Do While MSComm.InBufferCount > 0
Text1.Text = Text1.Text & MSComm.Input
Loop
End If
The reciever never turns on. What could i be doing incorrectly? I checked to make sure the com port was 2 and it is.
David
You are just sending the characters <CR> rather than a real carriage return (ASCII code 13). Documentation for serial peripherals often puts the names of control characters in brackets (see Wikipedia for a list of them). You need the line:
MSComm.Output = "PWON" & Chr(13)
It also seems that the code that follows to read data from the serial port should be changed because if the data has not arrived in the serial port's buffer yet, it will read nothing. Take a look at Microsoft's example for how to do so. You could decide to stop reading once a particular substring in the input has been found, once a certain number of bytes have been read (Len function), etc.

How do I use WScript.Shell SendKeys to send Number Pad key strokes?

I am trying to use WScript.Shell SendKeys method to emulate sending a key press from the Number Pad.
I have an application that I am writing automated testing for using QTP. It is a Web Browser based application and the input is into a Java App within the web page. The input only accepts key presses from the Number Pad and the Enter key.
So far I am using this code:
Dim strInputKey
strInputKey = "{ENTER}"
Set objWsh = CreateObject("WScript.Shell")
Browser("Launch Browser").Page("Test Application").WebElement("Item ID").Click
objWsh.SendKeys strInputKey
This works fine for sending the Enter key, but I can't quite figure out if there is a way to send Number Keys. Any help would be greatly appreciated.
I am not sure if there are any undocumented ways of achieving this. I have read http://msdn.microsoft.com/en-us/library/8c6yea83(VS.85).aspx but it doesn't go into great detail.
I don't have the rep to comment on the above answer that said
objWsh.SendKeys chr(79) & chr(80) & chr(81)
but I don't think it's correct
objWsh.SendKeys chr(79) & chr(80) & chr(81)
For a start, it sends the letters O,P,Q
And he wants numbers, like 1234567890
and the link goes to keyboard scan codes.. I think those are for knowing what key on the keyboard was pressed. They are different from ascii codes.
79,80,81 are the keyboard scan codes for some numbers on the number pad / numpad.
Chr though, uses ascii codes. not keyboard scan codes.
Furthermore, just specifying a digit, here, since it isn't done by pressing a key, it doesn't specify and needn't specify, which was key was used, since a key wasn't used.
To sendkeys some numbers (from the number pad), is just same as sending keys from the top row. You just want to send some numbers.
If all he wants to know is how to use sendkeys to send digits, then obviously.
objWsh.SendKeys 12345
or
str="12345"
objWsh.SendKeys str
But if the questioner didn't realise that objWsh.SendKeys 12345 would do it, then perhaps the questioner is just confused. I guess from the green tick, he voted an answer that is like objWsh.SendKeys "OPQ".
I am aware that this is an old question, but for the sake of haing correct questions and answers..
You'll need to use the keycodes for the number pad.
Here's a list of them:
http://www.empirisoft.com/directrt/help/_helpcontents.htm?directrt_key_codes.htm
So to send "123", you would need to do:
objWsh.SendKeys chr(79) & chr(80) & chr(81)

Resources