Old 10-12-2016, 09:06 AM   #1
Stroudy
Human being with feelings
 
Stroudy's Avatar
 
Join Date: Jul 2014
Location: London
Posts: 455
Default Can scripts send key commands to the system?

I'm interested to know if a script can 'send' a key command.

It's probably irrelevant why I want it but here it is:

When windows open that are run from a script (e.g. gofer_spk77_Smooth_CCs.eel) they open in the top left. On a 4K screen, that can be a long way to move a mouse. I can use a 3rd party app to reposition any window. Ideally a single toolbar button could open the script and send a keycommand which another app could 'pick up' – probably using a macro.

Cheers
Stroudy is offline   Reply With Quote
Old 10-12-2016, 09:51 PM   #2
NextLevel
Human being with feelings
 
Join Date: Dec 2014
Posts: 411
Default

Using lua you can do something like this;

So if for example your third party app happened to be AutoHotkey you could write an ahk script to reposition the windows and then execute it from within a lua script using something similar to the line below.
Pay attention to the use of the single quotes and double quotes surrounding the path or it might not execute.

os.execute('"C:/folder/your_file_to be_executed.ahk"')
NextLevel is offline   Reply With Quote
Old 10-13-2016, 02:26 AM   #3
Stroudy
Human being with feelings
 
Stroudy's Avatar
 
Join Date: Jul 2014
Location: London
Posts: 455
Default

Ah. Very interesting.

I'm on a mac so I think I could trigger something like this in automator.

Thank you
Stroudy is offline   Reply With Quote
Old 10-13-2016, 05:56 AM   #4
Sju
Human being with feelings
 
Join Date: Jun 2015
Posts: 686
Default

You can edit the script to resize/position the window where you want it

gfx_init("name",width,height,dockstate,xpos,ypos);

or you can make it execute the action which repositions the window relative to your cursor position (SWS/BR: Move active floating window to mouse cursor).

Last edited by Sju; 10-13-2016 at 06:03 AM.
Sju is offline   Reply With Quote
Old 10-13-2016, 06:00 PM   #5
Stroudy
Human being with feelings
 
Stroudy's Avatar
 
Join Date: Jul 2014
Location: London
Posts: 455
Default

That's brilliant Sju.

Almost perfect. "SWS/BR: Move active floating window to mouse cursor" doesn't seem to work with the scripts I'm running.

However... the "gfx_init("name",width,height,dockstate,xpos,ypos) ;" works very well.

Would you know how I can retrieve the current mouse position and feed that into the last 2 values, xpos and ypos?
Stroudy is offline   Reply With Quote
Old 10-14-2016, 02:49 AM   #6
Sju
Human being with feelings
 
Join Date: Jun 2015
Posts: 686
Default

I think the script can only get the position inside it's own graphics window. About the BR action, try creating a custom action which runs your script first and then executes the "move to mouse cursor".
Sju is offline   Reply With Quote
Old 10-14-2016, 10:17 AM   #7
Stroudy
Human being with feelings
 
Stroudy's Avatar
 
Join Date: Jul 2014
Location: London
Posts: 455
Default

You think I would have tried that! That works great. Thank you!
Stroudy is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:13 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.