GUI update on keypress/hotkey, while GUI is not the active window

Ask gaming related questions
Genelas
Posts: 2
Joined: 23 Jul 2020, 04:59

GUI update on keypress/hotkey, while GUI is not the active window

23 Jul 2020, 05:21

Background: I am using Vis2 https://www.autohotkey.com/boards/viewtopic.php?t=36047 (Tesseract) in order to retrieve OCR data from my active game session.
The GUI is set to be AlwaysOnTop as I want to see if it receives the correct information at all time. When I press the c button (hotkey) then I want the GUI to display the value it has received from the OCR.
The code below works whenever I have the GUI as my current active window, but as soon as my game session is the active window (as it should be) the GUI will not update the information.

Code: Select all

#include <Vis2>  ; Equivalent to #include .\lib\Vis2.ahk
#SingleInstance, force

Gui, +AlwaysOnTop +LastFound
Gui, Add, Edit, x10 w200 r5 vEdit2,
Gui, Show, w500 h600, The GUI 
return

c::
	text:= OCR([579, 1033, 37, 21])
	GuiControl,,Edit2, %text%
return

GuiClose:
	ExitApp
I want the code above to update the GUI even though the GUI is not the active window, I would also prefer it if I do not have to tab out for this task, as this will cause FPS drops with the active gaming session.
Last edited by BoBo on 23 Jul 2020, 08:05, edited 1 time in total.
Reason: Moved to Gaming section.
User avatar
masato
Posts: 20
Joined: 08 Sep 2015, 13:38

Re: GUI update on keypress/hotkey, while GUI is not the active window

23 Jul 2020, 07:44

Genelas wrote:
23 Jul 2020, 05:21
Background: I am using Vis2 https://www.autohotkey.com/boards/viewtopic.php?t=36047 (Tesseract) in order to retrieve OCR data from my active game session.
The GUI is set to be AlwaysOnTop as I want to see if it receives the correct information at all time. When I press the c button (hotkey) then I want the GUI to display the value it has received from the OCR.
The code below works whenever I have the GUI as my current active window, but as soon as my game session is the active window (as it should be) the GUI will not update the information.

Code: Select all

#include <Vis2>  ; Equivalent to #include .\lib\Vis2.ahk
#SingleInstance, force

Gui, +AlwaysOnTop +LastFound
Gui, Add, Edit, x10 w200 r5 vEdit2,
Gui, Show, w500 h600, The GUI 
return

c::
	text:= OCR([579, 1033, 37, 21])
	GuiControl,,Edit2, %text%
return

GuiClose:
	ExitApp
I want the code above to update the GUI even though the GUI is not the active window, I would also prefer it if I do not have to tab out for this task, as this will cause FPS drops with the active gaming session.
Does it work when you active any other window than the game?
If so, then try running the script as admin.
And if not, then try adding this before your hotkey:

Code: Select all

#IfWinActive
Also if you want your hotkey to only work while in game, use:

Code: Select all

#IfWinActive ahk_exe YourGameExe.exe
Otherwise, it could simply be that your library requires the window to be visible or active.
Genelas
Posts: 2
Joined: 23 Jul 2020, 04:59

Re: GUI update on keypress/hotkey, while GUI is not the active window

23 Jul 2020, 09:15

Does it work when you active any other window than the game?
After some testing, I found out that the script does work when I apply it to other windows: It does return the "empty string", which is a correct behaviour as well.
If so, then try running the script as admin.
And if not, then try adding this before your hotkey:

Code: Select all

#IfWinActive
Unfortunately neither of the two options changed anything. It seems to be specific to the game that it will not allow me to update the GUI while having the game running (borderless windowed mode).

Return to “Gaming”

Who is online

Users browsing this forum: nida and 14 guests