diff --git a/Actions/DragDownRightAction.h b/Actions/DragDownRightAction.h new file mode 100644 index 0000000..60e4381 --- /dev/null +++ b/Actions/DragDownRightAction.h @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2007-2021, Carsten Blüm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * - Neither the name of Carsten Blüm nor the names of his contributors may be + * used to endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import +#import "ActionProtocol.h" +#import "MouseBaseAction.h" + +@interface DragDownRightAction : MouseBaseAction { + +} + ++ (NSString *)commandShortcut; + ++ (NSString *)commandDescription; + +- (NSString *)actionDescriptionString:(NSString *)locationDescription; + +- (void)performActionAtPoint:(CGPoint) p; + +@end diff --git a/Actions/DragDownRightAction.m b/Actions/DragDownRightAction.m new file mode 100644 index 0000000..78b408a --- /dev/null +++ b/Actions/DragDownRightAction.m @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2007-2021, Carsten Blüm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * - Neither the name of Carsten Blüm nor the names of his contributors may be + * used to endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "DragDownRightAction.h" + +@implementation DragDownRightAction + +#pragma mark - ActionProtocol + ++ (NSString *)commandShortcut { + return @"ddr"; +} + ++ (NSString *)commandDescription { + return @" ddr:x,y Will press down to START A DRAG at the given coordinates with the right mouse button.\n" + " Example: “dd:12,34” will press down at the point with x\n" + " coordinate 12 and y coordinate 34. Instead of x and y values,\n" + " you may also use “.”, which means: the current position."; +} + +#pragma mark - MouseBaseAction + +- (NSString *)actionDescriptionString:(NSString *)locationDescription { + return [NSString stringWithFormat:@"Drag press down with right button at %@", locationDescription]; +} + +- (void)performActionAtPoint:(CGPoint) p { + // Right button down, but don't release + CGEventRef rightDown = CGEventCreateMouseEvent(NULL, kCGEventRightMouseDown, p, kCGMouseButtonRight); + CGEventPost(kCGHIDEventTap, rightDown); + CFRelease(rightDown); +} + +@end diff --git a/Actions/DragMoveRightAction.h b/Actions/DragMoveRightAction.h new file mode 100644 index 0000000..06f6e8e --- /dev/null +++ b/Actions/DragMoveRightAction.h @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2007-2021, Carsten Blüm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * - Neither the name of Carsten Blüm nor the names of his contributors may be + * used to endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import +#import "ActionProtocol.h" +#import "MouseBaseAction.h" + +@interface DragMoveRightAction : MouseBaseAction { + +} + ++ (NSString *)commandShortcut; + ++ (NSString *)commandDescription; + +- (NSString *)actionDescriptionString:(NSString *)locationDescription; + +- (void)performActionAtPoint:(CGPoint) p; + +@end diff --git a/Actions/DragMoveRightAction.m b/Actions/DragMoveRightAction.m new file mode 100644 index 0000000..ccaf977 --- /dev/null +++ b/Actions/DragMoveRightAction.m @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2007-2021, Carsten Blüm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * - Neither the name of Carsten Blüm nor the names of his contributors may be + * used to endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "DragMoveRightAction.h" +#include + +@implementation DragMoveRightAction + +#pragma mark - ActionProtocol + ++ (NSString *)commandShortcut { + return @"dmr"; +} + ++ (NSString *)commandDescription { + return @" dm:x,y Will continue the DRAG event to the given coordinates with the right mouse button.\n" + " Example: “dmr:112,134” will drag and continue to the point with x\n" + " coordinate 112 and y coordinate 134."; +} + +#pragma mark - MouseBaseAction + +- (NSString *)actionDescriptionString:(NSString *)locationDescription { + return [NSString stringWithFormat:@"Drag move to %@", locationDescription]; +} + +- (void)performActionAtPoint:(CGPoint) p { +} + +- (uint32_t)getMoveEventConstant { + return kCGEventRightMouseDragged; +} + +@end diff --git a/Actions/DragUpRightAction.h b/Actions/DragUpRightAction.h new file mode 100644 index 0000000..897d1f8 --- /dev/null +++ b/Actions/DragUpRightAction.h @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2007-2021, Carsten Blüm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * - Neither the name of Carsten Blüm nor the names of his contributors may be + * used to endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import +#import "ActionProtocol.h" +#import "MouseBaseAction.h" + +@interface DragUpRightAction : MouseBaseAction { + +} + ++ (NSString *)commandShortcut; + ++ (NSString *)commandDescription; + +- (NSString *)actionDescriptionString:(NSString *)locationDescription; + +- (void)performActionAtPoint:(CGPoint) p; + +@end diff --git a/Actions/DragUpRightAction.m b/Actions/DragUpRightAction.m new file mode 100644 index 0000000..a118327 --- /dev/null +++ b/Actions/DragUpRightAction.m @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2007-2021, Carsten Blüm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * - Neither the name of Carsten Blüm nor the names of his contributors may be + * used to endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "DragUpRightAction.h" +#include + +@implementation DragUpRightAction + +#pragma mark - ActionProtocol + ++ (NSString *)commandShortcut { + return @"dur"; +} + ++ (NSString *)commandDescription { + return @" dur:x,y Will release to END A DRAG at the given coordinates with right mouse button.\n" + " Example: “dur:112,134” will release at the point with x\n" + " coordinate 112 and y coordinate 134."; +} + +#pragma mark - MouseBaseAction + +- (NSString *)actionDescriptionString:(NSString *)locationDescription { + return [NSString stringWithFormat:@"Drag release right mouse button at %@", locationDescription]; +} + +- (void)performActionAtPoint:(CGPoint) p { + // Right button up + CGEventRef rightUp = CGEventCreateMouseEvent(NULL, kCGEventRightMouseUp, p, kCGMouseButtonRight); + CGEventPost(kCGHIDEventTap, rightUp); + CFRelease(rightUp); +} + +- (uint32_t)getMoveEventConstant { + return kCGEventRightMouseDragged; +} + +@end diff --git a/cliclick.xcodeproj/project.pbxproj b/cliclick.xcodeproj/project.pbxproj index 38dce5e..3df027d 100644 --- a/cliclick.xcodeproj/project.pbxproj +++ b/cliclick.xcodeproj/project.pbxproj @@ -32,6 +32,9 @@ 5B9FEE9A1DDF5E6F0020F6F6 /* RightClickAction.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B9FEE991DDF5E6F0020F6F6 /* RightClickAction.m */; }; 8DD76F9A0486AA7600D96B5E /* cliclick.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* cliclick.m */; settings = {ATTRIBUTES = (); }; }; 8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; }; + D298673825FC529500C4DE39 /* DragUpRightAction.m in Sources */ = {isa = PBXBuildFile; fileRef = D298673425FC529500C4DE39 /* DragUpRightAction.m */; }; + D298673925FC529500C4DE39 /* DragDownRightAction.m in Sources */ = {isa = PBXBuildFile; fileRef = D298673725FC529500C4DE39 /* DragDownRightAction.m */; }; + D298673D25FC53F200C4DE39 /* DragMoveRightAction.m in Sources */ = {isa = PBXBuildFile; fileRef = D298673C25FC53F200C4DE39 /* DragMoveRightAction.m */; }; F0A674F818EE2D0C0062FD29 /* DragDownAction.m in Sources */ = {isa = PBXBuildFile; fileRef = F0A674F718EE2D0C0062FD29 /* DragDownAction.m */; }; F0A674FB18EE3F220062FD29 /* DragUpAction.m in Sources */ = {isa = PBXBuildFile; fileRef = F0A674FA18EE3F220062FD29 /* DragUpAction.m */; }; /* End PBXBuildFile section */ @@ -98,6 +101,12 @@ 5B9FEE981DDF5E6F0020F6F6 /* RightClickAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RightClickAction.h; path = Actions/RightClickAction.h; sourceTree = ""; }; 5B9FEE991DDF5E6F0020F6F6 /* RightClickAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RightClickAction.m; path = Actions/RightClickAction.m; sourceTree = ""; }; 8DD76FA10486AA7600D96B5E /* cliclick */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = cliclick; sourceTree = BUILT_PRODUCTS_DIR; }; + D298673425FC529500C4DE39 /* DragUpRightAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DragUpRightAction.m; path = Actions/DragUpRightAction.m; sourceTree = ""; }; + D298673525FC529500C4DE39 /* DragDownRightAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DragDownRightAction.h; path = Actions/DragDownRightAction.h; sourceTree = ""; }; + D298673625FC529500C4DE39 /* DragUpRightAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DragUpRightAction.h; path = Actions/DragUpRightAction.h; sourceTree = ""; }; + D298673725FC529500C4DE39 /* DragDownRightAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DragDownRightAction.m; path = Actions/DragDownRightAction.m; sourceTree = ""; }; + D298673B25FC53F200C4DE39 /* DragMoveRightAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DragMoveRightAction.h; path = Actions/DragMoveRightAction.h; sourceTree = ""; }; + D298673C25FC53F200C4DE39 /* DragMoveRightAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DragMoveRightAction.m; path = Actions/DragMoveRightAction.m; sourceTree = ""; }; F0A674F618EE2D0C0062FD29 /* DragDownAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DragDownAction.h; path = Actions/DragDownAction.h; sourceTree = ""; }; F0A674F718EE2D0C0062FD29 /* DragDownAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DragDownAction.m; path = Actions/DragDownAction.m; sourceTree = ""; }; F0A674F918EE3F220062FD29 /* DragUpAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DragUpAction.h; path = Actions/DragUpAction.h; sourceTree = ""; }; @@ -183,6 +192,10 @@ 22704CCB19816C4C000270EE /* MouseActions */ = { isa = PBXGroup; children = ( + D298673525FC529500C4DE39 /* DragDownRightAction.h */, + D298673725FC529500C4DE39 /* DragDownRightAction.m */, + D298673625FC529500C4DE39 /* DragUpRightAction.h */, + D298673425FC529500C4DE39 /* DragUpRightAction.m */, 22E5626116BA589200CD5D86 /* MouseBaseAction.h */, 22E5626216BA589200CD5D86 /* MouseBaseAction.m */, 22E5625616BA589200CD5D86 /* ClickAction.h */, @@ -191,6 +204,8 @@ F0A674F718EE2D0C0062FD29 /* DragDownAction.m */, 22129EB225EA93B500904544 /* DragMoveAction.h */, 22129EB325EA93B500904544 /* DragMoveAction.m */, + D298673B25FC53F200C4DE39 /* DragMoveRightAction.h */, + D298673C25FC53F200C4DE39 /* DragMoveRightAction.m */, F0A674F918EE3F220062FD29 /* DragUpAction.h */, F0A674FA18EE3F220062FD29 /* DragUpAction.m */, 22E5625816BA589200CD5D86 /* DoubleclickAction.h */, @@ -374,8 +389,11 @@ 22E5627316BA589200CD5D86 /* TripleclickAction.m in Sources */, 22998C7D197A85A300A4C691 /* TypeAction.m in Sources */, 22E5627416BA589200CD5D86 /* WaitAction.m in Sources */, + D298673825FC529500C4DE39 /* DragUpRightAction.m in Sources */, + D298673925FC529500C4DE39 /* DragDownRightAction.m in Sources */, 5B9FEE9A1DDF5E6F0020F6F6 /* RightClickAction.m in Sources */, 226347791B998B80003C5D71 /* ColorPickerAction.m in Sources */, + D298673D25FC53F200C4DE39 /* DragMoveRightAction.m in Sources */, 22C0ECEE16BAFD9800E3A46C /* KeyBaseAction.m in Sources */, F0A674F818EE2D0C0062FD29 /* DragDownAction.m in Sources */, F0A674FB18EE3F220062FD29 /* DragUpAction.m in Sources */,