Sign in to follow this  
Followers 0
iB07

display text on top but dont activate on click

4 posts in this topic

#1 ·  Posted (edited)

Dear AutoIt community,

im a hobbyscripter and got quite far with this awesome tool and its functions/tutorials already but now im stuck and dont find an answer for my problem (beside d3d drawing, which would require c++/dll injection)

my goal is it to display text on top of a borderless game window which is not active and NOT ACTIVATABLE

(just like i would DrawText with D3D)

that means i also dont want the text/label to "activate" if i accidentaly click it, since that would open the taskbar and id loose gamecontrol until i click the game again.

so is there any way to disable activating clicks for that gui? or is there even an better solution?

here an example what i got so far:

(press END to exit)

#include <GUIConstantsEx.au3> 
#include <Misc.au3>
Opt("GUIResizeMode",$GUI_DOCKALL)

;;VARS
global $EXIT = "23";Exit Hotkey = END
global $DisplayText="!!!!!!!!!!!!!!!!!!! TEXT TO DISPLAY !!!!!!!!!!!!!!!!!!!     'END' -> exit"
$X=800
$Y=50

CreateDisplay()

while 1
   HotKeys()
   GuiCtrlSetData($Label,$DisplayText)
   WinSetOnTop($GUI4LABEL,"",1)
   sleep(100)
wend

Func CreateDisplay()
   Global $GUI4LABEL = GUICreate("Display", 200, 200, 800, 3, 0x80000000, 128);$WS_POPUP = 0x80000000, $WS_EX_TOOLWINDOW = 128
    GUISetBkColor(0xADFF2F)
    ;Create Label with text
    Global $Label = GUICtrlCreateLabel($DisplayText, 3, 3)    
    $cgp = ControlGetPos($GUI4LABEL, "", $Label);get label size
    WinMove($GUI4LABEL, "", $X, $Y, $cgp[2], $cgp[3]);form gui
    ;OnTop
    WinSetOnTop($GUI4LABEL,"",1)
    ;Show no activate
    GUISetState(@SW_SHOWNOACTIVATE) 
 EndFunc
 
 Func HotKeys()
   ;;Hotkey END
   if _IsPressed($EXIT) = 1 Then
      Exit
   EndIf
   While _IsPressed ($EXIT) = 1
      Sleep(1)
   WEnd 
 EndFunc

regards,

iB07

Edited by iB07

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You have some errors and unnecessary elements there.

For starters, all your Globals should be at the top of your script.

If _IsPressed($exit) does indeed equal 1, it will never get to the While part of your Hotkeys function, because of the Exit.

Perhaps you meant it to part of an Else statement and use doesn't equal (<>)?

But then, your code execution would be trapped in that loop, and never return to your first While, until you pressed the END key.

Not quite sure why you need to keep sending the same text to the label again (repeatedly and so frequently)?

Or why you need to repetitively set the window on top, when it was made that way at creation?

And I'm not sure that I completely understand your overall aim, but you could disable the Mouse while the Text GUI is showing.

Perhaps, if you rethink the logic of what you are doing and correct your code, then I or another may be able to help.

EDIT

Welcome to the forum! :)

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

I think maybe something like this is what you are looking for?

#include <GUIConstantsEx.au3>

Opt("GUIResizeMode",$GUI_DOCKALL)

Global $DisplayText = "                                           !!!!!!!!!!!!!!!!!!! TEXT TO DISPLAY !!!!!!!!!!!!!!!!!!!     'END' -> exit"

HotKeySet("{END}", "Leave")

$GUI4LABEL = GUICreate("GreenGui", @DesktopWidth / 2, @DesktopHeight / 2, -1, -1, 0x80000000, 128);$WS_POPUP = 0x80000000, $WS_EX_TOOLWINDOW = 128
GUISetBkColor(0xADFF2F)
$Label = GUICtrlCreateLabel($DisplayText, 3, 3, @DesktopWidth / 2 - 10, 17)                     ; Need to set the width and height of the Label 
WinSetOnTop($GUI4LABEL,"",1)
GUISetState(@SW_SHOWNOACTIVATE)

$hWnd = WinGetHandle("GreenGui", "TEXT TO DISPLAY")

while 1
   If Not WinActive($hWnd) Then WinActivate($hWnd)
   Sleep(100)
wend

Func Leave()
    Exit
EndFunc

Hope this helps.

Share this post


Link to post
Share on other sites

my goal is it to display text on top of a borderless game window which is not active and NOT ACTIVATABLE

 

 

WOOP!!! WOOP!!!!

DANGER WILL ROBINSON!!! DANGER!!!

Read the rules.

1 person likes this

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0