hoppfrosch / AHK_Windy

Toolbox to operate on windows
http://hoppfrosch.github.io/AHK_Windy
Other
23 stars 8 forks source link

???: Restore WindowSettings on Process-Generation #35

Open hoppfrosch opened 9 years ago

hoppfrosch commented 9 years ago

On creation of a process the opened windows should be restored to predefined settings (for example window size & position)

Idea taken from: http://ahkscript.org/boards/viewtopic.php?f=5&t=9169

``#Persistent winmgmts := ComObjGet("winmgmts:") createSink := ComObjCreate("WbemScripting.SWbemSink") ComObjConnect(createSink, "ProcessCreate_") interval := 1 winmgmts.ExecNotificationQueryAsync(createSink, "SELECT * FROM __InstanceCreationEvent WITHIN " . interval . " WHERE TargetInstance ISA 'Win32_Process' AND TargetInstance.Name='notepad.exe'" ) return

ProcessCreate_OnObjectReady(objWbemObject, objWbemAsyncContext) { WinMove, % "ahk_pid " objWbemObject.TargetInstance.ProcessId,, 100, 200, 300, 400 }``

hoppfrosch commented 9 years ago

See also: https://bitbucket.org/klomb/frontandcenter (will automatically move new windows to the monitor the mouse is currently in and center them, if the window is maximized it will try to restore, move and maximize the window again.)