November 13, 2014
All on the same line... That makes a lot more sense.  Sorry, I probably just didn't understand what you meant.  I'll do that now and see if I can't get this working.  Then I'll try to get it working in a game.  I think I'll have to come up with something to add a delay in between the chat key down and chat key up, as without that, it didn't work with AHK.

I have this error now:

D:\Documents\Other\Hotkeys\D>dmd Keybinds.d simpledisplay.d color.d
Keybinds.d(11): Error: undefined identifier KEYEVENTF_UNICODE

Not sure what to do at this point.
November 13, 2014
On Thursday, 13 November 2014 at 23:54:13 UTC, Casey wrote:
> D:\Documents\Other\Hotkeys\D>dmd Keybinds.d simpledisplay.d color.d
> Keybinds.d(11): Error: undefined identifier KEYEVENTF_UNICODE

That should have been on the last line of the file, maybe it just got cut off in the copying process.

you can add it back:

enum KEYEVENTF_UNICODE = 0x4;

to the bottom.
November 13, 2014
On Thursday, 13 November 2014 at 23:54:13 UTC, Casey wrote:
> All on the same line... That makes a lot more sense.  Sorry, I probably just didn't understand what you meant.  I'll do that now and see if I can't get this working.  Then I'll try to get it working in a game.  I think I'll have to come up with something to add a delay in between the chat key down and chat key up, as without that, it didn't work with AHK.
>
> I have this error now:
>
> D:\Documents\Other\Hotkeys\D>dmd Keybinds.d simpledisplay.d color.d
> Keybinds.d(11): Error: undefined identifier KEYEVENTF_UNICODE
>
> Not sure what to do at this point.

Now I feel like a real idiot.  It's telling me there's an error on line 11 if I'm not mistaken.  I'm going to see if I edited your code by mistake and report back here.

Yep, it didn't give an error this time around.  However when I run the .exe I get your popup window and a blank terminal.  Pressing all the F keys does nothing.
November 14, 2014
On Thursday, 13 November 2014 at 23:59:59 UTC, Casey wrote:
> On Thursday, 13 November 2014 at 23:54:13 UTC, Casey wrote:
>> All on the same line... That makes a lot more sense.  Sorry, I probably just didn't understand what you meant.  I'll do that now and see if I can't get this working.  Then I'll try to get it working in a game.  I think I'll have to come up with something to add a delay in between the chat key down and chat key up, as without that, it didn't work with AHK.
>>
>> I have this error now:
>>
>> D:\Documents\Other\Hotkeys\D>dmd Keybinds.d simpledisplay.d color.d
>> Keybinds.d(11): Error: undefined identifier KEYEVENTF_UNICODE
>>
>> Not sure what to do at this point.
>
> Now I feel like a real idiot.  It's telling me there's an error on line 11 if I'm not mistaken.  I'm going to see if I edited your code by mistake and report back here.
>
> Yep, it didn't give an error this time around.  However when I run the .exe I get your popup window and a blank terminal.  Pressing all the F keys does nothing.

Nevermind, working now.
November 14, 2014
Well, I edited the code to add the chat button, and as I feared it didn't recignise it in game.  However, if I manually press the chat button it'll work fine, so all I need to do is add that delay in, then fine tune it to add all of the different messages I need now.

1)What part of this do I need to keep when adding the second hotkey?  Include an example if possible.  I find it hard to understand what is necessary to repeat and what I can just include once.

2)All I need to do at the moment to enable this to work is to add a ~1ms delay from the time the chat key is pressed down, and when it is pressed up.  Then it /should/ funtion in game properly.

3)It's a personal preference of mine to not have the chat window pop up like it does, nor the terminal popup.  This is a minor request, so I don't need it immediately.  Is there any way to make those disappear?

4)I'd like the first hotkey to be 0 + 1 on the numpad.  Numlock is always enabled on my keyboard, so I can't use arrows or anything like that.  The second set of hotkeys would be Ctrl + Del/End/PgDn/Insert/Home/PgUp, each one sending a different message.

5)Is there any way to pause the commands?  I have one hotkey set to Ctrl + Delete, and it gets really annoying when I try to Delete a full word but instead I send a chat message.  I think that I could activate and pause it with another hotkey, something like ctrl + numpad 0.  That should be something I'd never press.

I'm going to see if I can't figure everything above out on my own.  Maybe I'll start to learn it a bit more.  I'm also assuming I'll need another package to be imported if I am to add that delay, but it might already be in one of these.

Thanks so much everyone for your help.  It really means a lot to me.
November 14, 2014
Aha!  I found a sleep command.

On this page here:

http://forum.dlang.org/thread/diuepu$2ebg$1@digitaldaemon.com

Looks like I'd do something like this

[code]
import std.c.time
msleep(1)
[/code]

Now I'm looking into if there's a way to send a key down, and then up.  I don't think this will be too easy to find though.
November 14, 2014
On Friday, 14 November 2014 at 02:08:22 UTC, Casey wrote:
> Well, I edited the code to add the chat button, and as I feared it didn't recignise it in game.  However, if I manually press the chat button it'll work fine

What exactly happened there?

> 1)What part of this do I need to keep when adding the second hotkey?  Include an example if possible.  I find it hard to understand what is necessary to repeat and what I can just include once.

The RegisterHotKey function will need to be called again with a new ID. Then, the WM_HOTKEY message will have to handle the other hotkey id too.

You can copy and paste every instance of hotkey_id to make a hotkey2_id in a pinch.

I know there's a lot of concepts behind the MSDN pages that aren't all newbie friendly (well, actually, there are pages on it to explain the concepts too, in the References part at the bottom of each page. You'll be in for many hours of reading though, it took me weeks to get going beyond copy/paste and it was /years/ before I knew all the concepts, but gotta start somewhere). Anyway, take a look at the pages to better understand what the code is doing - the concepts will make sense too once you see enough of it and in the mean time, it can help to explain the pieces in isolation.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms646309%28v=vs.85%29.aspx

http://msdn.microsoft.com/en-us/library/windows/desktop/ms646279%28v=vs.85%29.aspx

http://msdn.microsoft.com/en-us/library/ms646310%28v=vs.85%29.aspx

http://msdn.microsoft.com/en-us/library/ms646271%28v=vs.85%29.aspx

This is all Windows specific, of course, but the concepts apply to a lot of systems - if you can write Win32 code, you can do a lot of stuff.

> 2)All I need to do at the moment to enable this to work is to add a ~1ms delay from the time the chat key is pressed down, and when it is pressed up.  Then it /should/ funtion in game properly.

The easiest way would be to split up the part that does SendInput into two parts - notice how in the code, there were separate events for pressed and released. You'd need to split that up into two separate calls to SendInput with some kind of sleep in between. There's also a timestamp thing mentioned in the MSDN docs which might work but I'm not sure that would actually work.

> 3)It's a personal preference of mine to not have the chat window pop up like it does, nor the terminal popup.  This is a minor request, so I don't need it immediately.  Is there any way to make those disappear?

The terminal won't appear if you use the -L SUBSYSTEM thing from a previous post on the compile command at the end of the lit of files.

The window itself could be hidden with the ShowWindow system function, but then you'd have to consider: how will you close the program when you don't want the hotkeys registered anymore? Having a visible window makes that easy.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548%28v=vs.85%29.aspx

The hwnd ShowWindow needs is available through window.impl.hwnd, so like

ShowWindow(window.impl.hwnd, SW_HIDE);

i should add this to simpledisplay.d too...

> 4)I'd like the first hotkey to be 0 + 1 on the numpad.  Numlock is always enabled on my keyboard, so I can't use arrows or anything like that.  The second set of hotkeys would be Ctrl + Del/End/PgDn/Insert/Home/PgUp, each one sending a different message.

The Virtual Keys thing is the answer here. Search for virtual key codes on MSDN and you'll find this

http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx

Then search that page for "Numeric keypad 0 key" and you'll find the VK_NUMPAD0 name and number.

> 5)Is there any way to pause the commands?  I have one hotkey set to Ctrl + Delete, and it gets really annoying when I try to Delete a full word but instead I send a chat message.  I think that I could activate and pause it with another hotkey, something like ctrl + numpad 0.  That should be something I'd never press.


This is pretty straightforward: you can use an if clause with a variable in the WM_HOTKEY message to skip processing. Or, you could use UnregisterHotKey, passing the hwnd from the window and the ID number to turn it off entirely, then RegisterHotKey again later to turn it back on.

> I'm going to see if I can't figure everything above out on my own.  Maybe I'll start to learn it a bit more.  I'm also assuming I'll need another package to be imported if I am to add that delay, but it might already be in one of these.

core.thread is one you can import, that gives you Thread.sleep
http://dlang.org/phobos/core_thread.html#sleep

This isn't the way you'd do this in a real program - it is usually a bad idea to sleep the thread responsible for handling window messages because then it can become unresponsive, but as long as you only sleep for a few milliseconds at a time it shouldn't be an issue.
November 14, 2014
On Friday, 14 November 2014 at 03:51:17 UTC, Adam D. Ruppe wrote:
> On Friday, 14 November 2014 at 02:08:22 UTC, Casey wrote:
>> Well, I edited the code to add the chat button, and as I feared it didn't recignise it in game.  However, if I manually press the chat button it'll work fine
>
> What exactly happened there?
>
>> 1)What part of this do I need to keep when adding the second hotkey?  Include an example if possible.  I find it hard to understand what is necessary to repeat and what I can just include once.
>
> The RegisterHotKey function will need to be called again with a new ID. Then, the WM_HOTKEY message will have to handle the other hotkey id too.
>
> You can copy and paste every instance of hotkey_id to make a hotkey2_id in a pinch.
>
> I know there's a lot of concepts behind the MSDN pages that aren't all newbie friendly (well, actually, there are pages on it to explain the concepts too, in the References part at the bottom of each page. You'll be in for many hours of reading though, it took me weeks to get going beyond copy/paste and it was /years/ before I knew all the concepts, but gotta start somewhere). Anyway, take a look at the pages to better understand what the code is doing - the concepts will make sense too once you see enough of it and in the mean time, it can help to explain the pieces in isolation.
>
> http://msdn.microsoft.com/en-us/library/windows/desktop/ms646309%28v=vs.85%29.aspx
>
> http://msdn.microsoft.com/en-us/library/windows/desktop/ms646279%28v=vs.85%29.aspx
>
> http://msdn.microsoft.com/en-us/library/ms646310%28v=vs.85%29.aspx
>
> http://msdn.microsoft.com/en-us/library/ms646271%28v=vs.85%29.aspx
>
> This is all Windows specific, of course, but the concepts apply to a lot of systems - if you can write Win32 code, you can do a lot of stuff.
>
>> 2)All I need to do at the moment to enable this to work is to add a ~1ms delay from the time the chat key is pressed down, and when it is pressed up.  Then it /should/ funtion in game properly.
>
> The easiest way would be to split up the part that does SendInput into two parts - notice how in the code, there were separate events for pressed and released. You'd need to split that up into two separate calls to SendInput with some kind of sleep in between. There's also a timestamp thing mentioned in the MSDN docs which might work but I'm not sure that would actually work.
>
>> 3)It's a personal preference of mine to not have the chat window pop up like it does, nor the terminal popup.  This is a minor request, so I don't need it immediately.  Is there any way to make those disappear?
>
> The terminal won't appear if you use the -L SUBSYSTEM thing from a previous post on the compile command at the end of the lit of files.
>
> The window itself could be hidden with the ShowWindow system function, but then you'd have to consider: how will you close the program when you don't want the hotkeys registered anymore? Having a visible window makes that easy.
>
> http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548%28v=vs.85%29.aspx
>
> The hwnd ShowWindow needs is available through window.impl.hwnd, so like
>
> ShowWindow(window.impl.hwnd, SW_HIDE);
>
> i should add this to simpledisplay.d too...
>
>> 4)I'd like the first hotkey to be 0 + 1 on the numpad.  Numlock is always enabled on my keyboard, so I can't use arrows or anything like that.  The second set of hotkeys would be Ctrl + Del/End/PgDn/Insert/Home/PgUp, each one sending a different message.
>
> The Virtual Keys thing is the answer here. Search for virtual key codes on MSDN and you'll find this
>
> http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx
>
> Then search that page for "Numeric keypad 0 key" and you'll find the VK_NUMPAD0 name and number.
>
>> 5)Is there any way to pause the commands?  I have one hotkey set to Ctrl + Delete, and it gets really annoying when I try to Delete a full word but instead I send a chat message.  I think that I could activate and pause it with another hotkey, something like ctrl + numpad 0.  That should be something I'd never press.
>
>
> This is pretty straightforward: you can use an if clause with a variable in the WM_HOTKEY message to skip processing. Or, you could use UnregisterHotKey, passing the hwnd from the window and the ID number to turn it off entirely, then RegisterHotKey again later to turn it back on.
>
>> I'm going to see if I can't figure everything above out on my own.  Maybe I'll start to learn it a bit more.  I'm also assuming I'll need another package to be imported if I am to add that delay, but it might already be in one of these.
>
> core.thread is one you can import, that gives you Thread.sleep
> http://dlang.org/phobos/core_thread.html#sleep
>
> This isn't the way you'd do this in a real program - it is usually a bad idea to sleep the thread responsible for handling window messages because then it can become unresponsive, but as long as you only sleep for a few milliseconds at a time it shouldn't be an issue.

I do see your point about closing it, that is something to consider.  However, if I could minimize it to a try that would be better.

I can't figure out how to separate the key press down and key press up, but if I can figure that out I should be good to go.  I'll give everything mentioned here a try out tomorrow evening sometime.  Thanks so much!
1 2 3 4
Next ›   Last »