Hide/Show a GUI Window Topic is solved

Ask gaming related questions (AHK v1.1 and older)
irosan
Posts: 3
Joined: 23 Apr 2021, 11:23

Hide/Show a GUI Window

06 May 2021, 14:02

Hey,

For the last few hours I have not been able to find out how I can perform a certain function with AHK.

I have a crosshair script with a GUI Window and I do want to hide that Window when Right Mouse Button is pressed, and to show that Window again when the Right Mouse Button is released. I have tried it out with this:

Code: Select all

~RButton::
    While, GetKeyState("RButton", "P")
    {
    Gui, crosshair:Hide
    }
Return

~RButton up::
Gui, crosshair:Show
return
and it does it partially: the function is there, but somehow it does block the playing in game (I am not sure, but I do assume that the conflict is there because of the command "AlwaysOnTop", cuz if I go desktop and back... the game is ok, until I do use the Right Mouse again. The Toogle works fine (it does not block the game while used).


The crosshair script I did found here: https://www.autohotkey.com/boards/viewtopic.php?p=296138#p296138

Can someone help me to resolve this problem?
User avatar
boiler
Posts: 16926
Joined: 21 Dec 2014, 02:44

Re: Hide/Show a GUI Window

06 May 2021, 16:05

This probably doesn't have anything to do with your problem, but I don't see a reason why you are continuously executing the Hide in a loop. It would work just hiding it upon the press and showing it on the release as demonstrated here:

Code: Select all

Gui, +AlwaysOnTop
Gui, Add, Text, y80 w150 h100 Center, Test GUI
Gui, Show
return

~RButton::
    Gui, Hide
Return

~RButton up::
	Gui, Show
return

GuiClose:
ExitApp
irosan
Posts: 3
Joined: 23 Apr 2021, 11:23

Re: Hide/Show a GUI Window

06 May 2021, 16:47

Thank you for your comment. But, the problem is still there. After using RButton, can´t move ingame. Need to go to desktop and back, or with alt tab switch between the windows to get back into game.
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Hide/Show a GUI Window  Topic is solved

06 May 2021, 18:15

You can avoid activation if needed.

Code: Select all

Gui, Show, NoActivate
Explained: Gui, Show
irosan
Posts: 3
Joined: 23 Apr 2021, 11:23

Re: Hide/Show a GUI Window

07 May 2021, 05:21

Thank you very much. That was the solution. Now it does works as it shall. Also big thanks to boiler for correcting the code. :)

The correct addition to the mentioned script is (for all future visitors who are interested) :

Code: Select all

~RButton::
    Gui, crosshair:Hide
Return

~RButton up::
    Gui, crosshair:Show, NoActivate

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 136 guests