Ejemplo n.º 1
0
int MediaPlayers::Check() {
    index = -1;
    bool recognized = CurrentEpisode.anime_id > anime::ID_UNKNOWN;

    // Go through windows, starting with the highest in the Z order
    HWND hwnd = GetWindow(g_hMain, GW_HWNDFIRST);
    while (hwnd != nullptr) {
        for (auto item = items.begin(); item != items.end(); ++item) {
            if (!item->enabled)
                continue;
            if (item->visible && !IsWindowVisible(hwnd))
                continue;
            // Compare window classes
            for (auto c = item->classes.begin(); c != item->classes.end(); ++c) {
                if (*c == GetWindowClass(hwnd)) {
                    // Compare file names
                    for (auto f = item->files.begin(); f != item->files.end(); ++f) {
                        if (IsEqual(*f, GetFileName(GetWindowPath(hwnd)))) {
                            if (item->mode != MEDIA_MODE_WEBBROWSER || !GetWindowTitle(hwnd).empty()) {
                                // Stick with the previously recognized window, if there is one
                                if (!recognized || item->window_handle == hwnd) {
                                    // We have a match!
                                    index = index_old = item - items.begin();
                                    new_title = GetTitle(hwnd, *c, item->mode);
                                    EditTitle(new_title, index);
                                    if (current_title != new_title) title_changed_ = true;
                                    current_title = new_title;
                                    item->window_handle = hwnd;
                                    return index;
                                }
                            }
                        }
                    }
                }
            }
        }
        // Check next window
        hwnd = GetWindow(hwnd, GW_HWNDNEXT);
    }

    // Not found
    return -1;
}
Ejemplo n.º 2
0
void MkWindowBaseNode::_StartCursorReport(ePA_SceneNodeEvent evt, const MkInt2& position)
{
	// report
	MkFloat2 worldPos(static_cast<float>(position.x), static_cast<float>(position.y));
	MkFloat2 localPos = worldPos - GetWorldPosition();

	MkDataNode arg;
	arg.CreateUnit(MkWindowBaseNode::ArgKey_CursorLocalPosition, MkVec2(localPos.x, localPos.y));
	arg.CreateUnit(MkWindowBaseNode::ArgKey_CursorWorldPosition, MkVec2(worldPos.x, worldPos.y));
	StartNodeReportTypeEvent(evt, &arg);

	// call back
	if (!m_CallBackTargetWindowPath.Empty())
	{
		do
		{
			MkSceneNode* mgrNode = FindNearestDerivedNode(ePA_SNT_WindowManagerNode); // 소속 window mananger
			if (mgrNode == NULL)
				break;

			MkSceneNode* targetNode = mgrNode->GetChildNode(m_CallBackTargetWindowPath); // call back을 호출 할 node
			if ((targetNode == NULL) || (!targetNode->IsDerivedFrom(ePA_SNT_WindowBaseNode)))
				break;

			MkWindowBaseNode* winBase = dynamic_cast<MkWindowBaseNode*>(targetNode);
			if (winBase == NULL)
				break;

			MkArray<MkHashStr> myPath;
			GetWindowPath(myPath);
			winBase->CallBackOperation(evt, &arg, myPath);
			return;
		}
		while (false);

		m_CallBackTargetWindowPath.Clear(); // 부정 경로. 초기화
	}
}