how to create a script with curley brackets using autokey - autohotkey

I want to create a script that'll type {{'
and I can't get it to write my {{
Here's my code:
^1::
#NoEnv ; Recommended for performance and compatibility with future
AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and
reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Send ,{{'

If you're looking to only send the text, then try using Text mode like so:
SendInput {text}{{'

Related

Visual Studio Code extension - mouse middle click go to definition

I'm searching for an extension for VS Code something like this:
https://marketplace.visualstudio.com/items?itemName=norachuga.MiddleClickDefinition
It's natively supported in WebStorm, and I want to switch to VSC and it's really annoying.
I didn't find any results on google.
Is any good tutorial or code snipped on how to create one?
Author Credit: https://github.com/danielsamuels
For those of you who are looking for a short term fix for this, I've created an AutoHotkey script which provides middle-click Go To Definition behaviour:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#IfWinActive ahk_exe Code.exe
~MButton::
MouseGetPos, xpos, ypos
if (ypos >= 87) {
SendInput,{Click}{F12}
}
return
Copy the above contents into a file named vscode-f12-go-to-definition.ahk and run it. You'll see a green H icon in your systray which shows it's running.

Noticeable lag in hotkey, how can i reduce the delay?

I am trying to change the hotkey Win + E to Win + Space and i used the code below
Code:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey
releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and
reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#space:: Run explorer.exe shell:MyComputerFolder
which worked fine but i noticed a lag. when i use Win + E its opens instantly but when i use Win + Space there is a 1 sec delay.
Is there anyway to get rid of this delay?
Found a solution on AutoHotKey forums. If anyone is interested here it is
Answered by username: TheDewd
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey
releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and
reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#space::#e ;this line solves the delay. Makes it Just like using Win + E
#e:: ;if you want to remap Win + E
MsgBox, Test
return
Reference, just incase but all the answer is in the code above.

How to make autohotkey work in "OneNote for Windows 10" app (not OneNote)?

I am trying to add a program specific shortcut, i.e. a shortcut to be used inside OneNote App only, and not the short cut for the opening of app itself.
Here is how the present script is:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#IfWinActive, ahk_exe OneNote.exe
+Enter::
Send, {(}!+d{)}
return
But the above one works in OneNote desktop and not for the "OneNote for Windows 10" app (OW10A); how do I make it work for that store app? I am not able to find .exe for the store app to mention it in the above script.
You can use the #If- or the #IfWinActive- directive to create context-sensitive hotkeys and hotstrings:
#If WinActive("WinTitle ahk_class WinClass", "WinText", "ExcludeTitle", "ExcludeWinText")
#IfWinActive, WinTitle ahk_class WinClass, WinText, ExcludeTitle, ExcludeWinText
https://autohotkey.com/docs/commands/_If.htm
Use Window Spy to get detailled information about the program windows.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetTitleMatchMode, 2 ; Title can be part of the full title
#If WinActive("- OneNote ahk_class ApplicationFrameWindow", "OneNote")
+Enter:: Send, {(}!+d{)}
; Here you can add more program specific shortcuts:
; ...
; Here you can add specific shortcuts for another program:
#If WinActive("‎- Microsoft Edge ahk_class ApplicationFrameWindow", "Microsoft Edge")
+Enter:: MsgBox, You pressed Shift+Enter in Microsoft Edge
#If ; turn off context sensitivity

Fix Labview Alt-Tab behaviour with Autohotkey

Did anyone try to fix the way Labview interferes with normal Alt-Tab behaviour using Autohotkey?
Alt-Tab inside Labview puts all non-labview windows to the end of the list.
So if you have just alt-tabbed to labview window from your browser it takes
(2 × number_of_currently_open_labview_projects -1)
keystrokes to get back.
Great idea. I find that functionality annoying and there doesn't appear to be an easy fix anywhere on the web. Here's my script. Two quick notes:
I had a lot of trouble re-mapping Alt-Tab. If that's critical you can try starting here for help.
To my knowledge it's not possible to get rid of the "screen flicker" because Windows requires some delay between keystrokes.
Note: to adapt this code for various Windows - look up the "ahk_class" using the Window Spy tool included in the AutoHotkey installer .
Code
#NoEnv ; Recommended for performance and compatibility with future
AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#NoTrayIcon
#SingleInstance force
SetTitleMatchMode 2 ;partial search mode
#IfWinActive vi
#q:: ;there were issues mapping to Alt+Tab
CountOfVIs := -1
WinGet, id, list,ahk_class LVDChild,, Program Manager
Loop, %id%
{
CountOfVIs := CountOfVIs +1
}
msgbox, # of VIs open: %CountOfVIs% ;when I remove this it doesn't work - must be an AHK thing
Send {Alt down}
Loop,%CountOfVIs%
{
Send {tab}
Sleep,50 ;if this is too low it doesn't work
}
Send {Alt up}
I've recently found an article related to this problem, but unfortunately it is in Russian.
It references the following blog with a python script (+autohotkey mapping) that seems to be solving the problem without the "screen flicker".

Hotkey causing variable to be unassigned?

I know I'm missing something obvious but I can't figure out why this doesn't work. Why doesn't hello show up in the first msgbox I know it says the variable isn't assigned if I uncomment #Warn? This is the only thing in the ahk file.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
; Reload the script
^!z::
WinActivate, ahk_class Notepad++
Send {ctrl down}s{ctrl up}
sleep 100
Reload
return
ADPass = hello
!5::
MsgBox, %ADPass%
Msgbox, test
return
Your assignment of ADPass never gets executed because it is between 2 hotkeys. You must place it before you begin your hotkeys (before ^!z) or place it within your hotkey (!5) to ensure it is executed.
I think the other answer would probably work, you need the variable to be set before the return. The return means the machine is never getting to that line of code, Try this.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
ADPass = hello; this doesn't have to stay here, just make sure it's before the return.
; Reload the script
^!z::
WinActivate, ahk_class Notepad++
Send {ctrl down}s{ctrl up}
sleep 100
Reload
return
!5::
MsgBox, %ADPass%
Msgbox, test
return
or
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
; Reload the script
^!z::
WinActivate, ahk_class Notepad++
Send {ctrl down}s{ctrl up}
sleep 100
Reload
return
!5::
goto set
point:
MsgBox, %ADPass%
Msgbox, test
return
set:
ADPass = hello
goto point
Return