bug.n icon indicating copy to clipboard operation
bug.n copied to clipboard

Differentiate # (Windows) button key to act on specific screen only

Open nanangarsyad opened this issue 8 years ago • 5 comments

I wanted to implemented the feature that can differentiate which windows button I pressed. For example, I wanted to know whether left-windows or right-windows being pressed. My point is, I'm trying to create a feature where if I pressed left side modifier button (alt, shift, ctrl, win) it'll only applied on specific monitor (not virtual monitor, but multi-monitor). e.g. I have 2 physical monitor, in which case the feature I proposed will work like this: left-win + t -> will changing the layout type to 'tile layout' for my main (1st) screen left-win + 3 -> will show 3rd virtual desktop on main (1st) screen

right-win + -> will changing the layout type to 'tile layout' for my second screen right-win + 3 -> will show 3rd virtual desktop on second screen

I'm a newbie on autohotkey, but more ore less I have some skill on java and python, and just started with c++ and windows programming. please give me some pointer, where should I start first, so I could implement this feature. Thank you, and if my wording not clear enough please let me know :)

nanangarsyad avatar Aug 02 '17 05:08 nanangarsyad

You may use LWin and RWin instead of # to configure hotkeys (see the topic Hotkeys in the AutoHotkey documentation). For your first example you will need an altered View_setLayout function; a possible hack of Config.ahk for the first part would be as follows:

LWin & t::
  If Not (1 = View_#1_#%Monitor_#1_aView_#1%_layout_#1) {
    View_#1_#%Monitor_#1_aView_#1%_layout_#2 := View_#1_#%Monitor_#1_aView_#1%_layout_#1
    View_#1_#%Monitor_#1_aView_#1%_layout_#1 := 1
  }
  View_arrange(1, Monitor_#1_aView_#1, True)
Return

I already shortened the code, but the point is to change Manager_aMonitor to 1 (LWin) and 2 (RWin) -- but do not set the variable Manager_aMonitor itself. As an alternative you may change the active monitor and apply the function afterwards with no need to alter the function itself; the following should work (I did not test it):

LWin & t::
  Manager_activateMonitor(1)
  View_setLayout(1)
Return

For your second example you would need an altered Monitor_activateView function with aMonitor set to the respective values, or the following:

LWin & 3::
  Manager_activateMonitor(1)
  Monitor_activateView(3)
Return

joten avatar Dec 26 '17 22:12 joten

Have you guys thought about following the pattern of e.g. i3-wm, to assign unique view ids across multiple monitors, with each monitor starts with 4 views instead of 10.

Monitor1: view 1, 2, 3, 4
Monitor2: view 5, 6, 7, 8
Monitor3: ...

This way the user doesn't need to mess with manually mapping views to monitors and the config file continues to work across multiple monitors, e.g., Win+5 will always bring me to second screen's first view. I think this is the most useful function of a window manager - be able to quickly switching between not only windows but also monitors without me dragging the mouse, as most 'advanced' users today have a) 2-3 monitors; and b) a fixed mind-mapping between the window he/she is interacting with to the location (monitor/view).

techbos avatar Jan 21 '18 18:01 techbos

Untested indeed. I'm not able to figure out the magic syntax to chain functions in an INI config which I believe doesn't support multiple lines. Only the first function gets called. (I use "j" instead of "Down" for vim-like navigation):

Config_hotkey=RWin & j::Manager_activateMonitor(2), View_activateWindow(0, +1)

bug.n is a nice product though, I'm finally surviving my switch from Linux (awesomewm) to Windows in the workplace with tools like this.

akadaedalus avatar May 25 '18 15:05 akadaedalus

You are right, this does not work in Config.ini. The hack was intended for Config.ahk, which is part of the source. You will have to put it there towards the end of the file as follows:

RWin & j::
  Manager_activateMonitor(2)
  View_activateWindow(0, +1)
Return

Than run bug.n not by starting the executable, but by starting the script Main.ahk with AutoHotkey.

joten avatar May 30 '18 13:05 joten

Confirmed to work with Config.ahk and AutoHotkey binary.

akadaedalus avatar Jun 07 '18 18:06 akadaedalus