red0fireus Posted July 31, 2020 Posted July 31, 2020 (edited) #include <WinAPI.au3> while 1 sleep(1000) If IsVisible() = 1 then ConsoleWrite("TRUE") Elseif IsVisible() = 0 then ConsoleWrite("FALSE") EndIF WEnd Func IsVisible() Local $hWnd = DllCall('user32.dll', 'hwnd', 'GetForegroundWindow') $hWnd = $hWnd[0] If (@error) Or ($hWnd = 0) Then Return SetError(1, 0, -1) EndIf If (StringInStr(WinGetClassList($hWnd), 'SHELLDLL_DefView') = 0) And (BitAND(WinGetState($hWnd), 2) = 2) And (_WinAPI_GetClientWidth($hWnd) = @DesktopWidth) And (_WinAPI_GetClientHeight($hWnd) = @DesktopHeight) Then return 1 else return 0 EndIf EndFunc I'm running in to an issue with this script. Currently it finds the Most Active Foreground Window but if I click on another monitor it starts to return False instead of True. I was thinking the best way to fix this would be to get the active windows pid and then if that ProcessExists then keep returning true. I've been working on this for 2 days now (it's probably simple) I'm pretty much worn out and need some kind of hint. (I want to keep returning true even if I click on another monitor) - that's my goal Thank you - Edited July 31, 2020 by red0fireus
red0fireus Posted July 31, 2020 Author Posted July 31, 2020 If this is not possible with multiple monitors then that would be good to know too.
red0fireus Posted August 1, 2020 Author Posted August 1, 2020 (edited) expandcollapse popup#include <WinAPI.au3> Global $iMonitor AdlibRegister("_AggIsFullScreen") While 1 $tmp = _AggIsFullScreen() sleep(1000) If $tmp = 1 and ProcessExists("rainmeter.exe") then run("cmd.exe /c taskkill /im rainmeter.exe /f", "", @SW_HIDE) ConsoleWrite("monitor 1") elseif $tmp = 0 and not ProcessExists("rainmeter.exe") then Run("C:\Program Files\Rainmeter\rainmeter.exe", "C:\Program Files\Rainmeter", @SW_HIDE) ConsoleWrite("monitor 2") EndIf WEnd Func _AggIsFullScreen() $xMousePos = MouseGetPos(0) $yMousePos = MouseGetPos(1) Local $iPid Local $iWin Local $var = WinList("[REGEXPTITLE:^(?!Microsoft Text Input Application|Program Manager)(?s).*]") If $xMousePos >= 0 AND $xMousePos < @DesktopWidth AND $yMousePos >= 0 AND $yMousePos < @DesktopHeight then For $i = 1 To $var[0][0] $iWin = $var[$i][1] If BitAND(WinGetState($var[$i][1]), 2) and BitAND(WinGetState($iWin), 2) and (StringInStr(WinGetClassList($iWin), 'SHELLDLL_DefView') = 0) And (BitAND(WinGetState($iWin), 2) = 2) And (_WinAPI_GetClientWidth($iWin) = @DesktopWidth) And (_WinAPI_GetClientHeight($iWin) = @DesktopHeight) then ; is visible $iPid = WinGetProcess($var[$i][1]) If ProcessExists($iPid) Then return 1 else return 0 endIf EndIf Next else return -1 Endif EndFunc I took a break and came back and I figured it out. If anyone is interested here is my code Edited August 2, 2020 by red0fireus
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now