AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

passing all events from one window to other one (crosshair)

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
robf
Guest





PostPosted: Mon Feb 21, 2005 4:47 pm    Post subject: passing all events from one window to other one (crosshair) Reply with quote

I have modified the ruler script to create a crosshair at the
mouse position. Unfortunately clicks/key presses do not get
passed to the window under the rulers anymore, but they are
swallowed by the rulers. This can be prevented by shifting the
rulers by one pixel away from the mouse cursor, but I do not
want this.

Is there any other and easy way to pass the events to the window
below the rulers?

Code:

SetWinDelay, -1

~CapsLock::
  if A_PriorHotkey <> ~CapsLock
  {
     KeyWait, CapsLock
     return
  }
  if A_TimeSincePriorHotkey > 400
  {
     KeyWait, CapsLock
     return
  }
  if CrossHair <> on
  {
     SetTimer,CrossHair,0
  }
  else
  {
     SetTimer,CrossHair,Off
     CrossHair = Off
     Splashimage,3:Off
     Splashimage,4:Off
  }
Return

CrossHair:
   Coordmode, Mouse, Screen
   MouseGetPos,RulerX, RulerY
   ; if we leave it at the mouse position clicks do not get passed
   ; to the window underneath
   ;RulerX -= 1
   ;RulerY -= 1
   if CrossHair <> on
   {
     ;; we use two images denoted by :3 and :4
     Splashimage,3:, B H1 W%A_ScreenWidth% X0 Y%RulerY% CWcc9900,,,ScreenRulerY
     Splashimage,4:, B H%A_ScreenHeight% W1 X%RulerX% Y1 CWcc9900,,,ScreenRulerX
     WinSet,Transparent,125,ScreenRulerY
     WinSet,Transparent,125,ScreenRulerX
   }
   else
   {
     WinMove, ScreenRulerY,,,%RulerY%
     WinMove, ScreenRulerX,,%RulerX%
   }
   CrossHair = on
return
Back to top
Pallie



Joined: 05 Jul 2004
Posts: 57
Location: London

PostPosted: Mon Feb 21, 2005 9:51 pm    Post subject: Reply with quote

I tried adding the following to the end of the script.
Code:
$LButton::
  WinSet,TransColor, cc9900,ScreenRulerY
  WinSet,TransColor, cc9900,ScreenRulerX
  mouseclick,  left
  WinSet,TransColor, off, ScreenRulerY
  WinSet,TransColor, off, ScreenRulerX
Return


The idea is that when you click, it makes the lines transparent (click through) to do the click but then undoes the transparency. It works a bit but I think the timer is getting in the way, but maybe you could turn off the timer for the same period of time. Click and drag is a bit dodgy though!
Back to top
View user's profile Send private message
jonny



Joined: 13 Nov 2004
Posts: 3004
Location: Minnesota

PostPosted: Mon Feb 21, 2005 10:04 pm    Post subject: Reply with quote

If you're gonna mess with the gui, why not just move it one pixel to the left and down (or whatever direction strikes your fancy), then send the click through? Seems like it'd be faster than messing with transparecnies...
Back to top
View user's profile Send private message
robf
Guest





PostPosted: Tue Feb 22, 2005 10:19 am    Post subject: Reply with quote

Pallie wrote:
I tried adding the following to the end of the script.
Code:
$LButton::
  WinSet,TransColor, cc9900,ScreenRulerY
  WinSet,TransColor, cc9900,ScreenRulerX
  mouseclick,  left
  WinSet,TransColor, off, ScreenRulerY
  WinSet,TransColor, off, ScreenRulerX
Return


The idea is that when you click, it makes the lines transparent (click through) to do the click but then undoes the transparency. It works a bit but I think the timer is getting in the way, but maybe you could turn off the timer for the same period of time. Click and drag is a bit dodgy though!


Well I tried it in a similar way, the problem is:

1. You cannot drag anymore
2. You would have to bind ALL buttons/keys you want to get through

Robert
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Tue Feb 22, 2005 10:31 am    Post subject: Reply with quote

In the future, there should be a way for a window to be notified of all clicks within its boundaries. Hopefully that would help.
Back to top
View user's profile Send private message Send e-mail
robf
Guest





PostPosted: Tue Feb 22, 2005 10:54 am    Post subject: Reply with quote

Chris wrote:
In the future, there should be a way for a window to be notified of all clicks within its boundaries. Hopefully that would help.


Cool, in the mean time I solved it by simply creating four rulers and leaving the point under the mouse uncovered ... well calculations could
be a bit more compact Wink

Code:
SetWinDelay, -1

~CapsLock::
  if A_PriorHotkey <> ~CapsLock
  {
     KeyWait, CapsLock
     return
  }
  if A_TimeSincePriorHotkey > 400
  {
     KeyWait, CapsLock
     return
  }
  if CrossHair <> on
  {
     SetTimer,CrossHair,0
  }
  else
  {
     SetTimer,CrossHair,Off
     CrossHair = Off
     Splashimage,3:Off
     Splashimage,4:Off
     Splashimage,5:Off
     Splashimage,6:Off
  }
Return

CrossHair:
   Coordmode, Mouse, Screen
   MouseGetPos,X,Y
   X1 = 0
   W1 = %X%
   W1 -= 10
   X2 = %X%
   X2 += 10
   W2 = %A_ScreenWidth%
   W2 -= %X%
   W2 -= 10
   Y1 = 0
   H1 = %Y%
   H1 -= 10
   Y2 = %Y%
   Y2 += 10
   H2 = %A_ScreenHeight%
   H2 -= %Y%
   H2 -= 10

   if CrossHair <> on
   {
     ;; we use two images denoted by :3 and :4
     Splashimage,3:, B H1 W%W1% X%X1% Y%Y% CWcc9900,,,ScreenRulerX1
     Splashimage,4:, B H1 W%W2% X%X2% Y%Y% CWcc9900,,,ScreenRulerX2
     Splashimage,5:, B H%H1% W1 X%X% Y%Y1% CWcc9900,,,ScreenRulerY1
     Splashimage,6:, B H%H2% W1 X%X% Y%Y2% CWcc9900,,,ScreenRulerY2
     WinSet,Transparent,125,ScreenRulerX1
     WinSet,Transparent,125,ScreenRulerX2
     WinSet,Transparent,125,ScreenRulerY1
     WinSet,Transparent,125,ScreenRulerY2
   }
   else
   {
     WinMove, ScreenRulerX1,,%X1%,%Y%,%W1%
     WinMove, ScreenRulerX2,,%X2%,%Y%,%W2%
     WinMove, ScreenRulerY1,,%X%,%Y1%,,%H1%
     WinMove, ScreenRulerY2,,%X%,%Y2%,,%H2%
   }
   CrossHair = on
return
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group