Jump to content

Capture click position on desktop


Recommended Posts

G'day everyone

I'm fiddling with a sliding toolbar script:

#include <GUIConstants.au3>

$mainwindow = GUICreate("LB", 100, 500)
GUICtrlCreateLabel("LauncherBar", 20, 10)

WinSetOnTop("LB", "", 1)

GUISwitch($mainwindow)
GUISetState(@SW_SHOW)

$mposq = 1
$lbmid = @DesktopHeight - (@DesktopHeight/2) - 250

While 1
$msg = GUIGetMsg(1)

Select

Case $msg[0] = $GUI_EVENT_PRIMARYDOWN
$mpos = MouseGetPos()
If $mpos[0] = @DesktopWidth-1 Then
If $mposq = 1 Then
WinMove ("LB", "", @DesktopWidth-1, $lbmid)
$mposq = 0
ElseIf $mposq = 0 Then
WinMove ("LB", "", @DesktopWidth-99, $lbmid)
$mposq = 1
EndIf
EndIf

Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $mainwindow 
ExitLoop

EndSelect

WEnd

If you drag the toolbar to the right side of the screen, and release your mousebutton, it slides away leaving just a 1 pixel vertical line. Click that line, and the toolbar comes back. Click the edge of the screen again, and the toolbar goes away again, etc.

This is all fine, but I'd like the toolbar to be restored not to the edge of the screen, but to any other position on the screen (eg as the middle of it). I can get it to restore to the middle of the screen, but then I can't get it to slide away again by simply clicking the side of the screen (I have to drag the toolbar back to the edge of the screen). This is because the mouseclick is captures only if the click occurs on the toolbar (not elsewhere on the screen). So, how can I capture a mouseclick at the edge of the screen (either the desktop of any othe window which is maximised at that stage)?

I have a kludge solution: create a dummy toolbar (a second toolbar) which resides at the very edge of the screen even when the main toolbar is in the middle of the screen, and have that second toolbar capture the mouseclick. I'm good at coming with kludge solutions... but I'd like to keep things simple.

Any ideas?

Thanks

Samuel

Edited by leuce
Link to comment
Share on other sites

Hi,

could you please explain it 2 sentences whats your prob. I don't get it. :">

Thanks!

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Could you please explain it 2 sentences whats your prob. I don't get it.

Two sentences? Sheesh :-)

I have a GUI window called $mainwindow somewhere on my desktop. When I click on the very righthand edge of my screen (or in the top-right corner, for example), I want $mainwindow to move somewhere else.

Half of the time, the window $mainwindow will not be under the mouse cursor when I click (some other window will be under it, or sometimes no window will be under it), but the other half of the time, it will be under the mouse cursor when I click.

I hope this helps...

PS I've changed the word "slider" in Post #1 to "sliding" because I realised that "slider" is also the name of a GUI control.

Edited by leuce
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...