Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VD PinWindow function doesn't work with ahk_id #17

Closed
megamorphg opened this issue Jul 25, 2022 · 2 comments
Closed

VD PinWindow function doesn't work with ahk_id #17

megamorphg opened this issue Jul 25, 2022 · 2 comments

Comments

@megamorphg
Copy link

As per a Stack Overflow answer:
I tried using process ID but I think VD.PinWindow doesn't work with it e.g. VD.PinWindow("ahk_id 0xD3854") or VD.PinWindow("ahk_id %this_id%").

Full code used:

#Persistent
; If the script is not elevated, relaunch as administrator and kill current instance
full_command_line := DllCall("GetCommandLine", "str")

if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
    try ; leads to having the script re-launching itself as administrator
    {
        if A_IsCompiled
            Run *RunAs "%A_ScriptFullPath%" /restart
        else
            Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
    }
    ExitApp
}

#Include lib\VD.ahk-class_VD\_VD.ahk

WinGet, HWiNFO64List, List, ahk_exe HWiNFO64.EXE
VD.init()

Loop, %HWiNFO64List%
{
	this_id := HWiNFO64List%A_Index%
	VD.PinWindow("%this_id%")
	; MsgBox %this_id%
}
@FuPeiJiang
Copy link
Owner

try
VD.PinWindow("ahk_id " this_id)
instead of
VD.PinWindow("%this_id%")

this is a scripting error
% is not to be used inside quotes


this_id is a variable
this is how you'd write it in javascript: string concatenation
VD.PinWindow("ahk_id " + this_id)
this is how you'd write it in ahk: . is string concatenation operator
VD.PinWindow("ahk_id " . this_id)
or (concatenation is assumed):
VD.PinWindow("ahk_id " this_id)


props to you for putting Full code


you can also 'step into' using a debugger and see that the parameter's value isn't what you want
I use https://marketplace.visualstudio.com/items?itemName=zero-plusplus.vscode-autohotkey-debug#installation

@megamorphg
Copy link
Author

megamorphg commented Jul 25, 2022

Thank you! That worked. The parameter is already variabilized so it was failing.

      WinGet, HWiNFO64List, List, ahk_exe HWiNFO64.EXE
      Loop, %HWiNFO64List%
      {
         this_id := HWiNFO64List%A_Index%
         VD.PinWindow("ahk_id " this_id)
      }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants