ddh819 wrote:
@nick: works pretty well! I use a dual monitor setup though, and when the gui is "off" it shows up on the right side of my secondary monitor. How do I change where the gui hides?
Maybe:
Code:
#NoEnv
#SingleInstance force
SetBatchLines, -1
SendMode, Input
CoordMode, Mouse, Screen
DetectHiddenWindows, On
; ------------------------------------------------------------------------------
; Idle time to show the gui
Check_Time := 2000
; Idle time to click on gui
Watch_Time := 1500
; Transparency
Trans := 190
; Mouse buttons down state
M_State:= ""
; Timer state
T_State := "On"
; Tooltip text
T_Tip := ""
; Ini file
Ini_File := A_ScriptDir . "\Clicker.ini"
; Gui's "hiding" position
XH := 0
YH := 0
; Virtual screen's width and height
VW := A_ScreenWidth
VH := A_ScreenHeight
; ------------------------------------------------------------------------------
If (!FileExist(Ini_File)) {
IniWrite, %Check_Time%, %Ini_File%, Clicker, Check_Time
IniWrite, %Watch_Time%, %Ini_File%, Clicker, Watch_Time
IniWrite, %Trans%, %Ini_File%, Clicker, Transparency
}
IniRead, Check_Time, %Ini_File%, Clicker, Check_Time, %Check_Time%
IniRead, Watch_Time, %Ini_File%, Clicker, Watch_Time, %Watch_Time%
IniRead, Trans, %Ini_File%, Clicker, Transparency, %Trans%
If (A_OSVersion <> "WIN_NT4" And A_OSVersion <> "WIN_95") {
SysGet, XH, 76
SysGet, YH, 77
SysGet, VW, 78
SysGet, VH, 79
}
W_ID := WinExist("A")
GoSub, Create_Gui
MouseGetPos, YM, YM
SetTimer, Check_Mouse, On
WinActivate, ahk_id %W_ID%
Return
; ------------------------------------------------------------------------------
; Create gui
Create_Gui:
Gui, Destroy
Gui, +ToolWindow
Gui, Margin, 0, 0
Gui, Font, , Verdana
Gui, Add, Button, x0 y0 h20 w100 0x200 Center gClick_L, Click left
Gui, Add, Button, xm y+0 hp wp 0x200 Center gClick_D, Doubleclick
Gui, Add, Button, xm y+0 hp wp 0x200 Center gClick_R, Click right
Gui, Add, Button, xm y+0 hp wp 0x200 Center gClick_M, Click middle
Gui, Add, Button, xm y+0 hp wp 0x200 Center gLeft_D, Left down
Gui, +LastFound
WinSet, Transparent, 0
Gui, -Caption
Gui, Show, AutoSize
WinGetPos, , , WW, WH
XH -= WW
YH -= WH
WinMove, XH, YH
WinSet, Transparent, %Trans%
Return
; ------------------------------------------------------------------------------
; Escape was pressed
GuiEscape:
Gui, +LastFound
WinMove, XH, YH
SetTimer, Tool_Tip, Off
SetTimer, Watch_Mouse, Off
SetTimer, Check_Mouse, On
Return
; ------------------------------------------------------------------------------
; Click left
Click_L:
Gui, +LastFound
WinMove, XH, YH
WinActivate, ahk_ID %W_ID%
MouseMove, XM, YM
Click
Return
; ------------------------------------------------------------------------------
; Doubleclick
Click_D:
Gui, +LastFound
WinMove, XH, YH
WinActivate, ahk_ID %W_ID%
MouseMove, XM, YM
Click 2
Return
; ------------------------------------------------------------------------------
; Click right
Click_R:
Gui, +LastFound
WinMove, XH, YH
WinActivate, ahk_ID %W_ID%
MouseMove, XM, YM
Click R
Return
; ------------------------------------------------------------------------------
; Click middle
Click_M:
Gui, +LastFound
WinMove, XH, YH
WinActivate, ahk_ID %W_ID%
MouseMove, XM, YM
Click M
Return
; ------------------------------------------------------------------------------
; Click left and hold down
Left_D:
Gui, +LastFound
WinMove, XH, YH
WinActivate, ahk_ID %W_ID%
MouseMove, XM, YM
Click Down
M_State := "L"
T_Tip := "Left down"
SetTimer, Tool_Tip, 50
Return
; ------------------------------------------------------------------------------
; Check mouse movement
Check_Mouse:
If (A_TimeIdle > Check_Time) {
If (M_State) {
Click %M_State% Up
M_State := ""
SetTimer, Tool_Tip, Off
ToolTip
Return
}
MouseGetPos, X1, Y1
If (X1 = XM And Y1 = YM) {
Return
}
SetTimer, Check_Mouse, Off
W_ID := WinExist("A")
XM := X1, YM := Y1
XW := (X1 + WW) > VW ? X1 - WW : X1
YW := (Y1 + WH) > VH ? Y1 - WH : Y1
Gui, +LastFound
WinSet, AlwaysOnTop, On
WinMove, %XW%, %YW%
WinGetPos, X, Y, W, H
MouseMove, 0, 1, , R
MouseMove, 0, -1, , R
SetTimer, Watch_Mouse, On
}
Return
; ------------------------------------------------------------------------------
; Watch mouse movement on gui
Watch_Mouse:
Gui, +LastFound
MouseGetPos, X2, Y2
If (X2 < X Or X2 > (X + W) Or Y2 < Y Or Y2 > (Y + H)) {
WinMove, XH, YH
SetTimer, Watch_Mouse, Off
SetTimer, Check_Mouse, On
Return
}
If (A_TimeIdle > Watch_Time) {
If (X2 <> X1 And Y2 <> Y1) {
Click
} Else {
WinMove, XH, YH
WinActivate, ahk_ID %W_ID%
}
SetTimer, Watch_Mouse, Off
SetTimer, Check_Mouse, On
Return
}
Return
; ------------------------------------------------------------------------------
; ToolTip follows mouse
Tool_Tip:
ToolTip, %T_Tip%
Return
; ------------------------------------------------------------------------------
; Stop/Start timer Check_Mouse
CapsLock & a::
KeyWait, Capslock
T_State := T_State = "On" ? "Off" : "On"
SetTimer, Tool_Tip, Off
SetTimer, Watch_Mouse, Off
SetTimer, Check_Mouse, %T_State%
Return
; ------------------------------------------------------------------------------
; ExitApp
Capslock & q::
KeyWait, Capslock
SetTimer, Tool_Tip, Off
SetTimer, Watch_Mouse, Off
SetTimer, Check_Mouse, Off
Gui, Destroy
ExitApp
I couldn't test, I have only one!
