Finding each win position & applying a command to each one

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Kobaltauge
Posts: 264
Joined: 09 Mar 2019, 01:52
Location: Germany
Contact:

Re: Finding each win position & applying a command to each one

31 Dec 2019, 05:03

Now I'm at the end of my knowledge. I'm using Windows 10, Word 365 and AHK 1.1.30.01. And I think it does what you want with one or 10 Word windows. And if you have a mix of the views, it toggles them.

The only thing is, that the hotkey should not be used in the window you are clicking it. For example this "F6" doesn't work in AHK Studio, because "F6" is mapped there for other things. For testing, I click on the desktop, so every window is not active.
AmDeG 11
Posts: 388
Joined: 28 Nov 2013, 11:42

Re: Finding each win position & applying a command to each one

31 Dec 2019, 09:49

I'm frustrated.
I do have the same environment: Windows 10, autohotkey same version and Office 365.
I don't understand why it's not working. (I use Scite and not AHK Studio, I understand that is unrelated)

BTW, I didn't understand your second paragraph. Are you saying that I should not pull the code at the very Word doc I would like to apply that view?
Indeed I have it inside a

Code: Select all

#IfWinActive ahk_class OpusApp ahk_exe WINWORD.EXE
Kobaltauge
Posts: 264
Joined: 09 Mar 2019, 01:52
Location: Germany
Contact:

Re: Finding each win position & applying a command to each one

01 Jan 2020, 08:45

No, my script works every time. Unless you are in a window, that has remapped F6. For example, when you have F6 as hotkey in word, it probably overrides the hotkey of AHK. Sorry for the confusion.

You can, after execute the hotkey, open the log of AHK. Click with the right mouse button on the H in the system tray and choose Open. There you can take a look if something doesn't work properly.
As you can see in the screenshot, I have three word windows open and the loop is executed three times. You can see, what was the last command the script executed. Probably there is something, that goes wrong.
Please try in the first step only the posted code. if this works, you have a base and know that everything your adding, cause the problem.
Anmerkung 2020-01-01 142602.png
Anmerkung 2020-01-01 142602.png (36.86 KiB) Viewed 410 times

Code: Select all

#SingleInstance

F6::
WinGet, Window, List, ahk_class OpusApp
Loop, %Window% 
{ 
	if Window%A_Index%
	{
		WinGetPos, X,Y,W,H, % "ahk_id " Window%A_Index%
		WinActivate, % "ahk_id " Window%A_Index%
		Send ^!{F5} ;ToggleFull
		sleep, 1000
		WinMove % "ahk_id " Window%A_Index%,, %X% ,%Y% ,%W% ,%H%
	}
}
return
AmDeG 11
Posts: 388
Joined: 28 Nov 2013, 11:42

Re: Finding each win position & applying a command to each one

01 Jan 2020, 13:42

ok, I replaced the whole previous script and run the last one with only Word and the problem persists (: I mean, for a second it does the job but then again it maximizes

(BTW this code is added to my main ahk codes, I understand I should nor run independently --- I add this comment since the code starts with a #Single Instance)

(BTW2 in the very first codes, it was working with just one Word)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], JoeWinograd and 131 guests