Git Product home page Git Product logo

Comments (13)

3tmp avatar 3tmp commented on July 27, 2024 1

Thanks!

from vd.ahk.

FuPeiJiang avatar FuPeiJiang commented on July 27, 2024

interesting..


using a debugger, you can see exactly which line causes a crash

vscode https://marketplace.visualstudio.com/items?itemName=zero-plusplus.vscode-autohotkey-debug
with https://marketplace.visualstudio.com/items?itemName=mark-wiemer.vscode-autohotkey-plus-plus


I ran on Windows 11, no crash

fresh Windows install

how do you get a fresh Windows install that easily ? Vmware ?
I shall use that to get Windows 10


it's interesting that you can use
"ahk_id" hwnd
instead of
"ahk_id " hwnd

from vd.ahk.

FuPeiJiang avatar FuPeiJiang commented on July 27, 2024

I ran your code on windows 10 vmware, no crash
by "explorer shell", do you mean explorer.exe ? with taskbar and desktop ?

from vd.ahk.

FuPeiJiang avatar FuPeiJiang commented on July 27, 2024

The windows that cause the problem seem to be invisible to the user, which means that the built in commands return blank strings for the process path or class name

then what's the wintitle ? VD.getDesktopNumOfWindow should return -1 for empty "" wintitle


Maybe it's your AHK version ? as last hope ?
mine is 1.1.33.10

MsgBox % Clipboard:=A_AhkVersion

from vd.ahk.

3tmp avatar 3tmp commented on July 27, 2024

how do you get a fresh Windows install that easily ? Vmware ?

I got the fresh install using the Windows Sandbox.
And I also just tried it with vmware, same result sadly.
The ahk version is 1.1.33.11 and the Windows 10 version is 21H2

by "explorer shell", do you mean explorer.exe ? with taskbar and desktop ?

Yes, i mean the explorer.exe
shell_crashing

using a debugger, you can see exactly which line causes a crash

I already tried using a debugger yesterday, but I will try again as soon as I have the time to.

then what's the wintitle ?

I will try to identify the wintitle

from vd.ahk.

3tmp avatar 3tmp commented on July 27, 2024

Also, if I run the code from the global_functions branch, then the shell does not crash.

from vd.ahk.

FuPeiJiang avatar FuPeiJiang commented on July 27, 2024

I got it, I got the bug, now I can try to fix it (on Win11 and Win10)


ahk classes are a pain to debug
if I use If (d > -1) instead of if (d != -1)
then the problem becomes apparent that I didn't include the class
I thought it would throw an error if the class isn't included, but nothing happens, it just runs

the class VD isn't even included and these 2 methods run without throwing...
VD.init()
VD.getDesktopNumOfWindow("ahk_id" hwnd)

needed #Include _VD.ahk at the top


Also, if I run the code from the global_functions branch, then the shell does not crash.

good news, then it's fixable


Windows Sandbox. ? wow I forgot about that. seeing it being used for debugging makes me want to try it
thank you

from vd.ahk.

3tmp avatar 3tmp commented on July 27, 2024

ahk classes are a pain to debug

Yeah, ahk in general is not that much fun to debug...
Ah yes, it can be really frustrating that ahk just ignores errors


I use Windows Sandbox all the time. It's really useful if you just want to try out a new program, but you don't want to install it on your main machine and it boots much faster than normal VMs. But if I remember correctly it only works on the Pro versions and not Home

from vd.ahk.

FuPeiJiang avatar FuPeiJiang commented on July 27, 2024
Windows Shell Experience Host
ahk_class Windows.UI.Core.CoreWindow
ahk_exe ShellExperienceHost.exe

Inside of class, I was setting DetectHiddenWindows Off, so no WinTitle..

from vd.ahk.

3tmp avatar 3tmp commented on July 27, 2024

Ah I see

from vd.ahk.

3tmp avatar 3tmp commented on July 27, 2024

I think I could locate the problem: It has to be somewhere inside of the _getFirstValidWindow(wintitle) method, because I modified the method to just return the hwnd that it received and now there are no crashes anymore.

from vd.ahk.

FuPeiJiang avatar FuPeiJiang commented on July 27, 2024

you may want to do it like this

;VD.getDesktopNumOfWindow will filter out invalid windows`

#Include ..\VD.ahk

foundProcesses := ""
; Make sure to get all windows from all virtual desktops
DetectHiddenWindows On
WinGet, id, List
Loop %id%
{
    hwnd := id%A_Index%
    ;VD.getDesktopNumOfWindow will filter out invalid windows
    desktopNum_ := VD.getDesktopNumOfWindow("ahk_id" hwnd)
    If (desktopNum_ > -1) ;-1 for invalid window, 0 for "Show on all desktops", 1 for Desktop 1
    {
        WinGet, exe, ProcessName, % "ahk_id" hwnd
        foundProcesses .= desktopNum_ " " exe "`n"
    }
}

MsgBox % foundProcesses

I think I should add this code block in the README.md

https://github.com/FuPeiJiang/VD.ahk/blob/da6445cfadfce8ddef1e70751ee319507422d461/other%20examples/foundProcesses_min.ahk
https://github.com/FuPeiJiang/VD.ahk/blob/da6445cfadfce8ddef1e70751ee319507422d461/other%20examples/foundProcesses.ahk

from vd.ahk.

FuPeiJiang avatar FuPeiJiang commented on July 27, 2024

Yeah, ahk in general is not that much fun to debug...
Ah yes, it can be really frustrating that ahk just ignores errors

oh, ahkv2 fixed it, so that's not ahk's issue, I think ahkv2 is 10x easier to debug

from vd.ahk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.