Giter VIP home page Giter VIP logo

Comments (7)

BlueM avatar BlueM commented on August 18, 2024

The Ruby code is not very helpful in understanding the issue, but (as you write yourself), it basically seems to boil down to getting the cursor type – which is not difficult.
The question is if it would be sufficient to implement getting the cursor and writing it to STDOUT (so your code can read it and use that information to judge what would be the appropriate action), or if you’d rather expect cliclick to do something like “if the cursor is the resizeLeftRightCursor, click at 10:20, else click at 10:30”.

from cliclick.

driven avatar driven commented on August 18, 2024

sorry about the ruby...
I was originally looking for cursor detector code that I could call after calculating the target x,y.
As I still would need cliclick to move the mouse to trigger any cursor event, I thought it may be better if self contained...
I tried to write my thinking as a cliclick command example.
gc[:x,y,a,b,str] GET CURSOR will move the mouse to the point with the given coordinates and query cursor type given in the string. Example: “gc:12,34,-0,+5,resizeLeftRightCursor” will move the mouse to the point with x coordinate 12 and y coordinate 34 and returns true if cursor matches string, else it will move the mouse using values given in a,b and re-test. If a match is not found at any position return returns false.
AS a bonus, I think having it as part of cliclick would make it possible to avoid dragging none edges or clicking misplaced buttons when automating GUI testing.
thanks for your reply
john

from cliclick.

BlueM avatar BlueM commented on August 18, 2024

I wouldn’t want to add the logic part to cliclick, as the possible behaviors – and therefore command syntaxes – are endless. (For instance: someone might just want to write to STDERR and exit, if the cursor is not as expected, while somebody else might want to wait 10 seconds and check again, while a third person might want to check the cursor is one of 3 allowed types.)
However, as I wrote before, just reading and returning the cursor isn’t hard, and I think it would make sense to add it.
So, despite your “gc:” example above, I guess that would be something that could help you get the task done?

from cliclick.

driven avatar driven commented on August 18, 2024

just getting the active cursor would be very useful, and I can add my own logic in the ruby code...
I not a programer, I just write plugins for Sketchup,app to make it run better on a mac...
sometimes I was just over complicating my thoughts...

from cliclick.

BlueM avatar BlueM commented on August 18, 2024

As I wrote before, getting the current cursor is not difficult – well, at least theoretically …

The problem is, that as soon as I add [NSCursor currentSystemCursor] to the code, it crashes:

NSLog(@"Supported: %@", [NSCursor respondsToSelector:@selector(currentSystemCursor)] ? @"Y" : @"N");
NSCursor *cursor = [NSCursor currentSystemCursor]; // <-- Causes SIGABRT

The stack suggests that the code tries to get a graphics context (calling [NSGraphicsContext currentContext] returns nil, which is not surprising), but doesn’t get one:

* thread #1: tid = 0xbdce, 0x00007fff91c4b212 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00007fff91c4b212 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff91ecbb24 libsystem_c.dylib`pthread_kill + 90
    frame #2: 0x00007fff91f0ff61 libsystem_c.dylib`abort + 143
    frame #3: 0x00007fff8f65e112 CoreGraphics`CGSConnectionByID + 232
    frame #4: 0x00007fff8f7b8a1c CoreGraphics`CGSGetRegisteredCursorDataSize + 50
    frame #5: 0x00007fff8c1f2d3e AppKit`+[NSCursor currentSystemCursor] + 61
  * frame #6: 0x000000010000a751 cliclick`-[PrintCursorTypeAction performActionWithData:inMode:](self=0x0000000100114e60, _cmd=0x000000010000b829, data=0x0000000100013600, mode=0) + 225 at PrintCursorTypeAction.m:56
    frame #7: 0x000000010000233e cliclick`+[ActionExecutor executeActions:inMode:waitingMilliseconds:](self=0x0000000100012fc8, _cmd=0x000000010000b7f7, actions=0x0000000100112230, mode=0, milliseconds=30) + 1230 at ActionExecutor.m:79
    frame #8: 0x0000000100001769 cliclick`main(argc=2, argv=0x00007fff5fbffa20) + 1705 at cliclick.m:132

Unfortunately, I don’t have a clue about graphics contexts and how to create one without a window. I am now adding this comment, hoping that someone out there might be able to help out with this …

from cliclick.

driven avatar driven commented on August 18, 2024

does using currentCursor have the same issue?
NSCursor *cursor = [NSCursor currentCursor];

from cliclick.

BlueM avatar BlueM commented on August 18, 2024

No, it hasn’t, but it doesn’t help in identifying the global cursor.

from cliclick.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.