DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Scrolling windows other than the active one  (Read 8,260 times)

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Scrolling windows other than the active one
« on: February 23, 2006, 10:44 AM »
When i got myself another monitor, the feature that i looked for the most was the ability to code in one monitor and see the "what to do" list on the other monitor.
But the problem was that i had to scroll the window with the "to do list" and for that, I'd have to use my mouse, or alt-tab into it.
So, i created a ahk script to do what the ctrl+meta+v key does in emacs: scroll the other window.
This script has the ability of storing 9 windows and scroll each of them, restoring the focus to the original window after it scrolls the others.
In early times, it used MW_VSCROLL message, but that message doesn't work with adobe acrobat, so, i changed it to the "send" keys, so now it activates the window, sends specified keys to scroll the window, and reactivates the last window.
I hope you like it:

Code
#SingleInstance, Force

;Pressing win+alt+numpad# stores the current window under #.
;For scrolling up the # window, press win+#
;For scrolling down the #window, press ctrl+win+#
KeyUp={Up} ;the Up arrow will be sent to scroll up
KeyDown={Down} ;the down arrow will be sent to scroll the window down.
;To use the page up and down to scroll the windows, replace 'up' and
;'down' by PgUp and PgDn
loop 9
{
  MMWindow%A_Index%=
  MMWinCtrl%A_Index%=
  Hotkey,!#Numpad%A_Index%, Save
  Hotkey,#NumPad%A_Index%, ScrollDown
  Hotkey,^#NumPad%A_Index%, ScrollUp
}
return

Save:
  StringRight, MMKeyID, A_ThisHotkey, 1
  MMWindow%MMKeyID% :=WinActive("a")
  MouseGetPos, , , , MMWinCtrl%MMKeyID%,
  Return
  
ScrollDown:
  LastWindow :=WinActive("a")
  StringRight, MMKeyID, A_ThisHotkey, 1
  MMWinID :=(MMWindow%MMKeyID%)
  MMWinCtrlID := (MMWinCtrl%MMKeyID%)
  WinActivate, ahk_id %MMWinID%
  loop
  {
    Send,{Down}
    GetKeyState, state, Numpad%MMKeyID%, P
    If state = u
      break
  }
  WinActivate, ahk_id %LastWindow%
  return

ScrollUp:
  LastWindow :=WinActive("a")
  StringRight, MMKeyID, A_ThisHotkey, 1
  MMWinID :=(MMWindow%MMKeyID%)
  MMWinCtrlID := (MMWinCtrl%MMKeyID%)
  WinActivate, ahk_id %MMWinID%
  loop
  {
    Send,%KeyUp%
    GetKeyState, state, Numpad%MMKeyID%, P
    If state = u
      break
  }
  WinActivate, ahk_id %LastWindow%
  return
« Last Edit: February 23, 2006, 11:36 AM by jgpaiva »

brotherS

  • Master of Good Ideas
  • Honorary Member
  • Joined in 2005
  • **
  • Posts: 2,261
Re: Scrolling Other windows other than the active one
« Reply #1 on: February 23, 2006, 10:52 AM »
Nice idea! Now all I need is a second monitor  ;D
Thank you.

Kniht

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 8
Re: Scrolling Other windows other than the active one
« Reply #2 on: February 23, 2006, 11:00 AM »
While you're at it, get me a second monitor too. This external video jack is just going to waste.

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: Scrolling Other windows other than the active one
« Reply #3 on: February 23, 2006, 11:25 AM »
Nice idea! Now all I need is a second monitor  ;D
You don't really need a second monitor, this works for every window, not necessarily for windows in a second monitor.
With a few tweaks, this can work like a "fast reference" script. You can press a key to activate the window and release it to return to the window you were using before. A quite useful feature ;)

Original address: https://www.donationcoder.com/forum/index.php?topic=2537.0