Jump to content
  • Announcements

    • AndalayBay

      Orphan Attachments   07/31/2018

      I have been doing some housekeeping lately and I've noticed that I had a lot of orphaned attachments. Attachments get orphaned when the PM or post is deleted without removing the attachment first. Deleting a PM or post does not delete the attachment and the file or image remain on the server. I'd like to ask all members to go through their attachments and delete any attachments you don't need anymore or those that have been orphaned. Where can I get a list of my attachments? Click on your display name in the upper right corner of the forums and pick "My Attachments" from the drop-down list. How can I tell an attachment is orphaned? If the PM has been deleted, you'll see a message like this in your attachment list: Unfortunately there is no message if the post has been deleted, so please check your old posts. We do purge old birthday threads every once in a while. Also some hosted projects have been shut down, so you may have orphaned attachments on one of those locations. Thanks!
Sign in to follow this  
Schtearn

PrgLnch: Yet Another Game Launcher

Recommended Posts

The last test looped 3 times so it's getting the monitorcount right? (4 message boxes in all)

Here's the script:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

w:= A_Screenwidth/2
Gui, New, +HwndhWnd
Gui, Add, Text, centre, Temp Monitor GUI:
Gui, Show, W%w%
Gui, Flash

SysGet, MonitorCount, MonitorCount
msR:= 0
msB:=0
monitorHandle := 0



	WinGetPos,x,y,w,h, ahk_id %hWnd%
	MsgBox, 8192, , Is the GUI behind this message box? `nBefore any moves, x value is %x%
	
	TargMon := GetMonitorFrmHWND(MonitorCount, msR, msB, hWnd, monitorHandle)
	x := % msR - w
	y := % msB - h
	WinMove, ahk_id %hWnd%,,%x%, %y%
	Gui, Flash
	MsgBox, 8192, , Did we move the form to the BR of current monitor # %TargMon%?`nValue of x is now %x%. `nAttempting to move form to each monitor...

loop % MonitorCount
{
	
	if (A_Index = MonitorCount)
	TargMon := 1
	else	
	TargMon := % A_Index + 1

	SysGet, ms, MonitorWorkArea, % A_Index
	SysGet, md, MonitorWorkArea, % TargMon
	mdw := mdRight - mdLeft, mdh := mdBottom - mdTop
	msw := msRight - msLeft, msh := msBottom - msTop

	; Calculate new size for new monitor.
	;dx := (TargMon > A_Index)? mdRight - w + (x-msLeft)*(mdw/msw): mdRight - w - (x-msLeft)*(mdw/msw)
	dx := mdLeft + (x-msLeft)*(mdw/msw)
	dy := mdTop + (y-msTop)*(mdh/msh)
	
	;  4 monitors!!!!!!!!!!!!!!!

	;dy := mdTop + (y-msTop)*(mdh/msh)

	w := Round(w*(mdw/msw))
	h := Round(h*(mdh/msh))

	; Move window, using resolution difference to scale co-ordinates.
	WinMove, ahk_id %hWnd%, , dx, dy, w, h
	Gui, Flash
	;move mouse
	DllCall("SetCursorPos", int, dx + w/2, int, dy + h/2)

	WinGetPos,x,y,w,h, ahk_id %hWnd%
	MsgBox, 8192, , We have attempted to move the form to the BR of the following `nMonitor: %TargMon%, having width %mdw%, and height %mdh%.
}


	
	
ExitApp	
GetMonitorFrmHWND(MonitorCount, ByRef msR, ByRef msB, hWnd, monitorHandle := 0)
{
	MONITOR_DEFAULTTONULL := 0
	VarSetCapacity(monitorInfo, 40)
	NumPut(40, monitorInfo)

	
	if (monitorHandle := DllCall("MonitorFromWindow", "uint", hWnd, "uint", MONITOR_DEFAULTTONULL)) 
		&& DllCall("GetMonitorInfo", "uint", monitorHandle, "uint", &monitorInfo) 
	{
	msLeft :=		NumGet(monitorInfo, 4, "Int")
	msTop := 		NumGet(monitorInfo, 8, "Int")
	msRight := 		NumGet(monitorInfo, 12, "Int")
	msBottom := 	NumGet(monitorInfo, 16, "Int")
	mswLeft := 		NumGet(monitorInfo, 20, "Int")
	mswTop := 		NumGet(monitorInfo, 24, "Int")
	mswRight := 	NumGet(monitorInfo, 28, "Int")
	mswBottom :=	NumGet(monitorInfo, 32, "Int")
	mswPrimary :=	NumGet(monitorInfo, 36, "Int") & 1


		; GetMonitorIndexFromWindow(windowHandle)	

		Loop, %MonitorCount%
		{
			SysGet, mt, Monitor, %A_Index%

			; Compare location to determine the monitor index.
			if ((msLeft = mtLeft) and (msTop = mtTop)
				and (msRight = mtRight) and (msBottom = mtBottom))
			{
				msR := msRight
				msB := msBottom
				msI := A_Index
				break
			}
		}

	}
if (msI)
return msI
else ; should never get here
MsgBox, 8192, , Cannot retrieve the Monitor for the current window!
return 1 ;hopefully this is the one!
}

Sysget wraps SystemParametersInfo, can't see how the driver S/W for Eyefinity is overriding the system calls for that:

Rejigged the script again, and now it calls for GUI location before moving it: TBandMonInfo.7z

Share this post


Link to post
Share on other sites

Just once, actually. Eyefinity and Nvidia Surround combine them into a single virtual screen. While X.Org on *nix has functions for this stuff, I'm not sure Windows does natively. However! I do have an idea on how it can be with wrappers without too much trouble. I'll look!

Edit:

I'm not seeing documentation on Eyefinity's developer stuff, unfortunately. :/

Edited by Visceral Moonlight

Share this post


Link to post
Share on other sites

Eyefinity and Nvidia Surround? Certainly looks as if they are not using WDDM at all. But NVAPI might have something on the NVIDIA surround thing- wonder if the folks back at AHK know about any of this.

Share this post


Link to post
Share on other sites

Thanks, yes, didn't even twig that PrgLnch logged you as having only one monitor.

Well now, it's a definite brick wall, as there appears to be quite a bit involved in even detecting an Eyefinity or NVIDIA Surround config.

Updated docs, and posted up new version.

 

 

Share this post


Link to post
Share on other sites

Might be a bit awkward without DisplayPort. Unless we start to read GPU configs. :)

Another area to be looked at is saving Windows layouts and program window positions for specified resolutions. If one runs a Prg in 800X600, temp resolution, window positions of all running apps will not revert to their original resolution, but remain at 800 wide or 600 high, if greater than 800 or 600 initially. This also requires a bit of work!

Share this post


Link to post
Share on other sites
Posted (edited)

The window positions resetting is innate to Windows, actually. It doesn't save the configuration for each resolution, instead it's per user account at a global level. It'd be nice to have the behavior of the former (I'm not sure Linux even saves them per resolution), though. Maybe something we should request from the people of their respective OS?

Edit:

For the implementation of such a thing, it'd simply be a stack:

On resolution change, push current positions into stack.

Push the new positions on to stack for the new resolution.

On changing back, pop the current ones off the stack and push onto another stack.

Pop the old ones off the stack.

It could be done with temporary variables but a stack greatly simplifies the code and makes it much cleaner. In essence, it's basically the same deal but looks nicer. :)

Or it could be done using a map of sets. This is probably the better way in case there are many resolution changes while the windows are open.

Edited by Visceral Moonlight

Share this post


Link to post
Share on other sites
Posted (edited)

Another challenge is that some browsers like Chrome have multiple windows and tabbed groups which probably also requires tapping into their APIs for an easy outcome. Although with AHK, not so easy..

Edited by Schtearn

Share this post


Link to post
Share on other sites

Okay, so we can extend my map idea for the sets to contain a map with the running programs as the key and the values being a mutliset, holding the window positions. Not something we can do ourselves, of course, but it's definitely something to keep in mind as a request for the windowing people. :)

Reading GPU configs: we found that the documentation was lacking, didn't we? Or did we want to try another approach?

Share this post


Link to post
Share on other sites

Yes, thanks. It might be possible to dump all that to the ini perhaps. Clarification of the problem in a new issue. Comments welcome, of course. :)

GPU configs? Eyes are still peeled.:P

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×