Need help with a script that will send the {HOME} key to all ahk_class CabinetWClass | ahk_class ExploreWClass if active or exist.
I've been working on this for quite sometime and have yet to figure this out.
I've tried this and several other variations (Controlsend/ControlsendRaw/Send, etc...).
#Persistent
IfWinExist, ahk_class CabinetWClass
WinActivate
Send, {Home}
return
Help would be much apprenticed.
Need help with a script ...
Re: Need help with a script ...
IfWinExist, ahk_class CabinetWClass
{
WinActivate, ahk_class CabinetWClass
Send, {Home}
}
Else
Soundbeep, 199, 777
Return
{
WinActivate, ahk_class CabinetWClass
Send, {Home}
}
Else
Soundbeep, 199, 777
Return
Re: Need help with a script ...
That will only find one of the windows and operate on it. You need to use WinGet, List to identify all the matching windows, then create a loop to activate each one and Send, {Home} to each one individually.
Re: Need help with a script ...
That's a very nice idea.boiler wrote:That will only find one of the windows and operate on it. You need to use WinGet, List to identify all the matching windows, then create a loop to activate each one and Send, {Home} to each one individually.
Now, how is the codes ?
You can help him/her from top to bottom and every coner of it.
I, am, so busy at the moment.
See you then.
Re: Need help with a script ...
Code: Select all
WinGet, WinList, List, ahk_class CabinetWClass
Loop, %WinList%
{
WinID := WinList%A_Index%
WinActivate, ahk_id %WinID%
Send, {Home}
}
Re: Need help with a script ...
Thanks for the suggestions guys however these scripts do not work. Any more suggestions while I continue to figure this out?
Re: Need help with a script ...
By not working, do you mean it's not working in an ongoing manner? You need to put it in a loop or on a timer for that. As written, it does it once when you run it. But I know it works because when I replace CabinetWClass with Notepad and {Home} with Hello, it writes "Hello" into every open Notepad window I have open when I run it.
Perhaps sending {Home} to an active window of windows of class CabinetWClass does not have the result that you expect.
But if it's because it's not working as an ongoing script, try this:
However, that will continuously keep sending {Home} to those windows over and over, which I didn't think is what you would want.
Perhaps sending {Home} to an active window of windows of class CabinetWClass does not have the result that you expect.
But if it's because it's not working as an ongoing script, try this:
Code: Select all
Loop
{
WinGet, WinList, List, ahk_class CabinetWClass
Loop, %WinList%
{
WinID := WinList%A_Index%
WinActivate, ahk_id %WinID%
Send, {Home}
}
Sleep, 100
}
Re: Need help with a script ...
I think it's the class as you stated because when I first wrote the script it worked perfectly in notepad but not CabinetWClass. There has to be a way ........
Re: Need help with a script ...
Thanks again for your input.
Re: Need help with a script ...
I just ran it exactly as shown here, and it works with CabinetWClass as well for me. It does the exact same thing in all of my explorer windows as if I had hit the Home key myself in them. Is that what you're expecting to happen?
Re: Need help with a script ...
Well I'm not sure what's going on but it's not working in the manner I intended for it to work (If I click it it presses the home key like the scripts I previously made, but not when I open up other windows). I even added #Persistent to see if that would help, nope!
Re: Need help with a script ...
Again I'm trying to get the script to send the home key (select/highlight the first item in the folder) to each instance of class of window once opened.
Re: Need help with a script ...
No, you actually didn't say that before. The "once opened" is the key new thing you mentioned. The script I posted does exactly what your first post says you wanted. When you run the script, it will do that for all windows that exist at the time. If you want it to operate on windows as they open and only as they are first opened, that's different. It can be made to do that. Persistent just keeps the script open, it doesn't make it keep checking or running it from the beginning. You have to add the flow and control into the code yourself to make it do what you want when you want. If you use the version I showed with the Loop in it, then it will constantly be sending {Home} to all of them. It sounds like you want it to just check for new ones, which is more involved. That can be done.
You need to have it keep an updated array of all the existing IDs that match the criteria (I showed you how to store them in an array). Then you need to have it re-check for all the ones that currently exist (using the method shown) and compare them to the ones in the array of last known group of windows. Then if it finds a new one (i.e., not in the list), it would send {Home} to that one (and update the list of last known windows for the next comparison).
You may want to try to make a script do that per that direction and post it here if you can't get it to work. It's a lot better for learning if you try working out the logic yourself first.
You need to have it keep an updated array of all the existing IDs that match the criteria (I showed you how to store them in an array). Then you need to have it re-check for all the ones that currently exist (using the method shown) and compare them to the ones in the array of last known group of windows. Then if it finds a new one (i.e., not in the list), it would send {Home} to that one (and update the list of last known windows for the next comparison).
You may want to try to make a script do that per that direction and post it here if you can't get it to work. It's a lot better for learning if you try working out the logic yourself first.
Re: Need help with a script ...
Easy Dear "boiler"..
>You can help him/her from top to bottom and every coner of it.
Actually, You can not help him.
That is his own business.
>You can help him/her from top to bottom and every coner of it.
Actually, You can not help him.
That is his own business.
Re: Need help with a script ...
That's what I've been doing relentlessly for the past few days, I put aside my pride and came here for some help. My apologies if I didn't make the purpose of the script crystal clear on my original post. My thoughts were active included on open.
Re: Need help with a script ...
The difference now is that I showed you some things that would allow you to do it, and I outlined the logic for you. I'll post something that works, but I think it would still be a good exercise for you to try it yourself using the approach I described.
Re: Need help with a script ...
Again, that's what I've been doing relentlessly for the past few days even with what you've outlined the time I've spent working on this particular script has diminished my patience on it. I have many more scripts to create, this one is quite the challenge. Thanks again for your help.
Re: Need help with a script ...
You're welcome. Here's a working script:
Code: Select all
LastCount := 0
Loop
{
WinGet, WinList, List, ahk_class CabinetWClass
Loop, %WinList%
{
Outer := A_Index
Found := 0
Loop, %LastCount%
{
if (WinList%Outer% = LastWinID%A_Index%)
{
Found := 1
break
}
}
if !Found
{
WinID := WinList%Outer%
WinActivate, ahk_id %WinID%
Send, {Home}
}
}
LastCount := WinList
Loop, %WinList%
LastWinID%A_Index% := WinList%A_Index%
Sleep, 100
}
Re: Need help with a script ...
Thanks!!! WoW, impressive!!! I learn better with examples. Now I'm going to get the script to send home once I click on a folder inside the initial window. To achieve that it would Involve WinGet and Loop correct?
Re: Need help with a script ...
If I understand what you want it to do, you want it to automatically send Home to it again, but only when you open a new folder in that window. Is that correct? What I think would be necessary would be to constantly monitor the contents of the Edit1 control (which displays the current path) of the active window (if it is this class of window) using ControlGet, and wait for it to change. Then when it does, send Home to the window.
Who is online
Users browsing this forum: Rohwedder and 336 guests