Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Focus() to area on screen


  • Please log in to reply
14 replies to this topic
Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
WARNING: This is old thread. It is continued here.

Click & drag to select area on screen on which you want to focus. Click again to go back to normal view.
Still not polished (it's too late, I'm going to sleep), but here it is;

MButton::Focus()

Focus(Options="") {	; by Learning one. Click & drag to select area on screen on which you want to focus. Click again to go back to normal view. Updated 08.03.2014.
	; http://www.autohotkey.com/board/topic/60727-focus-to-area-on-screen/
	; Examples:
	;	MButton::Focus()
	;	MButton::Focus("cGreen t200 g44")
	;	MButton::Focus("mffffff t255")
	static State := 0
	CoordMode, Mouse, Screen
	MouseGetPos, MX, MY
	ActiveWinID := WinExist("A")
	loop, parse, Options, %A_Space%
	{
		Field := A_LoopField, FirstChar := SubStr(Field,1,1)
		if FirstChar contains c,t,g,m
		{
			StringTrimLeft, Field, Field, 1
			%FirstChar% := Field
		}
	}
	c := (c = "") ? "Blue" : c, m := (m = "") ? 000000 : m, t := (t = "") ? "240" : t, g := (g = "") ? "99" : g
	if (state = 1) {
		Gui %g%: Destroy
		state := 0 
		return
	}
	state := 1
	Gui %g%: Destroy
	Gui %g%: +AlwaysOnTop -caption +Border +ToolWindow +LastFound
	WinSet, Transparent, 50
	Gui %g%: Color, %c%
	Hotkey := RegExReplace(A_ThisHotkey, (A_IsUnicode = 1) ? "(*UCP)^(\w* & |\W*)" : "^(\w* & |\W*)")
	While, (GetKeyState(Hotkey, "p") = 1) {
		Sleep, 20
		MouseGetPos, MXend, MYend
		w := abs(MX - MXend), h := abs(MY - MYend)
		X := (MX < MXend) ? MX : MXend
		Y := (MY < MYend) ? MY : MYend
	    Gui %g%: Show, x%X% y%Y% w%w% h%h% NA
	}
	Gui %g%: Destroy
	MouseGetPos, MXend, MYend
	If (MX > MXend)
		temp := MX, MX := MXend, MXend := temp
	If (MY > MYend)
		temp := MY, MY := MYend, MYend := temp
	area := MX "|" MY "|" MXend "|" MYend
	StringSplit, v, area, |
	Coords := v1 "-" v2 A_Space v3 "-" v2 A_Space v3 "-" v4 A_Space v1 "-" v4 A_Space v1 "-" v2
	Gui %g%: Margin , 0, 0
	Gui %g%: -Caption +ToolWindow +AlwaysOnTop +LastFound
	Gui %g%: Color, % m	
	WinSet, Transparent, %t%
	WinSet, ExStyle, +0x20	; click through
	WinSet, Region, 0-0 %A_ScreenWidth%-0 %A_ScreenWidth%-%A_ScreenHeight% 0-%A_ScreenHeight% 0-0  %Coords%
	Gui %g%: Show, NA Maximize
	
	WinActivate, ahk_id %ActiveWinID%
	Gui %g%: +AlwaysOnTop
}
License: public domian

x79animal
  • Members
  • 1021 posts
  • Last active: May 14 2013 04:21 PM
  • Joined: 01 May 2010
i dont see the use in this allthough blocking out the taskbar should be in there as its distracting (flash games or something)

TomXIII
  • Members
  • 182 posts
  • Last active: Feb 28 2011 11:42 PM
  • Joined: 14 Apr 2009
Hi!

Not bad at all but maybe you should create another hotkey to change the opacity.
I've done a script like this when I had my blog. The script was called BlackScreen but I don't remember where it is!

PS: I studying RM Launcher + Mouse Gesture. There are a lot of changes since the last time I looked over!

Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
I remember somebody wanted something like this... so I made is just for fun...

@TomXIII: also take a look at the RM2module- it's the main engine of Radial menu 4 application.
btw, in latest Ini4Ahkl_v5.ahk, I get error in line 205 - illegal character. Code: Loop, Parse, KeyVal["Value"], CSV
Maybe something like this. Code:
ToParse := KeyVal["Value"]
Loop, Parse, ToParse, CSV


and in Sample_v5.ahk
#Include, %A_ScriptDir%\Ini4Ahkl.ahk should be #Include, %A_ScriptDir%\Ini4Ahkl_v5.ahk

Other than that, nice & useful work :wink:

TomXIII
  • Members
  • 182 posts
  • Last active: Feb 28 2011 11:42 PM
  • Joined: 14 Apr 2009
Thx for the reported bugs.
I did'nt track bug enough before posting the code on ahk.net.
I'll work on it this week-end, I promise!

Wicked - Guest
  • Guests
  • Last active:
  • Joined: --
Learning One... Can I be completely honest here?


That... Was just... Freaking awesome!


Was just watching a movie online last night while trying to keep an eye on something else on my screen at the same time. This could have come in quite handy, as the other thing was quite bright and overpowering. >.<.


Kudos! =).

closed
  • Members
  • 509 posts
  • Last active: Jan 14 2012 06:14 PM
  • Joined: 07 Feb 2008
Wooow...!!!!

Every time i look at youtube (anime!!!) i think it would be great to have this but never got to work on it .

(The +E0x20 is a live saver!)

Thanks !

Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
:)

tomoe_uehara
  • Members
  • 2166 posts
  • Last active: Jun 11 2015 05:33 PM
  • Joined: 05 Sep 2009
Wow, great scipt, I like it! :wink:
I tweaked it a little so I can change the transparency with my mouse

MButton::Focus()

Focus(Options="") {   ; by Learning one 
   [color=red]Trans = 210[/color]
   static State 
   CoordMode, Mouse, Screen 
   MouseGetPos, MX, MY 
   ActiveWinID := WinExist("A") 
   loop, parse, Options, %A_Space% 
   { 
      Field := A_LoopField 
      FirstChar := SubStr(Field,1,1) 
      if FirstChar contains c,t,g,m 
      { 
         StringTrimLeft, Field, Field, 1 
         %FirstChar% := Field 
      } 
   } 
   c := (c = "") ? "Blue" : c, t := (t = "") ? "50" : t, g := (g = "") ? "99" : g , m := (m = "") ? "s" : m 
   if state 
   { 
      Gui %g%: Destroy 
      state = 
      return 
   } 
   state = 1 
   Gui %g%: Destroy 
   Gui %g%: +AlwaysOnTop -caption +Border +ToolWindow +LastFound 
   WinSet, Transparent, %t% 
   Gui %g%: Color, %c% 
   Hotkey := RegExReplace(A_ThisHotkey,"^(\w* & |\W*)") 
   While, (GetKeyState(Hotkey, "p")) 
   { 
      Sleep, 10 
      MouseGetPos, MXend, MYend 
      w := abs(MX - MXend), h := abs(MY - MYend) 
      X := (MX < MXend) ? MX : MXend 
      Y := (MY < MYend) ? MY : MYend 
       Gui %g%: Show, x%X% y%Y% w%w% h%h% NA 
   } 
   Gui %g%: Destroy 
   MouseGetPos, MXend, MYend 
   If ( MX > MXend ) 
   temp := MX, MX := MXend, MXend := temp 
   If ( MY > MYend ) 
   temp := MY, MY := MYend, MYend := temp 
   area := MX "|" MY "|" MXend "|" MYend 
   StringSplit, v, area, | 
   Coords = %v1%-%v2%  %v3%-%v2% %v3%-%v4% %v1%-%v4%       %v1%-%v2% 
   Gui %g%: Margin , 0, 0 
   Gui %g%: -Caption +AlwaysOnTop +LastFound 
   Gui %g%: Color, 000000 
   Gui %g%: Show, Maximize, [color=red]Focus[/color]
   WinSet, Transparent, %Trans%
   WinSet, ExStyle, +0x20   ; click through 
   WinSet, Region, 0-0 %A_ScreenWidth%-0 %A_ScreenWidth%-%A_ScreenHeight% 0-%A_ScreenHeight% 0-0  %Coords% 
   WinActivate, ahk_id %ActiveWinID%
}

[color=red]~RButton & WheelDown::
Trans-=20
Winset, Transparent, %Trans%, Focus
return

~RButton & WheelUp::
Trans+=20
Winset, Transparent, %Trans%, Focus
return[/color]


Wicked
  • Members
  • 504 posts
  • Last active: Jun 14 2014 06:04 PM
  • Joined: 07 Jun 2008
Thank you for the idea, Learning One!

I've tweaked it the way I like it and it suits my needs. Whether outher people will like it as well is up to them but I'll share it. =).

CoordMode, Mouse, Screen 
SetBatchLines, -1
SetWinDelay, -1

Loop, 4
{
	Gui, %A_Index%: -Caption +AlwaysOnTop +ToolWindow +LastFound
	WinSet, Transparent, 200
	WinSet, ExStyle, +0x20
	Gui, %A_Index%: Color, Red
}

Gui, 99: -Caption +AlwaysOnTop +LastFound +ToolWindow
WinSet, Transparent, 0 
WinSet, ExStyle, +0x20
Gui, 99: Color, Black
Gui, 99: Show, Maximize, Focus

MButton::
	Focus()
Return

Focus() {
	Static S
	I := Gui_ID(99)
	If S
	{
		Loop, 20
		{
			WinSet, Transparent, % 200 - A_Index * 10, % "ahk_id " I
			Sleep (10)
		}
		S =
		Return
	}
	H := RegExReplace(A_ThisHotkey,"^(\w* & |\W*)")
	MouseGetPos, X, Y
	While, GetKeyState(H, "p") 
	{
		MouseGetPos, X2, Y2
		gW := Abs(X - X2), gH := Abs(Y - Y2)
		gX := (X < X2) ? X : X2, gY := (Y < Y2) ? Y : Y2
		Gui, 1: Show, % "x" gX " y" gY " w" gW " h1 NoActivate" ;Top vertical
		Gui, 2: Show, % "x" gX " y" gY " w1 h" gH " NoActivate" ;Left horizontal
		Gui, 3: Show, % "x" gX " y" gY + gH " w" gW " h1 NoActivate" ;Bottom vertical
		Gui, 4: Show, % "x" gX + gW " y" gY " w1 h" gH " NoActivate" ;Right horizontal
	}
	Loop, 4
	{
		Gui, %A_Index%: Show, w1 h1 NoActivate ;Oddly needs to be done...
		Gui, %A_Index%: Hide
	}
	If(gW < 40 || gH < 40)
		Return
	X := (X < X2) ? X : X2, Y := (Y < Y2) ? Y : Y2
	X2 := X + gW, Y2 := Y + gH
	WinSet, Region, 0-0 %A_ScreenWidth%-0 %A_ScreenWidth%-%A_ScreenHeight% 0-%A_ScreenHeight% 0-0 %X%-%Y% %X2%-%Y% %X2%-%Y2% %X%-%Y2% %X%-%Y%, % "ahk_id " I
	Loop, 20
	{
		WinSet, Transparent, % A_Index * 10, % "ahk_id " I
		Sleep (10)
	}
	S := True
}

Gui_ID(N) {
	Gui, %N%: +LastFound
	Return WinExist()
}

3nL8f.png


Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
@tomoe_uehara: nice and useful tweak :) @Wicked: cool tweak 8) + cool signature 8)

Do with the code whatever you want. I have no interest to polish it. After all, I declared it public domain.

SoggyDog
  • Members
  • 803 posts
  • Last active: Mar 04 2013 06:27 AM
  • Joined: 02 May 2006
I haven't reviewed the mods, but the original script doesn't handle multiple monitor setups.

[edit]
@Wicked
Wicked Logo!

Wicked
  • Members
  • 504 posts
  • Last active: Jun 14 2014 06:04 PM
  • Joined: 07 Jun 2008

[edit]
@Wicked
Wicked Logo!


Thanks. =).

3nL8f.png


tomoe_uehara
  • Members
  • 2166 posts
  • Last active: Jun 11 2015 05:33 PM
  • Joined: 05 Sep 2009
Wow, nice fade-in and out 8)

Cragaha
  • Members
  • 265 posts
  • Last active: Jan 04 2016 02:24 AM
  • Joined: 19 Nov 2010
Very nice Learning one :)