Jump to content

Black screen while creating an overlay using ImGui


Recommended Posts

#include <Windowsconstants.au3>
#include <WinAPI.au3>
#include "imgui.au3"


_ImGui_EnableViewports()

Local $hwnd = _ImGui_GUICreate("", 1, 1, -100, -100, 0, $WS_EX_TOOLWINDOW)
_WinAPI_ShowWindow($hwnd)

_ImGui_StyleColorsDark()
Global $bCheckbox1 = 0
Global $ScreenSize[] = [@DesktopWidth, @DesktopHeight]
Local $io = _ImGui_GetIO()
$io.ConfigWindowsMoveFromTitleBarOnly = True

Local $is_first_run = True

While 1
    If Not _ImGui_PeekMsg() Then Exit

    _ImGui_BeginFrame()
    If Not _ImGui_Begin("Test", True, $ImGuiWindowFlags_NoCollapse) Then Exit

    If $is_first_run Then
        $is_first_run = False
        Local $win_size[] = [500, 300]
        Local $win_pos_x = (@DesktopWidth - $win_size[0]) / 2
        Local $win_pos_y = (@DesktopHeight - $win_size[1]) / 2
        _ImGui_SetWindowPos($win_pos_x, $win_pos_y)
        _ImGui_SetWindowSize($win_size[0], $win_size[1])
    EndIf

    _ImGui_CheckBox("Overlay", $bCheckbox1)
    If $bCheckbox1 Then
        _ImGui_SetNextWindowSize($ScreenSize[0], $ScreenSize[1])
        _ImGui_SetNextWindowPos(0, 0)
        If _ImGui_Begin("overlay", False, BitOR($ImGuiWindowFlags_NoDecoration, $ImGuiWindowFlags_NoInputs, $ImGuiWindowFlags_NoBringToFrontOnFocus, $ImGuiWindowFlags_NoCollapse, $ImGuiWindowFlags_NoScrollbar, $ImGuiWindowFlags_NoScrollWithMouse, $ImGuiWindowFlags_NoBackground)) Then
            Local $pDrawListPtr = _ImGui_GetWindowDrawList()
            _ImDraw_AddCircle(400, 400, 100, 0xFFFFFF)
            _ImGui_End()
        EndIf

    EndIf
    _ImGui_End()
    _ImGui_EndFrame()
Wend

First window is appearing there is no problem, but when i create second window it's just pure black screen when i put $ImGuiWindowFlags_NoBackground. What am i doing wrong? What I'm tryna do is, when i hit the checkbox it will create a transparent background and draw a circle on it. It doesn't draw the circle probably because it's pure black screen like i said. I've tried a lot of stuff but didn't work, i'd appreciate any help. Thanks in advance..

Edited by kevinalberts
Link to comment
Share on other sites

Posted (edited)

an addition; I checked demo window thing. Somehow that $ImGuiWindowFlags_NoBackground and $ImGuiWindowFlags_NoTitleBar works fine but not on my script.

 

(Forgive me if i created the help post in wrong section)

Edited by kevinalberts
Link to comment
Share on other sites

10 minutes ago, Jos said:

What exactly is IMGUI as that is not a standard UDF library we supply?

Hi Jos, IMGUI is a powerful & high performanced cool looking UI library, thought you know it.

It uses imgui functions using DllCalls from compiled imgui dll. So imgui can be used in autoit as well thanks to this.

Link to comment
Share on other sites

31 minutes ago, kevinalberts said:

anyone?

I think you should ask the creator of imgui.  It is the first I hear about it and I have been using AutoIt for about 20 years !  I doubt that someone here has the knowledge to answer you without investing quite some time on your issue.  But who knows I could be wrong.

BTW, you should wait longer before bumping your own thread...

Link to comment
Share on other sites

1 hour ago, Nine said:

I think you should ask the creator of imgui.  It is the first I hear about it and I have been using AutoIt for about 20 years !  I doubt that someone here has the knowledge to answer you without investing quite some time on your issue.  But who knows I could be wrong.

BTW, you should wait longer before bumping your own thread...

i'm sorry i'm kinda new to forum, when should i bump?

Link to comment
Share on other sites

It doesn't work because you need to call SetDrawList() and the color should be in AARRGGBB format.

#include <Windowsconstants.au3>
#include <WinAPI.au3>
#include "imgui.au3"


_ImGui_EnableViewports()

Local $hwnd = _ImGui_GUICreate("", 1, 1, -100, -100, 0, $WS_EX_TOOLWINDOW)
_WinAPI_ShowWindow($hwnd)

_ImGui_StyleColorsDark()
Global $bCheckbox1 = 0
Global $ScreenSize[] = [@DesktopWidth, @DesktopHeight]
Local $io = _ImGui_GetIO()
$io.ConfigWindowsMoveFromTitleBarOnly = True

Local $is_first_run = True

While 1
    If Not _ImGui_PeekMsg() Then Exit

    _ImGui_BeginFrame()
    If Not _ImGui_Begin("Test", True, $ImGuiWindowFlags_NoCollapse) Then Exit

    If $is_first_run Then
        $is_first_run = False
        Local $win_size[] = [500, 300]
        Local $win_pos_x = (@DesktopWidth - $win_size[0]) / 2
        Local $win_pos_y = (@DesktopHeight - $win_size[1]) / 2
        _ImGui_SetWindowPos($win_pos_x, $win_pos_y)
        _ImGui_SetWindowSize($win_size[0], $win_size[1])
    EndIf

    _ImGui_CheckBox("Overlay", $bCheckbox1)
    If $bCheckbox1 Then
        _ImGui_SetNextWindowSize($ScreenSize[0], $ScreenSize[1])
        _ImGui_SetNextWindowPos(0, 0)
        If _ImGui_Begin("overlay", False, BitOR($ImGuiWindowFlags_NoDecoration, $ImGuiWindowFlags_NoInputs, $ImGuiWindowFlags_NoBringToFrontOnFocus, $ImGuiWindowFlags_NoCollapse, $ImGuiWindowFlags_NoScrollbar, $ImGuiWindowFlags_NoScrollWithMouse, $ImGuiWindowFlags_NoBackground)) Then
            Local $pDrawListPtr = _ImGui_GetWindowDrawList()
            _ImDraw_SetDrawList($pDrawListPtr)              ; line added
            _ImDraw_AddCircle(400, 400, 100, 0xFFFFFFFF)    ; AARRGGBB color
            _ImGui_End()
        EndIf

    EndIf
    _ImGui_End()
    _ImGui_EndFrame()
Wend

 

Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

14 minutes ago, kevinalberts said:

it's still black screen

Really? It's black because you use dark color style + $ImGuiWindowFlags_NoBackground. Voilà, it's not black anymore:

#include <Windowsconstants.au3>
#include <WinAPI.au3>
#include "imgui.au3"


_ImGui_EnableViewports()

Local $hwnd = _ImGui_GUICreate("", 1, 1, -100, -100, 0, $WS_EX_TOOLWINDOW)
_WinAPI_ShowWindow($hwnd)

_ImGui_StyleColorsLight()
Global $bCheckbox1 = 0
Global $ScreenSize[] = [@DesktopWidth, @DesktopHeight]
Local $io = _ImGui_GetIO()
$io.ConfigWindowsMoveFromTitleBarOnly = True

Local $is_first_run = True

While 1
    If Not _ImGui_PeekMsg() Then Exit

    _ImGui_BeginFrame()
    If Not _ImGui_Begin("Test", True, $ImGuiWindowFlags_NoCollapse) Then Exit

    If $is_first_run Then
        $is_first_run = False
        Local $win_size[] = [500, 300]
        Local $win_pos_x = (@DesktopWidth - $win_size[0]) / 2
        Local $win_pos_y = (@DesktopHeight - $win_size[1]) / 2
        _ImGui_SetWindowPos($win_pos_x, $win_pos_y)
        _ImGui_SetWindowSize($win_size[0], $win_size[1])
    EndIf

    _ImGui_CheckBox("Overlay", $bCheckbox1)
    If $bCheckbox1 Then
        _ImGui_SetNextWindowSize($ScreenSize[0], $ScreenSize[1])
        _ImGui_SetNextWindowPos(0, 0)
        If _ImGui_Begin("overlay", False, BitOR($ImGuiWindowFlags_NoDecoration, $ImGuiWindowFlags_NoInputs, $ImGuiWindowFlags_NoBringToFrontOnFocus, $ImGuiWindowFlags_NoCollapse, $ImGuiWindowFlags_NoScrollbar, $ImGuiWindowFlags_NoScrollWithMouse)) Then
            Local $pDrawListPtr = _ImGui_GetWindowDrawList()
            _ImDraw_SetDrawList($pDrawListPtr)              ; line added
            _ImDraw_AddCircle(400, 400, 100, 0xFFFF8000)    ; AARRGGBB color
            _ImGui_End()
        EndIf

    EndIf
    _ImGui_End()
    _ImGui_EndFrame()
Wend

 

Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

Posted (edited)

No you didn't get me, i want it to be transparent...

 

I noticed i didn't even use $ImGuiWindowFlags_NoBackground. But eventho i added it it's still not transparent window

Edited by kevinalberts
Link to comment
Share on other sites

My crystal ball it's broken, I can't figure out what everyone might want. Anyway your issues doesn't seems related to AutoIt but more about how imgui works, so it's better to post your questions about imgui in the right place.

When the words fail... music speaks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...