![Photo](https://secure.gravatar.com/avatar/619cb806b43e7ff77b2ec76c632995e6?s=100&d=%2F%2Fwww.autohotkey.com%2Fboard%2Fpublic%2Fstyle_images%2Fortem%2Fprofile%2Fdefault_large.png)
mouse kicks on the sreen edge
I was wondering if it is possible to trigger an action through mouse kicks on the sreen edge, similar gestures.
I thought of using a timer like SetTimer, watchmouse, 100 but it is not functional since it will uses cpu in vain most part of the time just to check mouse x and y.
is there a way to that?
(see, the idea is not gestures and all that... i need only "kicks on the sreen edge")
8-)
![mouse kicks on the sreen edge: post #1](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
![mouse kicks on the sreen edge: post #2](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
You aren't very clear as to what "action" you wish upon.
Does the action really matters?
okay.. lets say....
msgbox hey, you hit the screen edge 2 times in less than 500ms
crystal clear now!
![:D](http://www.autohotkey.com/board/public/style_emoticons/default/grin.png)
![mouse kicks on the sreen edge: post #3](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
~LButton:: MouseGetPos, X, Y, Win WinGetPos,,, W, H, A If (X < 20 || Y < 15 || W - X < 20 || H - Y < 15) MsgBox You Clicked The Edge! return
![mouse kicks on the sreen edge: post #4](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
![mouse kicks on the sreen edge: post #5](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
"Some people, when confronted with a problem, think I know, I'll use regular expressions. Now they have two problems."
- Jamie Zawinski
![mouse kicks on the sreen edge: post #6](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
![mouse kicks on the sreen edge: post #7](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Antonio França -- git.io -- github.com -- ahk4.net -- sites.google.com -- ahkscript.org
Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.
Thanks for the answers.
Yes, by kick i mean: touch the mouse on the screen edges 2x quikly, not click event, move event.
Certainly windows doesnt keep querying x & y constanly using the cpu. it uses some hardware hook/event to get notified whenever the mouse changes x or y.
Afaik, there is no MOUSE MOVE HOOK on AHK, sadly.
No way i'll set the cpu to keep quering about x & y constantly on AHK.
But thanks everyone!
![mouse kicks on the sreen edge: post #8](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
<!-- m -->http://stackoverflow... ... pplication<!-- m -->
But it would be easier if you could hit a key at the same time. Then just call MouseGetPos. Even back in Dos days there was a Dos interrupt that could be used to call user code on mouse events.
![mouse kicks on the sreen edge: post #9](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
"Some people, when confronted with a problem, think I know, I'll use regular expressions. Now they have two problems."
- Jamie Zawinski
![mouse kicks on the sreen edge: post #10](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
My Scripts are written for the latest released version of AutoHotkey.
Need a secure, accessible place to backup your stuff? Use Dropbox!
any sample with AHK? (forgive my newbieness)
thanks!
![mouse kicks on the sreen edge: post #11](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
É sempre bom ver mais uns brazucas por aqui :wink:
You can do that without a hook by using OnMessage() and MouseGetPos.
The code bellow does it with 4 1-pixel-thin windows. The called function simply gets the current mouse position and displays it in a message box. It does so only when the borders of the screen are touched. The XAddresses and YAddresses can be mathematically compared to retrieve which border was "kicked". Also, to get an idea on how to implement time checks, see A_TickCount.
Gui 2: +AlwaysOnTop -Caption Gui 2: Color, 0x000000 WidthOfGui1 := A_ScreenWidth - 1 Gui 2: Show, w1 h%A_ScreenHeight% x%WidthOfGui1% y0 Gui 2: +Owner Gui 3: +AlwaysOnTop -Caption Gui 3: Color, 0x000000 Gui 3: Show, w1 h%A_ScreenHeight% x0 y0 Gui 3: +Owner Gui 4: +AlwaysOnTop -Caption Gui 4: Color, 0x000000 Gui 4: Show, w%A_ScreenWidth% h1 x0 y0 Gui 4: +Owner Gui 5: +AlwaysOnTop -Caption Gui 5: Color, 0x000000 HeightOfGui4 := A_ScreenHeight - 1 Gui 5: Show, w%A_ScreenWidth% h1 x0 y%HeightOfGui4% Gui 5: +Owner Onmessage(0x200, "Shout") return Shout(wParam, lParam) { CoordMode, Mouse, Screen MouseGetPos, XAddress, YAddress msgbox % "XAddress: " XAddress "`n" "YAddress: " YAddress }
![:O](http://www.autohotkey.com/board/public/style_emoticons/default/shocked.png)
Best wishes.
![mouse kicks on the sreen edge: post #12](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
"What is a suitable automation? Whatever saves your day for the greater matters."
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!
![:)](http://www.autohotkey.com/board/public/style_emoticons/default/happy.png)
I have a getworkarea function but I haven't used multiple guis and am not accustomed to moving them around.
edit: those who autohide taskbar may not care. But it would be nice to periodically check the work area for change and accommodate for those who don't use autohide. I have this preliminary code.
edit2: (one would think it better to get notification of work area change. I tried it in another app and it doesn't work. I also saw MSDN articles where it didn't work as documented. Screen res change notification worked fine. But work area change notification was useless.. that's why the polling approach. )
L1 := 0, L2 := 0, T1 := 0, T2 := 0, R1 := 0, R2 := 0, B1 := 0, B2 := 0 _GetWorkArea(L2,T2,R2,B2) L1 := L2, T1 := T2, R1 := R2, B1 := B2 ; your code that creates and shows the guis here should use work are info ; then poll however often for work area change .. 10 seconds to try it SetTimer,WorkAea,10000 Onmessage(0x200, "Shout") return WorkAea: _GetWorkArea(L2,T2,R2,B2) if (L1 != L2) ; Taskbar moved to left edge .. move gui else if (T1 != T2) ; Taskbar moved to top ... else if (R1 != R2) ; Taskbar moved to right edge ... else if (B1 != B2) ; Taskbar moved to bottom ; copy work area info to check for change next ; timer trigger L1 := L2, T1 := T2, R1 := R2, B1 := B2 ; set it back to long polling period ; presumably if you get an edge hit you would ; shorten the polling for one go to fix it during the ; time the user is kicking it if unresponsive on one edge.. maybe 1/4 sec. SetTimer,WorkAea,10000 return _GetWorkArea(ByRef left, ByRef top, ByRef right, ByRef bottom) { VarSetCapacity(work_area,16,0) success := DllCall( "SystemParametersInfo", "uint", 0x30, "uint", 0, "uint", &work_area, "uint", 0 ) if success = { return 0 } left := NumGet(work_area,0) top := NumGet(work_area,4) Right := NumGet(work_area,8) Bottom := NumGet(work_area,12) return 1 } Shout(wParam, lParam) { ; do shout code then check for work area change SetTimer,WorkAea,250 }
![mouse kicks on the sreen edge: post #13](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
"Some people, when confronted with a problem, think I know, I'll use regular expressions. Now they have two problems."
- Jamie Zawinski
Something like this works even out of Scite
#SingleInstance force L1 := 0, L2 := 0, T1 := 0, T2 := 0, R1 := 0, R2 := 0, B1 := 0, B2 := 0 _GetWorkArea(L2,T2,R2,B2) L1 := L2, T1 := T2, R1 := R2, B1 := B2 Gui 2: +AlwaysOnTop -Caption Gui 2: Color, 0x000000 WidthOfGui1 := A_ScreenWidth - 1 Gui 2: Show, w1 h%A_ScreenHeight% x%WidthOfGui1% y0 Gui 2: +Owner Gui 3: +AlwaysOnTop -Caption Gui 3: Color, 0x000000 Gui 3: Show, w1 h%A_ScreenHeight% x0 y0 Gui 3: +Owner Gui 4: +AlwaysOnTop -Caption Gui 4: Color, 0x000000 Gui 4: Show, w%A_ScreenWidth% h1 x0 y0 Gui 4: +Owner Gui 5: +AlwaysOnTop -Caption Gui 5: Color, 0x000000 HeightOfGui4 := A_ScreenHeight - 1 Gui 5: Show, w%A_ScreenWidth% h1 x0 y%HeightOfGui4% Gui 5: +Owner SetTimer,WorkAea,3000 Onmessage(0x200, "Shout") return WorkAea: _GetWorkArea(L2,T2,R2,B2) if (L1 != L2) or (T1 != T2) or (R1 != R2) or (B1 != B2) Reload return Shout(wParam, lParam) { CoordMode, Mouse, Screen MouseGetPos, Xaddress, Yaddress If (Xaddress = 0) MsgBox, 8256, , You Kicked Left Edge else if (Yaddress = 0) MsgBox, 8256, , You Kicked Top Edge else if (Xaddress = A_ScreenWidth - 1) MsgBox, 8256, , You Kicked Right Edge else if ( Yaddress = A_ScreenHeight - 1) MsgBox, 8256, , You Kicked Bottom Edge } _GetWorkArea(ByRef left, ByRef top, ByRef right, ByRef bottom) { VarSetCapacity(work_area,16,0) success := DllCall( "SystemParametersInfo", "uint", 0x30, "uint", 0, "uint", &work_area, "uint", 0 ) if success = { return 0 } left := NumGet(work_area,0) top := NumGet(work_area,4) Right := NumGet(work_area,8) Bottom := NumGet(work_area,12) return 1 }
![mouse kicks on the sreen edge: post #14](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
"Some people, when confronted with a problem, think I know, I'll use regular expressions. Now they have two problems."
- Jamie Zawinski
![:)](http://www.autohotkey.com/board/public/style_emoticons/default/happy.png)
I was wondering if it is possible to trigger an action through mouse kicks on the sreen edge, similar gestures.
Have you checked Shirubadappuru's MouseGestureL?
Just in case you are interested in triggering actions with mouse movements.
![mouse kicks on the sreen edge: post #15](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
"What is a suitable automation? Whatever saves your day for the greater matters."
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!