 |
|
 |
Hello everyone,
I was trying to make an application, that registers a hotkey and when the hotkey is pressed, simulates a keyboard event or mouse click.
To do so, I have chosen to use the RegisterHotkey(), SendInput() and GetMessage() windows functions.
The problem is that as soon as I declare a call to GetMessage() - SendInput() stops working.
In the code below, I made an experiment - the program is waiting for 3 seconds (to give me some time) and as soon as I start it, I bring notepad to focus and the "KeyDown(97)" types "1" in the notepad window.
However, this behavior does not work when the MessageLoop() is entered.
Thank you for your help.
Best Regards,
Alex
#define _WIN32_WINNT 0x0500
#include "stdafx.h"
#include <Windows.h>
//This function simulates a keyboard button press and release. Argument is VirtualKey
//This function works fine, before the GetMessage() function is declared/called
void KeyDown(int vk){
printf("Called KeyDown with parameter %d \n",vk);
INPUT Input[1];
Input[0].type = INPUT_KEYBOARD;
Input[0].ki.wVk= vk;
printf("Sending Input\n");
SendInput(1, Input, sizeof(Input));
}
//This function is blocking and waiting for a message to arrive
void MessageLoop(){
MSG msg = {0};
while (GetMessage(&msg, NULL, 0, 0) != 0)
{
//if the arrived message is a hotkey event
if (msg.message == WM_HOTKEY)
{
//some debugging
printf("msg.message %d, msg.lParam %d, msg.wParam %d \n",msg.message,msg.lParam,msg.wParam);
//press the numeric '1' on the keyboard - doesn't work
KeyDown(97);
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
int main(int argc, char* argv[])
{
//This part works, only when the GetMessage() function is in a separate function ex: MessageLoop----
Sleep(3000);
KeyDown(97);
//Register an ALT-CTR-A hotkey with ID - 1. First argument is NULL to make the hotkey global (it is a hWnd)
RegisterHotKey(
NULL,
1,
MOD_CONTROL | MOD_ALT,
0x41
); //0x41 is 'a'
//Enter the message loop that blocks and waits for a message to arrive for this application
//Note that if I put the 'while (GetMessage(&msg, NULL, 0, 0) != 0)' code here,
//instead of putting it in a separate function,
//the 'KeyDown(97)' call on the 2nd line of the main() function will not work !
MessageLoop();
//clean up
UnregisterHotKey(NULL,1);
return 0;
}
|
|
|
|
 |
|
 |
In the DirectX metro sample one can find a class named DirectXBase with roughly this header:
ref class DirectXBase abstract
{
public:
DirectXBase();
virtual void Render() = 0;
virtual void Present();
protected:
Microsoft::WRL::ComPtr<ID2D1Factory1> m_d2dFactory;
Microsoft::WRL::ComPtr<ID2D1Device> m_d2dDevice;
Microsoft::WRL::ComPtr<ID2D1DeviceContext> m_d2dContext;
Microsoft::WRL::ComPtr<ID2D1Bitmap1> m_d2dTargetBitmap;
};
What I find strange is that there is no destructor!
What about all those ComPtr? are they automatically set to null because it's a ref class?
is it a bug?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
 |
|
 |
Well, it's an abstract class... and all those are pointers. So if they were never allocated, they don't need to be destroyed.
|
|
|
|
 |
|
 |
I had a long and interesting conversation with a friend at MS about Metro, and he made the statement that there's no reason an expanded Metro tile (which I interpret to mean the launch of a Metro App that "fills the screen" ... which may, or may not, contain other Tiles):
Could indeed display a complex control, like a TreeView.
Since that conversation, I have been looking to find one example of some suggestion of a future control that could operate within a full-screened Metro App which reminds me of some of the common controls found in WinForms or WPF, like a TreeView, or some of the usual controls found in various major "suites" from Telerik, Lidor, DevXpress, etc. ...
My impression is that Metro is a "design language" that precludes use of controls that look like the TreeView we might be used to today: that precludes anything but one-level-at-a-time "drill-down" or "pop-back-up."
I'd appreciate hearing your thoughts, and possibly getting my (all too often incorrect) impressions corrected.
Now I do, indeed, understand that to some extent Metro qua "design language" is targeted at smaller form-factor delivery platforms, but if I am running Metro on a "big screen" ... am I not going to have access to controls with more possible representation of "levels of hierarchy" when I have full-screened a Metro Tile ?
thanks, Bill
"It is the mark of an educated mind to be able to entertain a thought without accepting it." Aristotle
|
|
|
|
 |
|
 |
The short answer is no. The form factor actually shouldn't matter - as Metro changes what the design is about. With Metro, the idea is that you start with application flow, and that content is king. Traditional hierarchical designs tend to be quite clunky, and don't always represent a user-centric flow. Instead, they target the mental model that we, as developers, tend to be familiar with - especially as we don't always consider the varying skill levels of users so what seems natural to us can be alien to the end user.
A core idea is that the form-factor is unimportant in Metro, so that the same application should be able to run on any metro platform. If you suddenly introduce larger scale form factor "enhancements", then you are presenting a none-unified experience that could cause confusion for clients using your application on a wide variety of devices.
A good place to start with thinking in Metro is this[^] blog posting.
|
|
|
|
 |
|
 |
Hi Pete, always appreciate your eloquent replies, and will certainly study the link you sent.
But, it seems to me that it is as natural as wearing socks with shoes to organize information by categories, which are frequently sub-categorized, as in my library of books, my BookMarks in the browser, my collection of Photos and MP3 files, and on, and on.
And frequently, I would claim, that it is the organization of content that is King, while the content becomes King only when you can locate it and focus on what you need to focus on. And then the Emperor, to continue this metaphor, is the ability to create complex associational networks of meaning across content, and across categories of content.
So one thinks of a "marriage:" and how that one concept may unite a scrapbook of pictures, collections of love-letters, facts-on-paper like tax payments, and checking accounts, personal diaries, to-do lists for joint projects, and a great webs of personal memories with unique emotions and memories interwoven into them.
What could be more vital to the flow of work than the ability to narrow or expand the extent to which content is summarized rather than all visible or revealed ?
I see "real world people" who are not developers using library card catalogs, personal diaries and appointment books organized by varying levels of time, etc. ... everywhere. That content, often simple, is, yes, content they create, but they also consume it.
To me a device that only serves as a playback machine for content you do not create, or create only by selecting from content others present you with, is not a personal computer: it's another form of TV, which is not to imply that TV's are not very useful, or cool !
I do not buy the idea that developers have special modes of thought that are rather alien to most other people. Whether software developers self-select to become developers because they are rather "alien" ... well let's leave that topic alone
"Hierarchical thinking" and organization of the experience of the world, I believe, is as natural as our primate biologically hard-wired equipment for figuring out, almost instantly, who's who in a power structure.
Lists, grids, items within items, recursion, as reflections of modes of thought are as natural across human cultures as weapons and fire. Within cultures where oral transmission of complex histories and genealogies, sagas, legends, etc., were critically important you also find some very sophisticated techniques for memorization (re-discovered in the Renaissance in the West via transmission from the Arab world [memory palaces, for example]).
An interesting example: the visual signals from the eye related to recognition of a friendly or hostile face are routed to the amygdala for processing, and are reacted to, often powerfully, long before the higher-level cognitive functions in the neo-cortex associated with the construction of an inner representation of a "seen world" is consciously present is created from the total set of signals from the ocular apparatus.
I see no reason whatsoever why you couldn't have a fine-quality treeview (given the resolutions now available in small form factor devices) that would allow a number of levels of drill-down partially based on dynamically sensing the size/resolution of the screen available. And you need one finger gesture, or click of something, to snap back to the TreeView after you've fully expanded the content in some "node" of interest.
Right now I regard "Metro" as something that a large group of people went off to some fantasy island to create, and brought back, as a kind of religious creed, believing it, perhaps, to be the great mantras of the dragon that could, perhaps, take a big bite out of Apple which has MS backed up against the wall.
Hope I am wrong. And certainly ready to change my mind.
best, Bill
"It is the mark of an educated mind to be able to entertain a thought without accepting it." Aristotle
|
|
|
|
 |
|
 |
You are limited in what you can do on your tile. The user can expand the tile to be a rectangle or a large square, but you can still only show certain things in there (words, icon, pictures, a handful of status indicators etc). Microsoft controls that piece in order to give the user a consistent feel throughout their desktop.
Once you launch the app, I don't think there is any limitation on what you can do. You'll be using XAML or HTML5 (or maybe C++, but I know nothing about that), and there is no technical reason you can't design or style a control in anyway you like. You're only limited by your skills and imagination. That being said, it might be harder to get your app in the store if it looks like a traditional desktop app, rather than embracing the Metro style. I'm not sure how or if they'll enforce that.
I'm sure the 3rd party control developers will be along with their metro style stuff soon, until then, look at phone controls to get an idea of what the other Metro controls might look like. Infragistics has this TreeMap[^] control that looks like how I think a Metro style tree would be displayed.
|
|
|
|
 |
|
 |
+5 Thanks; I missed seeing this response until today. best, Bill
"Our life is a faint tracing on the surface of mystery, like the idle, curved tunnels of leaf miners on the surface of a leaf. We must somehow take a wider view, look at the whole landscape, really see it, and describe what's going on here. Then we can at least wail the right question into the swaddling band of darkness, or, if it comes to that, choir the proper praise." Annie Dillard
|
|
|
|
 |
|
 |
Hi all, I am frustrated after week of searching for reason to unresolved import error from LoadLibrary function trying to load my own DLL compiled with /MD (which uses custom [same computer and same VS2005] compiles of Proj 4, Geos 3.3.1, SpatiaLite 3.0.0 beta1 and SQLite3 - all compiled with /MD as well).
I have looked into it using Dependency Walker and the reason surprisingly seems to be kernel32.dll.
There are missing following imports:
InterlockedCompareExchange
InterlockedDecrement
InterlockedIncrement
InterlockedExchange
I do not use those in my code, but for example msvcr80.dll internally does.
DLLs work fine on my Vista x64 notebook and also work fine on another x64 Win7, but not on mine - compile machine.
I have installed correct redist. and so on, but the main problem is that IT DOES NOT WORK ON DEV MACHINE!!!
Did you ever seen this? I can compile it, but can not load it
I can load separately Proj, Geos and SQLite, but can not load SpatiaLite.
My system:
Windows 7 x64
Visual Studio 2005 (with needed service packs)
Thanks, Dusan
modified 13 Nov '11.
|
|
|
|
 |
|
 |
You did not say exactly what the LoadLibrary error is. Have you resolved this already?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
 |
|
 |
Yes I did. Error was due to different version of SQLite than I link in system32 directory.
|
|
|
|
 |
|