autohotkey


Get AutoHotKey to do keyboard shortcut when mouse in certain position


I'm a complete newbie idiot trying to write an AutoHotKey script that does a keyboard shortcut (in this case, windows button + t) when my mouse is in a certain position on screen (in this case, below 1070 pixels). This is what I have wrote put I don't think it actually does anything.
CoordMode, Mouse, Screen
Check:
MouseGetPos, yy
if (yy < 1070) {
Send {LWin down}t{LWin up}
Return
}
The syntax is probably way off from what AutoHotKey is actually supposed to look like but after reading some forum posts I still can't tell what I did wrong. Thanks!
This code does literally what you asked for
Loop {
MouseGetPos, x, y
if (y < 1070){
Send {LWin down}t{LWin up}
}
Sleep 10 ; Avoid excessive CPU usage
}
However, whilst y is < 1070, it would constantly send the key combo.
I guess you only want it to send the key combo when the mouse first "enters" the zone.
last_pos := 999999 ; Set initial value really high
Loop {
MouseGetPos, x, y
if (y < 1070 && last_pos >= 1070){
Send {LWin down}t{LWin up}
}
last_pos := y
Sleep 10 ; Avoid excessive CPU usage
}
#t:: ;This will assign the window + t key to do something
{
Click 701,480 ;This clicks to a certain position on the screen. Autoit software can find the coordinates on the screen for you.
Send Hello ;This will write something in an area like if its on a webpage or something.
Send {Return}
{Space}
{ESC}
{up} ;The {} Hold different keystrokes to use- https://autohotkey.com/docs/commands/Send.htm
Sleep 300 ;This allows you to pause the program, you may need something to finish loading in.
}
This is just some background information for you to use for future, using what Clive Galway has said should work for you, if the position you want to do something is set use the Click ....,.... however if it may be at different points use the above answer.

Related Links

AHK: Script Help Num Lock acting up
AutoHotKey: How to find out if a certain window has or hasn't been interacted with
Win + mouse wheel keeps showing/hiding start menu
Generate timed-text synchronised with Text-to-Speech word-by-word?
AHK: closing a window whenever it pops up
AutoHotKey How to save file as XPS without dialog box
Autohotkey script doesn't work only in Skype
Gui clipboard not working
Restart script as admin, avoiding the error message
How to capture Logitech trackman special buttons using Autohotkey?
AHK: Automation of dialog boxes
How to send enter key when ever dialogue box is appears
How to set Autohotkey Gui control type slider as float?
Replace key by dot (“.”) with Shift Autohotkey
Why my script is not functioning like it had before?
AutoHotKey How can I connect dropdown list to my edit boxes here

Categories

HOME
reactjs
stanford-nlp
cors
postgresql-9.3
ldap
display
xamarin.forms
intellisense
phantomjs
ubuntu-14.04
sms
browser-cache
swap
comments
country-codes
zabbix
jquery-select2
browserstack
ephesoft
sahi
coding-style
normals
minimax
fetch
dynamics-crm-2011
vichuploaderbundle
jinja2
google-closure-compiler
nsoperation
bookmarklet
amazon-data-pipeline
md2
loader
custom-component
minimagick
dev-c++
hololens
tcpdf
screen-scraping
boosting
edirectory
apm
drawrect
key-bindings
ios-autolayout
incapsula
intersection
ansible-inventory
pymunk
lex
ape-phylo
qt-quick
python-venv
automapper-4
easyquery
remap
dcom
dna-sequence
jenkins-docker
fckeditor
androiddesignsupport
programming-pearls
opticalflow
dynatable
addressbook
copy-constructor
ownership
computed-properties
git-push
vga
hfp
shtml
razorengine
salesforce-service-cloud
datamodel
libgcrypt
play-json
jts
edgar
borland-c++
nmock
stereotype
vectordrawable
nfa
accpac
firebase-tools
ccmenuitem
msdropdown
triplestore
visual-c#-express-2010
acrofields
nvcc
complete
thucydides
sygic
octokit
dancer
datasheet
project-files
jqzoom
httppostedfilebase
overlays
gmagick
response-time
nyromodal
carbon-emacs
web-widget
pkcs#7
morfik
user-preferences
wtsapi32
bootstrap-protocol
cross-cutting-concerns
ironpython-studio

Resources

Encrypt Message