Skip to content

Commit

Permalink
Add MouseClickDrag
Browse files Browse the repository at this point in the history
  • Loading branch information
phil294 committed Jul 20, 2023
1 parent ed57b0a commit 89ddd5e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
14 changes: 7 additions & 7 deletions README.md
Expand Up @@ -55,7 +55,7 @@ AHK_X11 can be used completely without a terminal. You can however if you want u
<details><summary><strong>CLICK TO SEE WHICH COMMANDS ARE IMPLEMENTED AND WHICH ARE MISSING</strong>. Note however that this is not very representative. For example, no `Gui` sub command is included in the listing. For a better overview on what is already done, skim through the <a href="https://phil294.github.io/AHK_X11"><b>FULL DOCUMENTATION HERE</b></a>.</summary>

```diff
DONE ?% (95/220):
DONE ?% (99/220):
+ Else, { ... }, Break, Continue, Return, Exit, GoSub, GoTo, IfEqual, Loop, SetEnv, Sleep, FileCopy,
+ SetTimer, WinActivate, MsgBox, Gui, SendRaw, #Persistent, ExitApp,
+ EnvAdd, EnvSub, EnvMult, EnvDiv, ControlSendRaw, IfWinExist/IfWinNotExist, SetWorkingDir,
Expand All @@ -69,22 +69,22 @@ DONE ?% (95/220):
+ WinMove, WinRestore, MouseGetPos, MouseMove, GetKeyState, KeyWait, ControlClick, WinGetText,
+ WinGetTitle, WinGetClass, PixelGetColor, CoordMode, GuiControl, ControlGetPos, ControlGetText,
+ WinGet, Input, Loop (parse a string), ToolTip, If var [not] in/contains MatchList, ControlSetText,
+ PixelSearch, #Include, InputBox, ClipWait
+ PixelSearch, #Include, InputBox, ClipWait, EnvSet, SetKeyDelay, SetMouseDelay, MouseClickDrag

NEW ?% (9/220): (not part of spec or from a more recent version)
@@ Echo, ahk_x11_print_vars, FileRead, RegExGetPos, RegExReplace, EnvGet, Click @@
@@ ahk_x11_track_performance_start, ahk_x11_track_performance_stop @@

REMOVED ?% (12/220):
REMOVED ?% (11/220):
# ### Those that simply make no sense in Linux:
# EnvSet, EnvUpdate, PostMessage, RegDelete, RegRead, RegWrite, SendMessage, #InstallKeybdHook,
# EnvUpdate, PostMessage, RegDelete, RegRead, RegWrite, SendMessage, #InstallKeybdHook,
# #InstallMouseHook, #UseHook, Loop (registry)
#
# ### Skipped for other reasons:
# AutoTrim: It's always Off. It would not differentiate between %a_space% and %some_var%.
# It's possible but needs significant work.

TO DO ?% (100/220): alphabetically
TO DO ?% (97/220): alphabetically
- BlockInput, Control, ControlFocus, ControlGet, ControlGetFocus,
- ControlMove,
- DetectHiddenText, DetectHiddenWindows, Drive, DriveGet, DriveSpaceFree,
Expand All @@ -95,9 +95,9 @@ TO DO ?% (100/220): alphabetically
- GroupClose, GroupDeactivate, GuiControlGet,
- If var is [not] type,
- KeyHistory, ListHotkeys, ListLines, ListVars,
- MouseClickDrag, OnExit,
- OnExit,
- Process, Progress, Random, RunAs, SetBatchLines,
- SetCapslockState, SetControlDelay, SetDefaultMouseSpeed, SetFormat, SetKeyDelay, SetMouseDelay,
- SetCapslockState, SetControlDelay, SetDefaultMouseSpeed, SetFormat,
- SetNumlockState, SetScrollLockState, SetStoreCapslockMode, SetTitleMatchMode,
- SetWinDelay, Shutdown, Sort, SoundGet, SoundGetWaveVolume, SoundPlay, SoundSet,
- SoundSetWaveVolume, SplashImage, SplashTextOn, SplashTextOff, SplitPath, StatusBarGetText,
Expand Down
24 changes: 12 additions & 12 deletions docs/index.html
Expand Up @@ -137,7 +137,7 @@ <h2>Table of contents </h2>
<li>
<a href="#FileReadLine.htm">FileReadLine</a>
</li>
<li class="x11">
<li>
<a href="#FileRead.htm">FileRead</a>
</li>
<li>
Expand Down Expand Up @@ -443,7 +443,7 @@ <h2>Table of contents </h2>
<li>
<a class="tbd" href="#ListVars.htm">ListVars</a>
</li>
<li class="x11">
<li>
<a href="#EnvGet.htm">EnvGet</a>
</li>
<li>
Expand Down Expand Up @@ -497,7 +497,7 @@ <h2>Table of contents </h2>
<a href="#MouseClick.htm">MouseClick</a>
</li>
<li>
<a class="tbd" href="#MouseClickDrag.htm">MouseClickDrag</a>
<a href="#MouseClickDrag.htm">MouseClickDrag</a>
</li>
<li>
<a href="#MouseGetPos.htm">MouseGetPos</a>
Expand Down Expand Up @@ -971,7 +971,7 @@ <h2 class="calibre18">Tutorial Contents</h2>
<li class="calibre11">Move the mouse cursor to the desired position in the target window and write down the mouse coordinates displayed by Window Spy (or press Shift-Alt-Tab to activate Window Spy so that the "frozen" coordinates can be copied and pasted).</li>
<li class="calibre11">Use the coordinates discovered above with the <a href="#MouseClick.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2"><span class="">MouseClick</span></a> command as in this example, which clicks the left mouse button:<br class="calibre12" /> MouseClick, left, 112, 223 </li>
</ol>
<p class="calibre8">To move the mouse without clicking, use <a href="#MouseMove.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">MouseMove</a>. To drag the mouse, use <a href="#MouseClickDrag.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2"><span class="tbd">MouseClickDrag</span></a>. </p>
<p class="calibre8">To move the mouse without clicking, use <a href="#MouseMove.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">MouseMove</a>. To drag the mouse, use <a href="#MouseClickDrag.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">MouseClickDrag</a>. </p>
<p class="calibre8"> </p>
<p class="style1"><a id="TutorialHelp.htm__Activate" href="#TutorialHelp.htm__Activate" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">#</a> Activating and manipulating windows</p>
<p class="calibre8">To activate a window (make it foremost), use <a href="#WinActivate.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">WinActivate</a>. To detect whether a window exists, use <a href="#IfWinExist.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">IfWinExist</a> or <a href="#WinWait.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2"><span class="tbd">WinWait</span></a>. The following example illustrates these commands:</p>
Expand Down Expand Up @@ -2191,7 +2191,7 @@ <h2 class="calibre9"><span class="calibre23">The "Last Found" Window </span></h2
<td height="16" class="calibre4">Reads the specified line from a file and stores the text in a <a href="#Variables.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">variable</a>.</td>
</tr>
<tr class="calibre3">
<td height="16" class="calibre4 x11"><a href="#FileRead.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">FileRead</a></td>
<td height="16" class="calibre4"><a href="#FileRead.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">FileRead</a></td>
<td height="16" class="calibre4">Reads the specified line from a file and stores the text in a <a href="#Variables.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">variable</a>.</td>
</tr>
<tr class="calibre3">
Expand Down Expand Up @@ -2398,7 +2398,7 @@ <h2 class="calibre9"><span class="calibre23">The "Last Found" Window </span></h2
<td height="16" class="calibre4">Displays the script's <a href="#Variables.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">variables</a>: their names and current contents.</td>
</tr>
<tr class="calibre3">
<td height="16" class="x11 calibre4"><a href="#EnvGet.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">EnvGet</a></td>
<td height="16" class="calibre4"><a href="#EnvGet.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">EnvGet</a></td>
<td height="16" class="calibre4">Retrieves an environment variable.</td>
</tr>
<tr class="calibre3">
Expand Down Expand Up @@ -2438,7 +2438,7 @@ <h2 class="calibre9"><span class="calibre23">The "Last Found" Window </span></h2
<td height="16" class="calibre4">Clicks or holds a mouse button, or turns the mouse wheel.</td>
</tr>
<tr class="calibre3">
<td height="16" class="tbd calibre4"><a href="#MouseClickDrag.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">MouseClickDrag</a></td>
<td height="16" class="calibre4"><a href="#MouseClickDrag.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">MouseClickDrag</a></td>
<td height="16" class="calibre4">Clicks and holds the specified mouse button, moves the mouse to the destination coordinates, then releases the button.</td>
</tr>
<tr class="calibre3">
Expand Down Expand Up @@ -3969,7 +3969,7 @@ <h2 class="calibre9"><span class="calibre23">The "Last Found" Window </span></h2
return</pre>
</div>
</div>
<div class="calibreMain x11">
<div class="calibreMain">
<div class="calibreEbookContent">
<a id="FileRead.htm" href="#FileRead.htm">#</a> <h2 class="calibre17">FileRead</h2>
<hr size="2" class="calibre24" />
Expand Down Expand Up @@ -10602,15 +10602,15 @@ <h2 id="Examples">Examples</h2>
</div>
</div>
</div>
<div class="calibreMain tbd">
<div class="calibreMain">
<div class="calibreEbookContent">
<a id="MouseClickDrag.htm" href="#MouseClickDrag.htm">#</a> <h2 class="calibre17">MouseClickDrag</h2>
<hr size="2" class="calibre24" />
<p class="calibre8">Clicks and holds the specified mouse button, moves the mouse to the destination coordinates, then releases the button.</p>
<table cellspacing="5" width="100%" class="calibre28">
<tbody class="calibre2">
<tr class="calibre3">
<td height="48" class="calibre4">MouseClickDrag, WhichButton, X1, Y1, X2, Y2 [, Speed, R]</td>
<td height="48" class="calibre4">MouseClickDrag, WhichButton, X1, Y1, X2, Y2 [,<span class="tbd"> Speed</span>, R]</td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -10640,8 +10640,8 @@ <h2 id="Examples">Examples</h2>
<tr class="calibre3">
<td class="calibre4">R</td>
<td class="calibre4">
<p class="calibre8">In v1.0.11+, if this parameter is the letter R, the X1 and Y1 coordinates will be treated as offsets from the current mouse position. In other words, the cursor will be moved from its current position by X1 pixels to the right (left if negative) and Y1 pixels down (up if negative).</p>
<p class="calibre8">Similarly, the X2 and Y2 coordinates will be treated as offsets from the X1 and Y1 coordinates. For example, the following would first move the cursor down and to the right by 5 pixels from its starting position, and then drag it from that position down and to the right by 10 pixels: MouseClickDrag, 5, 5, 10, 10, , R </p>
<p class="calibre8">If this parameter is the letter R, the X1 and Y1 coordinates will be treated as offsets from the current mouse position. In other words, the cursor will be moved from its current position by X1 pixels to the right (left if negative) and Y1 pixels down (up if negative).</p>
<p class="calibre8">Similarly, the X2 and Y2 coordinates will be treated as offsets from the X1 and Y1 coordinates. For example, the following would first move the cursor down and to the right by 5 pixels from its starting position, and then drag it from that position down and to the right by 10 pixels: MouseClickDrag, Left, 5, 5, 10, 10, , R </p>
</td>
</tr>
</tbody>
Expand Down
11 changes: 11 additions & 0 deletions src/cmd/x11/mouse/mouse-click-drag.cr
@@ -0,0 +1,11 @@
require "./mouse-click"

# MouseClickDrag, WhichButton, X1, Y1, X2, Y2 [, Speed, R]
class Cmd::X11::Mouse::MouseClickDrag < Cmd::X11::Mouse::MouseClick
def self.min_args; 5 end
def self.max_args; 7 end
def run(thread, args)
parse_run thread, [args[0], args[1], args[2], "1", args[5]? || "", "D", args[6]? || ""]
parse_run thread, [args[0], args[3], args[4], "1", args[5]? || "", "U", args[6]? || ""]
end
end

0 comments on commit 89ddd5e

Please sign in to comment.