help in creating script

Get help with using AutoHotkey and its commands and hotkeys
jacus1000
Posts: 5
Joined: 16 Aug 2018, 10:03

help in creating script

16 Aug 2018, 10:14

Hi

I've been searching for help in my case for quite a long time now and can't really find what I'm trying to do.

I'm operating in one app and need to do something in other on different screen by clicking a specific mouse button.
I need a script that would do as follow:
1. take the cursor to another screen, different app (chrome window)
2. click the text window, type "a", then press "enter"
3. go back to the cursor's original location

I've been struggling with numerous issues like:
- the other window couldn't be activated
- cursor is ending up in totally weird position instead of getting back
- clicking on the desktop and launching first a-named file that is there

EDIT: ControlClick works for me but not in case of switching between programs I operate with.
jacus1000
Posts: 5
Joined: 16 Aug 2018, 10:03

Re: help in creating script

16 Aug 2018, 14:31

I'm trying different commands but the mouse just wont get focus from the program I use to other locations.
jacus1000
Posts: 5
Joined: 16 Aug 2018, 10:03

Re: help in creating script

17 Aug 2018, 11:43

Nobody knows what should I do or am I just making some kind of faux pas here. Sorry, my first thread there and Im a total noob in case of AHK.
swagfag
Posts: 1374
Joined: 11 Jan 2017, 17:59

Re: help in creating script

17 Aug 2018, 12:06

Code: Select all

#NoEnv
#SingleInstance Force
SendMode Input
SetBatchLines -1
SetTitleMatchMode 2
CoordMode Mouse, Screen

X_TARGET := 100
Y_TARGET := 100

q::
	MouseGetPos xStart, yStart
	Click %X_TARGET%, %Y_TARGET%
	Send a{Enter}
	MouseMove % xStart, % yStart
return

Esc::ExitApp
start by understanding what each of the commands does. u might need to use some Sleep here and there. Coordinates can be negative depending on where the other screen is located
jacus1000
Posts: 5
Joined: 16 Aug 2018, 10:03

Re: help in creating script

17 Aug 2018, 16:33

thank you, I'll look into it and let you know if it works
jacus1000
Posts: 5
Joined: 16 Aug 2018, 10:03

Re: help in creating script

19 Aug 2018, 11:13

Unfortunately it still wont take focus from the app I use. Works when I try on other apps though but not with the one I need.
User avatar
BriHecato
Posts: 123
Joined: 18 Jul 2017, 07:17

Re: help in creating script

19 Aug 2018, 15:32

Probably you will not be able to send to text box in chrome without activating it.
You can controlclick and controlsend in inactive windows and apps (but not minimized) if you have named controls (textbox or button) - if it is on the webpage it wouldn't work since whole chrome window is a single control. Maybe in IExplorer you could do that using COM.
Solution is that you use global coordinates - save you current mouse position - move mouse to chrome window to textbox, click once (or twice) to get blinking cursor in that textbox - send your keystrokes - then return to original mouse position and reactivate window/app you've been at the beggining. It can be done in a blink of an eye.

Return to “Ask For Help”

Who is online

Users browsing this forum: Google [Bot] and 55 guests