AutoHotkey Community

It is currently May 27th, 2012, 11:03 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: no-click interface
PostPosted: March 28th, 2007, 4:23 pm 
Offline

Joined: December 27th, 2006, 7:44 pm
Posts: 22
here's an interesting idea for an ahk script, a mouse app that lets you "click" by just pausing the mouse:

http://www.extremetech.com/article2/0,1 ... X1K0000532

whenever you stop the mouse, it brings up a menu for what to do, left-click, right-click, double click, mouse-down, release, but you don't actually do any clicking yourself.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 28th, 2007, 6:55 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8667
Location: Salem, MA
it's not done yet, but here's what I have so far. I think I have most of it working, but my only bug is that it doesn't click in the right spot, but I should have that worked out later. I just wanted to post my prototype.

Code:
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.

coordmode, pixel
Settimer whereisthemouse, 100
menushown = 0
held=0

return

whereisthemouse:
  MouseGetPos, Xpos, Ypos
  If(Xpos<>StoredXpos or Ypos<>StoredYpos ) {
    ;mouse moved
    StoredXpos := Xpos
    StoredYpos := Ypos
    stillcounter = 0
  } else {
    ;mouse didn't move
    stillcounter++
  }

  If(stillcounter>12) {
    ;stayed in place for 1.2 seconds
   if(A_TimeIdlePhysical>1000) {     ;so the menu won't pop up when you are typing
    if(menushown = 0){
      ;remember where to click
      TargetXpos := StoredXpos
      TargetYpos := StoredYpos
      StoredXpos+=85
      StoredYpos+=100

      ;show menu of clicks
      if(held=0) {
   menutext = L  M  R `nL2 M2 R2`nLD MD RD
        updown = down
      } else {
   menutext = L  M  R `nL2 M2 R2`nLU MU RU
        updown = up
      }

      Progress, m2 b fs14 zh0 x%StoredXpos% y%StoredYpos% w120, %menutext%, , , Courier New

      menushown = 1
    } else {
      ;click on the menu only, then do what it says
      Xdiff := StoredXpos - TargetXpos
      Ydiff := StoredYpos - TargetYpos
      Tooltip, X:%Xdiff%`nY:%Ydiff%,20, 20
      If( Xdiff>10 and Xdiff<38 and Ydiff>10 and Ydiff<27)
        Clickon(%TargetXpos%,%TargetYpos%,"left")
      If( Xdiff>42 and Xdiff<72 and Ydiff>10 and Ydiff<27)
        Clickon(%TargetXpos%,%TargetYpos%,"middle")
      If( Xdiff>79 and Xdiff<102 and Ydiff>10 and Ydiff<27)
        Clickon(%TargetXpos%,%TargetYpos%,"right")

      If( Xdiff>10 and Xdiff<38 and Ydiff>28 and Ydiff<47)
        Clickon(%TargetXpos%,%TargetYpos%,"left", 2)
      If( Xdiff>42 and Xdiff<72 and Ydiff>28 and Ydiff<47)
        Clickon(%TargetXpos%,%TargetYpos%,"middle", 2)
      If( Xdiff>79 and Xdiff<102 and Ydiff>28 and Ydiff<47)
        Clickon(%TargetXpos%,%TargetYpos%,"right", 2)

      If( Xdiff>10 and Xdiff<38 and Ydiff>49 and Ydiff<68)
        Clickon(%TargetXpos%,%TargetYpos%,"left", %updown%)
      If( Xdiff>42 and Xdiff<72 and Ydiff>49 and Ydiff<68)
        Clickon(%TargetXpos%,%TargetYpos%,"middle", %updown%)
      If( Xdiff>79 and Xdiff<102 and Ydiff>49 and Ydiff<68)
        Clickon(%TargetXpos%,%TargetYpos%,"right", %updown%)

      If( Xdiff<0 or Xdiff>110 and Ydiff<0 or Ydiff>75) {
       Progress, off
       menushown = 0
       StoredXpos = 0
       StoredYpos = 0
      }



    }
   } else {
    Progress, off
    menushown = 0
    StoredXpos = 0
    StoredYpos = 0
   }

  }
Return

Clickon(clickXpos, clickYpos, whichClick, clickType="")
{
  Global
  listvars
  pause
  Click %clickXpos% %clickYpos% %clicktype% %whichClick%
  Progress, off
  menushown = 0
  StoredXpos = 0
  StoredYpos = 0
}

+Esc::
ExitApp

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Last edited by engunneer on March 29th, 2007, 5:15 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 29th, 2007, 3:11 pm 
Offline

Joined: December 27th, 2006, 7:44 pm
Posts: 22
I just copied and pasted your code into an .ahk file and when I launch it, it just quits immediately. What else is needed to actually use it as a script?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 29th, 2007, 4:12 pm 
Offline

Joined: August 24th, 2005, 5:29 pm
Posts: 549
Location: Berlin / Germany
Here's another approach:

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"
; ------------------------------------------------------------------------------
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%
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
WinMove, -WW, -WH
WinSet, Transparent, %Trans%
Return
; ------------------------------------------------------------------------------
; Escape was pressed
GuiEscape:
Gui, +LastFound
WinMove, -WW, -WH
SetTimer, Tool_Tip, Off
SetTimer, Watch_Mouse, Off
SetTimer, Check_Mouse, On
Return
; ------------------------------------------------------------------------------
; Click left
Click_L:
Gui, +LastFound
WinMove, -WW, -WH
WinActivate, ahk_ID %W_ID%
MouseMove, XM, YM
Click
Return
; ------------------------------------------------------------------------------
; Doubleclick
Click_D:
Gui, +LastFound
WinMove, -WW, -WH
WinActivate, ahk_ID %W_ID%
MouseMove, XM, YM
Click 2
Return
; ------------------------------------------------------------------------------
; Click right
Click_R:
Gui, +LastFound
WinMove, -WW, -WH
WinActivate, ahk_ID %W_ID%
MouseMove, XM, YM
Click R
Return
; ------------------------------------------------------------------------------
; Click middle
Click_M:
Gui, +LastFound
WinMove, -WW, -WH
WinActivate, ahk_ID %W_ID%
MouseMove, XM, YM
Click M
Return
; ------------------------------------------------------------------------------
; Click left and hold down
Left_D:
Gui, +LastFound
WinMove, -WW, -WH
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) > A_ScreenWidth ? X1 - WW : X1
   YW := (Y1 + WH) > A_ScreenHeight ? 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, -WW, -WH
   SetTimer, Watch_Mouse, Off
   SetTimer, Check_Mouse, On
   Return
}
If (A_TimeIdle > Watch_Time) {
   If (X2 <> X1 And Y2 <> Y1) {
      Click
   } Else {
      WinMove, -WW, -WH
      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


Seems to work, so give it a try!

_________________
nick :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 29th, 2007, 5:17 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8667
Location: Salem, MA
ddh819 wrote:
I just copied and pasted your code into an .ahk file and when I launch it, it just quits immediately. What else is needed to actually use it as a script?


I just added an exitapp hotkey to it, to force it to be persistant. (I could have also used #Persistant)

Anyway, since mine wasn't working quite right, and the other one posted probably does work, I'd try that one.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 29th, 2007, 7:20 pm 
Offline

Joined: December 27th, 2006, 7:44 pm
Posts: 22
@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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 30th, 2007, 5:00 am 
Offline

Joined: August 24th, 2005, 5:29 pm
Posts: 549
Location: Berlin / Germany
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?
:D
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! :(

_________________
nick :wink:


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Edd, Exabot [Bot], Google Feedfetcher, HotkeyStick, Yahoo [Bot] and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group