detect

Detect which key is pressed [closed]

拥有回忆 提交于 2019-12-01 14:50:57
How do I tell which key was pressed in a Cocoa Application (I know each key has an associated number)? In my case, I want to log the key to the console. This is my code: - (BOOL)acceptsFirstResponder { return YES; } -(void)keyUp:(NSEvent*)event { NSLog(@"Key %@", event); } Use the NSEvent methods keyCode , characters or charactersIgnoringModifiers . - (void)keyUp:(NSEvent *)event { NSLog(@"Characters: %@", [event characters]); NSLog(@"KeyCode: %hu", [event keyCode]); } NSEvent has the keyCode method that returns exactly what you're looking for. 来源: https://stackoverflow.com/questions/12770980

Detect which key is pressed [closed]

走远了吗. 提交于 2019-12-01 13:31:03
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . How do I tell which key was pressed in a Cocoa Application (I know each key has an associated number)? In my case, I want to log the key to the console.

How to client-side detect when a page is bookmarked?

血红的双手。 提交于 2019-12-01 10:58:35
Is it possible to detect when a page is bookmarked within the browser, using Javascript? No, AFAIK this is not possible. Most browsers will not let you detect when a page is bookmarked because this would be another vector for Browser History Mining exploits. If malicious code could tell what websites you've used then, for example: At best, they'd know things about you that you might wish to keep private. They could use that information to target you with embarrassing ads or to target your kids with irresistible ads. They could target you with much more effective phishing attacks -- since they

How to detect an iOS App has been re-installed (from XCode) or upgraded (from AppStore)

会有一股神秘感。 提交于 2019-12-01 09:01:10
An app we are developing uses a binary file included in the app bundle. As this file needs to be processed and in some cases re-written, the app copies this file into the Library/Application Support directory at the first launch or whenever it is missing in Application Support. Then the app loads this file from Application Support every time it is launched and uses the data contained in it. As the Application Support directory is preserved at every app install/upgrade, we need to delete the above mentioned binary file under this directory when the app is installed or upgraded, re-copying it

Detect another process's bitness (in Windows)

别等时光非礼了梦想. 提交于 2019-12-01 07:14:19
问题 How can I detect whether another process is running as 32/64 bit in Windows? I know how to do this for my own process, but not for a different process. A tip or solution in any language would be fine. Thanks! 回答1: Check out IsWow64Process. 回答2: Windows XP SP2 also has IsWow64Process() . So, you can't have the guarantee that you are working under Windows 64-bits when you find IsWow64Process() in kernel32.dll. It means that you cannot say anything when you get FALSE as result. You have to know

Correct way to detect mime type in php

自古美人都是妖i 提交于 2019-12-01 06:54:08
What is the best and reliable way to detect mime type of a file in php? The following code which is suggested by many people failed to detect docx file mime type: $finfo = new finfo(FILEINFO_MIME_TYPE); $mime = $finfo->file($_FILES['file']['tmp_name']); echo $mime; exit; This is printing application/zip but it is supposed to be application/vnd.openxmlformats-officedocument.wordprocessingml.document h2ooooooo Based on this I've ported it to PHP: function getMicrosoftOfficeMimeInfo($file) { $fileInfo = array( 'word/' => array( 'type' => 'Microsoft Word 2007+', 'mime' => 'application/vnd

JavaScript: The best way to detect IE

本小妞迷上赌 提交于 2019-12-01 06:46:48
Reading this article I've found a following piece of code: if ('v'=='\v') { // Note: IE listens on document document.attachEvent('onstorage', onStorage, false); } Is this method 'v'=='\v' a great idea? Is this the shortest way to detect IE ever? If you can avoid it, don't test for browsers. Do feature detection. This will mean that your code is (more likely to be) future-proof. In this case, for instance, if you discovered that the browser was IE and decided to use attachEvent because of it, you would miss out on the fact that addEventListener (superior) is available in IE9. In this case, test

Correct way to detect mime type in php

陌路散爱 提交于 2019-12-01 04:34:11
问题 What is the best and reliable way to detect mime type of a file in php? The following code which is suggested by many people failed to detect docx file mime type: $finfo = new finfo(FILEINFO_MIME_TYPE); $mime = $finfo->file($_FILES['file']['tmp_name']); echo $mime; exit; This is printing application/zip but it is supposed to be application/vnd.openxmlformats-officedocument.wordprocessingml.document 回答1: Based on this I've ported it to PHP: function getMicrosoftOfficeMimeInfo($file) {

Android: Detect SMS Outgoing, Incorrect Count

孤者浪人 提交于 2019-12-01 04:00:41
I am trying to make an application to count the number of outgoing SMS messages from a phone. Presently I have the following code: private void listenForSMS(){ Log.v("SMSTEST", "STARTED LISTENING FOR SMS OUTGOING"); Handler handle = new Handler(){}; SMSObserver myObserver = new SMSObserver(handle); ContentResolver contentResolver = getContentResolver(); contentResolver.registerContentObserver(Uri.parse("content://sms"),true, myObserver); } private class SMSObserver extends ContentObserver{ int count = 0; String lastMessage = null; public SMSObserver(Handler handler) { super(handler); } public

How to detect and echo the last vowel in a word?

冷暖自知 提交于 2019-12-01 02:01:41
$word = "Acrobat" (or Apple, Tea etc.) How can I detect and echo the last vowel of a given word with php? I tried preg_match function, google'd for hours but couldn't find a proper solution. There can be multibyte letters like ü, ö in the string. Here's a multibyte safe version of catching the last vowel in a string. $arr = array( 'Apple','Tea','Strng','queue', 'asartä','nő','ağır','NOËL','gør','æsc' ); /* these are the ones I found in character viewer in Mac so these vowels can be extended. don't forget to add both lower and upper case versions of new ones because personally I wouldn't rely