Author Topic: Non Clickable Compact mode as a one liner  (Read 3592 times)

JTKaay

  • Newbie
  • *
  • Posts: 3
Non Clickable Compact mode as a one liner
« on: September 09, 2021, 01:06:11 PM »
Hi, first of all, Voice Attack is the best thing since sliced bread.

However, I have one small (probably massive) issue, especially after using something like Nvidia Performance Overlay.

Is it at all possible to have an opaque(ish) non clickable overlay, even a one liner (similar to winamp). I know I can set the opacity on commandline.


More often than not, Ill find myself inadvertantly clicking out of game (luckily only Borderless Windowed), because my mouse moves over the compact mode window.

I did search the forum for a similar post, but the only post that came close has not been answered at all.


Thanks in advance,

CMDR JTKaay (SOLO)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Non Clickable Compact mode as a one liner
« Reply #1 on: September 09, 2021, 02:00:22 PM »
I use an inline function for this, though I haven't spent much time refining it:
Code: [Select]
using System;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;

public class VAInline
{
[DllImport("user32.dll", SetLastError = true)]
    static extern int GetWindowLong(IntPtr hWnd, int nIndex);
    [DllImport("user32.dll")]
    static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
    const int GWL_EXSTYLE = -20;
    const int WS_EX_LAYERED = 0x80000;
    const int WS_EX_TRANSPARENT = 0x20;
   
    const int WS_EX_TOPMOST = 0x8;
   
   

public void main()
{
int currentStyle = GetWindowLong(VA.MainWindowHandle, GWL_EXSTYLE);

bool alwaysOnTop = (currentStyle & WS_EX_TOPMOST) != 0;

if (VA.Command.Name().EndsWith("on"))
{
VA.SetOpacity(30);//Changing opacity first works
if (!alwaysOnTop)
{
enableAlwaysOnTop();
}
enableClickThrough(currentStyle);
}
else if (VA.Command.Name().EndsWith("off"))
{
if (alwaysOnTop)
{
//disableAlwaysOnTop();
VA.WriteToLog("Keeping Always On Top enabled", "pink");
}
disableClickThrough(currentStyle);
VA.SetOpacity(100);
}
else
{
if (Application.OpenForms["frmMain"].Opacity < 1.0)//Assume the overlay is off if the window is not transparent
{
if (alwaysOnTop)
{
//disableAlwaysOnTop();
VA.WriteToLog("Keeping Always On Top enabled", "pink");
}

disableClickThrough(currentStyle);
VA.SetOpacity(100);
}
else
{
VA.SetOpacity(30);//Always change opacity first
if (!alwaysOnTop)
{
enableAlwaysOnTop();
}
enableClickThrough(currentStyle);
}
}
}

void enableAlwaysOnTop()
{
VA.Command.Execute("voiceattack on top", true, true);
System.Threading.Thread.Sleep(1000);
}

void disableAlwaysOnTop()
{
VA.Command.Execute("voiceattack not on top", true, true);
System.Threading.Thread.Sleep(1000);
}

void enableClickThrough(int currentStyle)
{
SetWindowLong(VA.MainWindowHandle,GWL_EXSTYLE , currentStyle | WS_EX_LAYERED | WS_EX_TRANSPARENT);
}

void disableClickThrough(int currentStyle)
{
SetWindowLong(VA.MainWindowHandle,GWL_EXSTYLE , currentStyle & WS_EX_LAYERED & WS_EX_TRANSPARENT);
}
}

The command phrase, if using this example, would be something like "overlay mode [;on;off]" (the semicolon indicating an optional section must be placed before the actual phrases/words in the section, because the current version of VoiceAttack would pass the phrase "overlay mode on" if the command phrase were "overlay mode [on;off;]" when triggering the command using most non-spoken means, thus preventing the command from toggling correctly)

You'll note the inline function attempts to call a command to switch the "Always on Top" option; that command merely runs another instance of VoiceAttack with the relevant command line parameters to toggle that setting.
« Last Edit: September 11, 2021, 01:17:45 AM by Pfeil »

JTKaay

  • Newbie
  • *
  • Posts: 3
Re: Non Clickable Compact mode as a one liner
« Reply #2 on: September 11, 2021, 04:40:44 AM »
Do you have a screenshot of what it actually looks like. Id like to see if its actually what Im after.

And please excuse the stupid question, I am not a programmer of anything but BASIC (way back when)

I see the "!other - execute an inline function", but would I select #c, vb or precomplied - and further, how would I execute it?

Thanks for the info for now. :-)

EDIT// : I see this - (I hope the image shows) - Inline function between lines 18 and 27





Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Non Clickable Compact mode as a one liner
« Reply #3 on: September 11, 2021, 04:45:26 AM »
It literally just makes the existing window partially transparent (which is optional, you could comment that out), and non-clickable.

This is a C# inline function.

JTKaay

  • Newbie
  • *
  • Posts: 3
Re: Non Clickable Compact mode as a one liner
« Reply #4 on: September 11, 2021, 04:47:04 AM »
It literally just makes the existing window partially transparent (which is optional, you could comment that out), and non-clickable.

This is a C# inline function.

Got it, thank you, I will try it later if you dont mind? - my last post was the vb code edit window.

//EDIT - PERFECT, this is exactly what I wanted. Thankyou :-D

« Last Edit: September 11, 2021, 12:19:40 PM by JTKaay »