2

I am trying to obtain the Seamless windows effect with TightVNC Viewer.
Basically I set the client visible area to an application with

"C:\Program Files\TightVNC\tvnserver.exe"  -controlapp  -shareapp <app PID>

then I use the following AutoHotkey script to hack TightVNC Viewer window (where I hide the toolbar):

^!h::
IfWinExist, antonio - TightVNC Viewer
{
   WinSet, Style, ^0xC00000  ; title bar, without you can move only with win-key 
   WinSet, Style, ^0x800000  ; thin-line border
   WinSet, Style, ^0x400000  ; dialog frame
   WinSet, Style, ^0x40000   ; sizing border, without you cannot resize
   WinSet, Style, ^0x200000  ; vertical scroll bar
   WinSet, Style, ^0x100000  ; horizont scroll bar
}
return
; http://www.autohotkey.com/docs/misc/Styles.htm

The script toogles the border and other window elements.
I am still working with the styles, but the main problem is that scrollbars don't go away.

How can I get rid of them?

Side note

An interesting side effect of sharing windows in VNC locally, that is with the loopback connection, is that you can obtain kinda of X Server in Windows, appealing for multi-monitors systems.

antonio
  • 10,629
  • 13
  • 68
  • 136
  • Scrollbars aren't enabled/disabled by `WS_HSCROLL` and `WS_VSCROLL` window styles - the styles merely serve to indicate whether the scroll bars are visible or not. A program controls its scrollbars with the `SetScrollInfo` and similar functions. – Jonathan Potter Aug 11 '14 at 12:12
  • @JonathanPotter: Thanks, but this just what I would like to do: to make them invisible. In Autohotkey `^` toggles the attributes and it actually adds/removes a _second pair_ of scrollbars. This happens also with a Notepad window. With Notepad, just now, I succeeded: using the Autohotkey Windows Spy, I saw that the bars are not related to the main Window, but to an internal `Edit1` control so I set the `0x200000` style for it. With TightVNC still it does not work. The Spy says the window to hack is TvnWindowClass1, which perhaps does not support the `0x200000` style. – antonio Aug 11 '14 at 15:52

1 Answers1

2

I found a "semi-general" solution for scrollbars. They are not a property of the window, but of some edit child control. Getting the control name via Window Spy, you can remove the bars from some app, with:

Control, Style, -0x100000, <control name>, <app window name>
Control, Style, -0x200000, <control name>, <app window name>

For example it works for for Notepad, where <control name> is Edit1.

Unfortunately TightVNC uses a non standard Window class, TvnWindowClass1, and I am unable to affect its scrollbars.

Anyway, replacing the server option -shareapp <app PID> with -sharewindow <app window name>, there are no-scrollbars.

The following is a local working sample assuming you want to share calc.exe, whose window name is Calculator.

Press Ctrl+Alt+h once and you will locally start a client-server VNC sharing the Calculator window. Press again and you get the seamless effect. Press again and you get back to standard view (and you can move, size again).

If toggling window style with Ctrl+Alt+h, TightVNC toolbar doesn't toggle too, set it on or off manually in normal view from the window control menu or with Shift+Ctrl+Alt+t.

If you want to use the script in two distinct systems, you have to split it in two parts where server commands are run on the server side and client ones on the client system.

Note that, for a more general use, regexp are used in naming the target application window.

Note The script is useful as is to duplicate a window. Window mirroring is something trivial in Linux X Window (for the server nature of the display), which instead require tools paid money in Windows. Mirroring turns useful when you have a multi-monitor system or a projector and you want to duplicate, not the whole desktop, but only some particular windows on the second monitor (projector).

^!h::
SetTitleMatchMode RegEx
IfWinExist, TightVNC Viewer$
{

   WinGet, Style, Style
   if(Style & 0x800000) {

    WinGetPos, X, Y
    Sleep,  6000    
    WinSet, Style, -0xC00000  ; title bar, without you can move only with win-key 
    WinSet, Style, -0x800000  ; thin-line border                                  
    WinSet, Style, -0x400000  ; dialog frame                                      
    WinSet, Style, -0x40000   ; sizing border, without you can't resize
    Send !+^t ; no toolbar 

    WinMinimize
    Sleep,  500 
    WinRestore  
    WinMove, X, Y 

   } else {

     WinSet, Style, +0xC00000  ; title bar, without you can move only with win-key 
     WinSet, Style, +0x800000  ; thin-line border                                  
     WinSet, Style, +0x400000  ; dialog frame                                      
     WinSet, Style, +0x40000   ; sizing border, without you can't resize
     Send !+^t ; no toolbar
   }

}


IfWinNotExist, TightVNC Viewer$
{
  Run, calc
  Run, "C:\Program Files\TightVNC\tvnserver.exe"  -run
  Sleep,  1000
  Run, "C:\Program Files\TightVNC\tvnserver.exe"  -controlapp -sharewindow Calculator
  Run, "C:\Program Files\TightVNC\tvnviewer"  127.0.0.1
}
return
antonio
  • 10,629
  • 13
  • 68
  • 136