Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kp: doesnt work (MacOS 12.6.2) #164

Open
sburlot opened this issue Jan 11, 2023 · 7 comments
Open

kp: doesnt work (MacOS 12.6.2) #164

sburlot opened this issue Jan 11, 2023 · 7 comments

Comments

@sburlot
Copy link

sburlot commented Jan 11, 2023

when using the command kp

  • cliclick kp:volume-up
  • cliclick kp:volume-down
  • cliclick kp:play-pause
  • cliclick kp:arrow-up
  • cliclick kp:arrow-down
  • cliclick kp:brightness-up
  • cliclick kp:brightness-down

(I've not tested all)

Nothing happens

weirdly, putting 2 commands works, le:
cliclick kp:brightness-down kp:brightness-up
or
cliclick ku:cmd kp:brightness-up

(The ku:cmd is just there to make a NOP command)

MacOS 12.6.2, iMac late 2015

@mocaffy
Copy link

mocaffy commented Feb 19, 2023

I am experiencing the same problem
macOS 11.7.2

@dangarfield
Copy link

Same with me. kp doesn't work for me at all either.
macOS Ventura 13.4.1 (22F82)

@profsmallpine
Copy link

Ditto on macOS Venture 13.5

@chopin1998
Copy link

any update? same problem.....

@BlueM
Copy link
Owner

BlueM commented Nov 10, 2024

I have finally been able to reproduce kp-related problems (on macOS 14).

What was/is really odd is that kp works even if you execute another command after it:

# Does not work
cliclick kp:brightness-up

# Works
cliclick kp:brightness-up p:'Hello world'

This looked an obvious indicator for a timing issue in newer macOS versions.

For anyone having this problem, please try if this modification solves the issue:

// In ActionExecutor.m, replace lines 89 thru 91 with:
if (options.isLastAction) {
    waitingtime.tv_sec = 0;
    waitingtime.tv_nsec = 1000000; // Arbitraray dummy value
    nanosleep(&waitingtime, NULL);
} else {
    nanosleep(&waitingtime, NULL);
}

// Cf. https://github.com/BlueM/cliclick/blob/master/ActionExecutor.m#L89

I am very much interested to hear if that changes the behavior.

@stephen714
Copy link

Hi BlueM,
Firstly I should say I don't have much experience and am probably making silly mistakes.
I forked and cloned the master and used vscode to test this change. I tried make in the VScode terminal and the vanilla terminal to compile, but it gave errors;

myhomefolder@computername cliclick-kp-test % make
./generate-action-classes-macro.sh
cc  -include cliclick_Prefix.pch -I Actions -I .   -c -o Actions/ColorPickerAction.o Actions/ColorPickerAction.m
Actions/ColorPickerAction.m:86:35: error: 'CGWindowListCreateImage' is unavailable: obsoleted in macOS 15.0 - Please use ScreenCaptureKit instead.
   86 |             CGImageRef imageRef = CGWindowListCreateImage(imageRect, kCGWindowListOptionOnScreenOnly, kCGNullWindowID, kCGWindowImageDefault);
      |                                   ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGWindow.h:271:33: note: 'CGWindowListCreateImage' has been explicitly marked unavailable here
  271 | CG_EXTERN CGImageRef __nullable CGWindowListCreateImage(CGRect screenBounds,
      |                                 ^
1 error generated.
make: *** [Actions/ColorPickerAction.o] Error 1

The same error with CGWindowListCreateImage persisted with the clean and modified versions I tried
I'd love to help more rn but I'm at the end of what I currently know... 😞

@BlueM
Copy link
Owner

BlueM commented Nov 10, 2024

@stephen714: the problem is caused by an API which is no longer included in the macOS 15 SDK. For testing purposes, you can simply remove all code in the performActionWithData:withOptions: method in ColorPickerAction.m so it looks like this:

- (void)performActionWithData:(NSString *)data
                  withOptions:(struct ExecutionOptions)options {
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants