StrokesPlus Forum
                       
StrokesPlus Forum
Home | Profile | Register | Active Topics
Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Lua Scripts
 General Action Scripts
 script code to move Window to monitor of the mouse
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ycomp

14 Posts

Posted - 02/09/2016 :  08:33:11  Show Profile  Reply with Quote
sorry for the title, the Subject wouldn't allow for longer.

I have a problem with Chrome. I have a V gesture that opens a new chrome window.

Works great.

The Only problem is that it tends to open the chrome window on the monitor where the last chrome window is displayed. Since I have a chrome window sitting on my second monitor for reference purposes at all times, often I'm drawing the V on the main monitor but chrome pops up on the secondary monitor and then I have drag it to the main monitor.

here is my current code, how could I modify it to detect the mouse monitor and move the window there?

--- Chrome Launch Code ---
function chrome(reposition)

	--acShellExecute("open", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", "--new-window --window-size=1300,1080 --window-position=0,0", "", 1) --sample opens the Windows folder
	acShellExecute("open", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", "--new-window", "", 1) --sample opens the Windows folder

	if (not reposition) then
		return 
	end

	--minimizeDashboard()

	-- TRY to reposition and resize window in the first 200ms
	acDelay(200)
	AttemptRepositonAndResize()

	-- VERIFY that it has been properly positioned,
	-- if not then reposition and resize it
	acDelay(200)

	AttemptRepositonAndResize()


	acDelay(200)

	AttemptRepositonAndResize()

	acDelay(200)

	AttemptRepositonAndResize()

end

ycomp

14 Posts

Posted - 02/09/2016 :  08:35:37  Show Profile  Reply with Quote

function AttemptRepositonAndResize()
 
	--h = acGetForegroundWindow()
	h = acFindWindowByTitleRegex("New Tab - Google Chrome")

	s = acGetWindowTitle(h, 0, 0)
	--acMessageBox(s, s, 0)
	if s == "New Tab - Google Chrome" then
		acSetWindowSize(h, 0, 0, 1073, 1080, 0, 0)
		acMoveWindow(h, 0, 0, 848, 0)
	end

end
Go to Top of Page

Rob

USA
2538 Posts

Posted - 02/09/2016 :  22:01:56  Show Profile  Visit Rob's Homepage  Reply with Quote
This works on my machine, obviously you can tweak it accordingly:
acShellExecute("open", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", "--new-window", "", 1) 
acDelay(300)
h = acFindWindowByTitleRegex("New Tab - Google Chrome")
acRestoreWindow(h, nil, nil) 
acSendWindowToMonitorByHandle(h, nil, nil, acGetMonitorFromPoint(gsx, gsy)) --Send it to the monitor where the gesture started
acMaximizeWindow(h, nil, nil)
Go to Top of Page

ycomp

14 Posts

Posted - 02/11/2016 :  10:45:57  Show Profile  Reply with Quote
thanks for the help, I'll give it a go.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000