Hi, I am porting a program I wrote in Windows to Mac, and part of the prog detects keypresses when the program isn't the active program - I'm using GetAsyncKeyState_($11) to detect CRTL for instance.
How can I do this on the mac?
Thanks for any advice, this is the first time I've used a Mac and I'm finding it a horrific experience!
Detecting Key Persses in Mac PB?
Re: Detecting Key Persses in Mac PB?
You're right, sometimes it's frustrating with missing commands an Mac.wmorton wrote:Hi, I am porting a program I wrote in Windows to Mac, and part of the prog detects keypresses when the program isn't the active program - I'm using GetAsyncKeyState_($11) to detect CRTL for instance.
How can I do this on the mac?
Thanks for any advice, this is the first time I've used a Mac and I'm finding it a horrific experience!
But... >GetAsyncKeyState_($11)< is a Windows-API and not available on Mac.
Try this: Keyboardpushed() or AddKeyboardShortcut. See the help for information.
I think, with one of these commands you can solve your problem.
Good luck!
michel51
Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
Thanks for your help, I looked at the two examples you gave, but I didn't quite understand them. Is it possible on Mac for my program to detect key-presses when my program is minimised and I am working in another program?
Don't worry, I'm not trying to make a key-logger - I am trying to make a program (Program-A) monitor the use of copy & paste, and when then user is working in Program-B presses the keyboard shortcut for paste (Apple-V?) I want Program-A to update the clipboard.
Thanks!
Don't worry, I'm not trying to make a key-logger - I am trying to make a program (Program-A) monitor the use of copy & paste, and when then user is working in Program-B presses the keyboard shortcut for paste (Apple-V?) I want Program-A to update the clipboard.
Thanks!
Hmm... I think, it's not possible to do that.wmorton wrote:Thanks for your help, I looked at the two examples you gave, but I didn't quite understand them. Is it possible on Mac for my program to detect key-presses when my program is minimised and I am working in another program?
Don't worry, I'm not trying to make a key-logger - I am trying to make a program (Program-A) monitor the use of copy & paste, and when then user is working in Program-B presses the keyboard shortcut for paste (Apple-V?) I want Program-A to update the clipboard.
Thanks!
The keyboard shortcuts you can use only with the active program, I think.
If you want to do that, you can copy (Apple-C) in program A, change to program B and paste (Apple-V). That's working. The items are stored within the clipboard til it will be overwritten.
But copy from a program in the foreground with access to an other program is not possible, I think so.
That to the basics.
>GetAsyncKeyState_< is a Windows-API-command. These APIs are'nt available on Mac and not usable on Mac.
An PB_like option are the named commands I told you in my last post.
Hope you understand.
Excuse my bad english, it's not my native language.
michel51
Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta

