PDA

View Full Version : Worm's "keystrokes.dll"



rhosk
03-01-2004, 10:35 AM
Hey Worm. Your keyboard.dll doesn't seem to work with the new upgrade (5.0.0.4). When and if you (or anyone else) get time, can you confirm this? Maybe different syntax again?

This is what I'm trying to use and it doesn't work -

function keypress()
prpwindow = Window.EnumerateTitles(false);
for handle, title in prpwindow do
result9 = String.Find(title, "Example - Notepad", 1, false);
if (result9 ~= -1) then
Window.SetOrder(handle, HWND_TOPMOST);
Keys="{ENTER}";
DLL.CallFunction(_SourceFolder.."\\KEYSTROKES.DLL", "KeyStroke", "\""..Keys.."\"", DLL_RETURN_TYPE_INTEGER, DLL_CALL_CDECL);
end
end
end

Then I call keypress(); with an on.Timer event. I get an error saying "Failed to find the specified function in the dll"

Worm
03-01-2004, 10:53 AM
I'll look into it, but try changing the call type to: DLL_CALL_STDCALL

Let me know if it doesn't work.

Worm
03-01-2004, 11:08 AM
Rhosk,

It doesn't seem to matter. It appears that the DLL is not working with 5.0.0.4

When I get home, I'll look through the source and see if I can figure out why.

In the mean time, Brett, any ideas as to why?

Brett
03-01-2004, 12:46 PM
No, I am not sure. Let me know if you can get it to work at home. Also try other DLL calls and see if they work...

EDIT:

This still seems to work in 5.0.0.4:


DLL.CallFunction ( _SystemFolder .. "\\User32.dll", "SetCursorPos", "0,0", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);

Worm
03-01-2004, 01:03 PM
I've tried using some of the other DLLs I've wrote, and they all seem to function properly. But for some reason this one doesn't seem to functioning as expected.

I'll update once I can pull the source code up and work with it.

Thanks!

Ted Sullivan
03-01-2004, 07:48 PM
Hmmm. I don't think we changed anything that would (read should) affect the DLL calling interface. Please let us know what you find. Strange...

rhosk
03-02-2004, 08:22 AM
Worm, just an update. I reverted back to version 5.0.0.3 and once again, it worked flawlessly. I hesitate to upgrade to .4 again because I had file association problems (which I have a support ticket for and a post elsewhere). Weird stuff.

Worm
03-02-2004, 08:32 AM
I'm looking into it right now... I'll let you know what I find.

Worm
03-02-2004, 08:55 AM
Hey Rhosk,

Can you try something for me?
Change your line that calls the DLL to this:

DLL.CallFunction(_SourceFolder.."\\KEYSTROKES.DLL", "KEYSTROKE", "\""..Keys.."\"", DLL_RETURN_TYPE_INTEGER, DLL_CALL_CDECL);

Let me know if it works, please.

Worm
03-02-2004, 08:59 AM
What I've found is that the call to the function is Case Sensitive now. In the source code I used all caps KEYSTROKE for the function name and alias. If you try to call the function in 5.0.0.4 with any other combinations i.e. KeyStoke, keystroke... The function is not found. But by using the same case as is defined in my source, the function works as expected.

rhosk
03-02-2004, 09:12 AM
Originally posted by Worm
Hey Rhosk,

Can you try something for me?
Change your line that calls the DLL to this:

DLL.CallFunction(_SourceFolder.."\\KEYSTROKES.DLL", "KEYSTROKE", "\""..Keys.."\"", DLL_RETURN_TYPE_INTEGER, DLL_CALL_CDECL);

Let me know if it works, please.

This works good (in ver .3 mind you).

Your conclusion makes sense. I tried everything to try and get that to work (except case sensitivity of course!). Good troubleshooting. That's probably one of the most powerful/useful dll's you've made so far that I know of! Thanks.

I'll play with version .4 here soon.

Worm
03-02-2004, 09:59 AM
I'm sure that its a Case Sensitivity issue. I took the line posted by Brett above and change the function to: SetCursorpos

and now it no workie either :)

Brett
03-02-2004, 12:10 PM
Worm,

I can't imagine that it ever really worked in a non-case-sentive way in any version. If it did I don't know why :)

Internally we call the Windows API call "GetProcAddress" in order to find the address of the function. According to Microsoft's documentation this call IS case-sensitive:


The spelling and case of a function name pointed to by lpProcName must be identical to that in the EXPORTS statement of the source DLL's module-definition (.Def) file. The exported names of functions may differ from the names you use when calling these functions in your code. This difference is hidden by macros used in the SDK header files. For more information, see Conventions for Function Prototypes. - MSDN Library

Is it possible that you changed the export table in different versions of the DLL? Has anyone tried the EXACT same DLL file on v5.0.0.4 and v5.0.0.3 - check, double check and then check again...

rhosk
03-02-2004, 12:19 PM
Has anyone tried the EXACT same DLL file on v5.0.0.4 and v5.0.0.3 - check, double check and then check again...
I did :)

I've been using this exact same dll since AMS 4.0x. And all of a sudden it didn't work with 5.0.0.4. Maybe a recent "Windows Update" issue? Don't know.

I had version 5.0.0.3 last night and checked - without a case issue. Re-installed the update .4 this morning, needs to be the exact case. Eh, weird, but it works :D

Worm
03-02-2004, 12:41 PM
I've tried this one on both .3 and .4

< .4 didn't seem to care whether it what case it was.


I'll be sure to call my functions with the proper case from now on though. Most of all, I'll try to be sure my examples are correct.

I guess it doesn't matter, as long as we know the solution.

Worm
03-02-2004, 01:14 PM
I plan to, but I haven't gotten my lazy self around to doing it yet. There always seems to be something more fun to do than writing documentation :D

willfreer
08-25-2004, 07:40 AM
Hi guys, On my project, I have a brief intro of 5 pages building with music untill it gets to the main menu.

I am trying to put a code on each on the intro pages that will make it jump to the main menu whenever someone clicked or hit any key during these first 5 pages.

any thoughts? Will

Intrigued
08-25-2004, 10:19 AM
Hi guys, On my project, I have a brief intro of 5 pages building with music untill it gets to the main menu.

I am trying to put a code on each on the intro pages that will make it jump to the main menu whenever someone clicked or hit any key during these first 5 pages.

any thoughts? Will
Here is an example I believe you may find useful:



-- Create a blank table to hold just about all of the ASCII codes AMS uses (this example uses 8-127, if I counted right!)
tblASCII = {};

-- for..do loop to populate the table tblASCII with the ASCII codes (key presses) we want to check for
for n=1, 121 do
Table.Insert(tblASCII, n, n);
end

-- Acutal check against the tblASCII table to see if one of the keyboard keys was pushed and then the application 'page jumps' to the main page
for index, data in tblASCII do
if e_Key == tblASCII[data] then
-- Dialog Messsage box for testing, example purposes -- You could use say a Dialog.TimedMessage dialog box even!
-- Dialog.Message("Notice!", "Key clicked, skipping Introduction video, flash, etc.!");
Page.Jump("Main");
end
end


Note: The code in my sample project puts all of the coding for this sample on the On Key event of the default 'Page1' page.

Sincerely,

willfreer
08-25-2004, 10:45 AM
Thanks, One more question where do I put this code?

Intrigued
08-25-2004, 10:49 AM
Thanks, One more question where do I put this code?
Note: The code in my sample project puts all of the coding for this sample on the On Key event of the default 'Page1' page.

One thing to note... this does not include Fucntion keys (F1, F2, F3, etc.) and a "couple..few" other keys. But, let me know if this will do the trick, if you would.

Again, the code goes on the On Key of the page(s) you want to have such active (able to be used).

Sincerely,

willfreer
08-25-2004, 02:37 PM
Thanks for the code but before I could put it in, my coworker said i should put a Skip into button on the first few slides. So I put it on the first 5 slides.

With the code on the button

on click - Audiostop

on enter - pagejump to "main menu"

off course it doesn't work hahaha,

The problem is I have a 8 second audio that I put in on the Project -Audio Settings, that does not stop until it is finished. even when the skip intro button is clicked. And another problem is that when it jumps it goes back from the main menu back into the intro pages.

Am i making any sense?

Will