Code: Select all
param1 = %1%
If StrLen(param1)
Option := param1
If (Option = "DragDrop") or (Option = "DnD")
Option := 0, DragBeg := True
Else If Option = Stay
{ Gui, Font, s30, Consolas
Gui, Add, ListBox, r10 gLBevent, Click|Right Click|X1 Click|X2 Click|No Click|Double Click|Drag & Drop|Wheel Up|Wheel Down|Middle Click
Gui, Show, Minimize, Fullscreen Trackpad - Select An Action Please
}OnMessage(0x6, "WM_ACTIVATE")
Gui, mask:New, +OwnDialogs
IfWinExist, Fullscreen Trackpad - Select An Action Please
Gui, mask:+ToolWindow
Gui, mask:+LastFound
Gui, Color, Yellow
WinSet, Transparent, 16
Gui, Show, w%A_ScreenWidth% h%A_ScreenHeight%, Mouse Positioning Mask
OnMessage(0x201, "WM_LBUTTONDOWN")
HBITMAP := Create_HBITMAP()
H := Bitmap_GetHeight(HBITMAP)
W := Bitmap_GetWidth(HBITMAP)
Gui, scope:New, +LastFound -Caption +OwnerMask
Gui, Margin, 0, 0
Gui, Add, Text, w%W% h%H% hwndHPic1
Bitmap_SetImage(HPic1, HBITMAP)
Gui, Color, White
WinSet, TransColor, White
CoordMode, Mouse, Screen
MouseGetPos, x, y
xx := x - 12, yy := y - 12
Gui, scope:Show, x%xx% y%yy% NoActivate, Mouse Position Scope
Send, {Ctrl Down}{Ctrl Up}
OnMessage(0x205, "WM_RBUTTONUP")
t =
(
Tap-to-place Mode: (before "drag")
Tap to position the scope (kinda mouse pointer)
Tap-n-hold to {Click}, or "Drag" to adjust
Tap-to-confirm Mode: (after "drag")
Tap to {Click}, or "Drag" to further adjust
whereas Tap-n-hold can reset the "drag" state
so that it will fall back to the Tap-to-place Mode
Esc to exit
.
) ; "drag" = touch the touchscreen w/o releasing and move freely until the scope (a little red circle on screen) reached the aiming location
ToolTip, %t%
Sleep, 5000
ToolTip
Return
WM_LBUTTONDOWN() {
global
Ox := x, Oy := y, beg := A_TickCount
MouseGetPos, x0, y0
While, GetKeyState("LButton", "P")
{ MouseGetPos, x1, y1
xd := x1 - x0, yd := y1 - y0
If xd or yd
{ x += xd, y += yd
xx := x - 12, yy := y - 12
Gui, scope:Show, x%xx% y%yy% NoActivate, Mouse Position Scope
x0 := x1, y0 := y1
}
}If (x - Ox) or (y - Oy) or A_TickCount - beg > 500
{ If (x - x0) or (y - y0)
DllCall("SetCursorPos", int, x, int, y), AdjFlag := True
Return
}Else If AdjFlag
WM_RBUTTONUP("a")
x := x0, y := y0
xx := x - 12, yy := y - 12
Gui, scope:Show, x%xx% y%yy% NoActivate, Mouse Position Scope
Send, {Ctrl Down}{Ctrl Up}
}
WM_RBUTTONUP(p) {
global
If AdjFlag and (p not = "a")
{ AdjFlag := False
Return
}WinHide, Mouse Positioning Mask
Click, %x%, %y%, %Option%
If DragBeg
{ WinShow, Mouse Positioning Mask
fromX := x, fromY := y, DragBeg := AdjFlag := False
MsgBox, Now`, select the destination please
}Else If StrLen(DragBeg)
{ Click, %fromX%, %fromY%, Down
Click, %x%, %y%, Up
Gosub, NoName
}Else Gosub, NoName
Return
NoName:
Send, {Ctrl Down}{Ctrl Up}
IfWinExist, Fullscreen Trackpad - Select An Action Please
{ AdjFlag := False
Gui, mask:Show, % (Option = 0) and not StrLen(DragBeg) ? "Minimize" : "NoActivate"
}Else Gosub, maskGuiClose
Return
}
maskGuiEscape:
maskGuiClose:
ExitApp
LBevent() {
global
GuiControlGet, Choice,, ListBox1
If StrLen(Choice)
{ CurItem := Choice
If A_TickCount - (StrLen(DownUp) ? DownUp : 0) < 100
Return
}Else If A_ThisHotkey in Space,$Enter,``
Choice := CurItem
DragBeg := ""
If (Option := StrReplace(StrReplace(Choice, A_Space), "Click")) = "No"
Option = 0
Else If Option = Double
Option = 2
Else If Option = Drag&Drop
Option := 0, DragBeg := True
WinMinimize, A
IfWinNotActive, Mouse Positioning Mask
Gui, mask:Show
}
WM_ACTIVATE(wParam) {
If (wParam > 0)
IfWinActive, Mouse Positioning Mask
OnMessage(0x201, "WM_LBUTTONDOWN")
Else OnMessage(0x201, "")
}
GuiClose:
Gui, Destroy
Gui, mask:-ToolWindow
Gui, mask:Show
Return
#IfWinActive, Fullscreen Trackpad - Select An Action Please
Space::
Enter::
`::LBevent()
~Down::
~Up::DownUp := A_TickCount
; here below are basically all from @"just me"
Create_HBITMAP(NewHandle := False) {
static hBitmap := 0
If (NewHandle)
hBitmap := 0
If (hBitmap)
Return hBitmap
VarSetCapacity(B64, 6796 << !!A_IsUnicode)
B64 := "iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAIAAABLixI0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAC3SURBVEhL7ZMxEsMgEAP9kJT5/8/yBqJw8iUsGChcZmcrTlJlH+Wa1+PZ69uI8Rb6vc61cAudue6cNFuI7uhm5buF0L7u5xbOaVwTXNO4Xm7F+xAkZbx/tnCQcZuAvNTjYKuG1/StA08yokvQktxycA90/1sL0OWWdHAFWvLW76t/lTU8A3mpx7v/R4FbGtcE1zSu3hI47+v+75ZAaEc3K82WQHSuOyfcCtDpda5lvBWgH/rWU8obYqAWeeI53OkAAAAASUVORK5CYII="
If !DllCall("Crypt32.dll\CryptStringToBinary", "Ptr", &B64, "UInt", 0, "UInt", 0x01, "Ptr", 0, "UIntP", DecLen, "Ptr", 0, "Ptr", 0)
Return False
VarSetCapacity(Dec, DecLen, 0)
If !DllCall("Crypt32.dll\CryptStringToBinary", "Ptr", &B64, "UInt", 0, "UInt", 0x01, "Ptr", &Dec, "UIntP", DecLen, "Ptr", 0, "Ptr", 0)
Return False
hData := DllCall("Kernel32.dll\GlobalAlloc", "UInt", 2, "UPtr", DecLen, "UPtr")
pData := DllCall("Kernel32.dll\GlobalLock", "Ptr", hData, "UPtr")
DllCall("Kernel32.dll\RtlMoveMemory", "Ptr", pData, "Ptr", &Dec, "UPtr", DecLen)
DllCall("Kernel32.dll\GlobalUnlock", "Ptr", hData)
DllCall("Ole32.dll\CreateStreamOnHGlobal", "Ptr", hData, "Int", True, "PtrP", pStream)
hGdip := DllCall("Kernel32.dll\LoadLibrary", "Str", "Gdiplus.dll", "UPtr")
VarSetCapacity(SI, 16, 0), NumPut(1, SI, 0, "UChar")
DllCall("Gdiplus.dll\GdiplusStartup", "PtrP", pToken, "Ptr", &SI, "Ptr", 0)
DllCall("Gdiplus.dll\GdipCreateBitmapFromStream", "Ptr", pStream, "PtrP", pBitmap)
DllCall("Gdiplus.dll\GdipCreateHBITMAPFromBitmap", "Ptr", pBitmap, "PtrP", hBitmap, "UInt", 0)
DllCall("Gdiplus.dll\GdipDisposeImage", "Ptr", pBitmap)
DllCall("Gdiplus.dll\GdiplusShutdown", "Ptr", pToken)
DllCall("Kernel32.dll\FreeLibrary", "Ptr", hGdip)
DllCall(NumGet(NumGet(pStream + 0, 0, "UPtr") + (A_PtrSize * 2), 0, "UPtr"), "Ptr", pStream)
Return hBitmap
}
Bitmap_GetWidth(hBitmap) {
static Size := (4 * 5) + A_PtrSize + (A_PtrSize - 4)
VarSetCapacity(BITMAP, Size, 0)
DllCall("Gdi32.dll\GetObject", "Ptr", hBitmap, "Int", Size, "Ptr", &BITMAP, "Int")
Return NumGet(BITMAP, 4, "Int")
}
Bitmap_GetHeight(hBitmap) {
static Size := (4 * 5) + A_PtrSize + (A_PtrSize - 4)
VarSetCapacity(BITMAP, Size, 0)
DllCall("Gdi32.dll\GetObject", "Ptr", hBitmap, "Int", Size, "Ptr", &BITMAP, "Int")
Return NumGet(BITMAP, 8, "Int")
}
Bitmap_SetImage(hCtrl, hBitmap) {
; STM_SETIMAGE = 0x172, IMAGE_BITMAP = 0x00, SS_BITMAP = 0x0E
WinSet, Style, +0x0E, ahk_id %hCtrl%
SendMessage, 0x172, 0x00, %hBitmap%,, ahk_id %hCtrl%
Return ErrorLevel
}
run it without command line parameter for positioning and (left mouse button) click. (remark: positioning = specifying the location where the mouse pointer should move to.)
if command line parameter (it cannot be more than one) is applied, it could be one of the following:
- right (or simply r) for positioning and right mouse button click.
- x1 for positioning and mouse x1 button click.
- x2 for positioning and mouse x2 button click.
- 0 for positioning only, i.e. without any button click nor wheel up/down whatsoever.
- 2 for positioning and double (left mouse button) click.
- dragdrop (or simply dnd) for positioning with drag & drop operation.
- wheelup (or simply wu) for positioning and mouse wheel up.
- wheeldown (or simply wd) for positioning and mouse wheel down.
- middle (or simply m) for positioning and middle mouse button click.
- down (or simply d) for positioning and left mouse button down.
- up (or simply u) for positioning and left mouse button up.
*known limitation: the mask doesn't cover the windows taskbar, so do not tap on the windows taskbar for tap-to-place nor for tap-to-confirm. (remark: tap-to-place = "having the scope placed directly at wherever your finger just tapped." whereas, tap-to-confirm = "having the click (or the drag & drop operation) occurred at the place(s) the scope is at, and exitapp. or, move the mouse pointer to wherever the scope is at, and exitapp.")
however, the scope does cover everywhere including the windows taskbar. that is, you can move the scope to anywhere on the windows taskbar. and the supposed subsequent action could be taken place there as well. (remark: the mask = "the area turned semi-transparent." whereas, the scope = "the little red circle displayed.")
in case you want to use it from spotmenu (viewtopic.php?p=437117#p437117), try these examples below. (assumed you saved the script above as poscursor.ahk)
Code: Select all
Click {PosCursor} Send LButton (Script)
Right Click {Right Click} Send RButton (Script)
X1 Click {X1 Click} Send X1Button (Script)
X2 Click {X2 Click} Send X2Button (Script)
No Click {Without Click} Positioning Only (Script)
Double Click {Double Click} (Script)
Drag && Drop {Drag & Drop} (Script)
Wheel Up {Wheel Up} Send WheelUp (Script)
Wheel Down {Wheel Down} Send WheelDown (Script)
Middle Click {Middle Click} Send MButton (Script)
;
{Script Right Click}
Option = Right
#Include, PosCursor.ahk
{/Script}
{Script X1 Click}
Option = X1
#Include, PosCursor.ahk
{/Script}
{Script X2 Click}
Option = X2
#Include, PosCursor.ahk
{/Script}
{Script Without Click}
Option = 0
#Include, PosCursor.ahk
{/Script}
{Script Double Click}
Option = 2
#Include, PosCursor.ahk
{/Script}
{Script Drag & Drop}
Option = DragDrop
#Include, PosCursor.ahk
{/Script}
{Script Wheel Up}
Option = WheelUp
#Include, PosCursor.ahk
{/Script}
{Script Wheel Down}
Option = WheelDown
#Include, PosCursor.ahk
{/Script}
{Script Middle Click}
Option = Middle
#Include, PosCursor.ahk
{/Script}
{Script LeftDown}
Option = Down
#Include, PosCursor.ahk
{/Script}
{Script LeftUp}
Option = Up
#Include, PosCursor.ahk
{/Script}
2022-1-22 edited: 1, "double click" was omitted, typed it back; 2, corrected a typo in the examples; 3. made some cosmetic adjustments in the examples.
edited: added the "stay" (i.e. won't exitapp after action) option which comes with a listbox for action choosing.