Home Download Screenshots Wiki Plugins Translations Developers Donate Forums/Help Contact Us |
StrokeIt
Such a question from you ? ! gemisigo, gemisigo
Declare Function SendMessage Lib "USER32" Alias "SendMessageA" ( _ ByVal hWnd As Long, ByVal Msg As Long, _ wParam As Any, lParam As Any) As Long any is string or long require[[alien]] local SendMessage= alien.User32.SendMessageA SendMessage:types{ret ='long', abi = 'stdcall','long','long','string','string'} or make it working with plugin.call
Yep, I'm familiar with SendMessage and that was my first idea, too, but I was quite sure there must be a more straightforward approach to send a message in Lua. Unfortunately I haven't found any. Most programming languages (at least those capable sending/posting messages) do not need such preparations. But it seems that Lua does. Not that I have problems with that, I just thought it would be nice to be able to do it simpler. I should have thought that because Lua is not windows-only. But you know, dope dies dast :) hiccup :D
By the way, thanks for your help, Leo :)
Next question :)
I have: local GetWindowThreadProcessId = alien.User32.GetWindowThreadProcessId GetWindowThreadProcessId:types{ret = 'long', abi = 'stdcall', 'long', 'pointer'} The 'long' is input, it's a handle to the window, the 'pointer' is a pointer to the variable that receives the identifier. My problem is that it is a pointer and it should point to an integer/long. Lua is dinamically typed. How do I make something to point to an integer typed variable? How do I create a pointer at all?? I can create a userdata typed variable local pointhere = alien.buffer(4) and do a call to local tid = GetWindowThreadProcessId(hwnd_mywindow, pointhere) The value in 'tid' is okay (it contains the threadid) but the value in 'pointhere' is unusable. It should store the processid, but I cannot cast it to an int/long. Alien has something (alien.toint or alien.tolong) that should do it but it fails with a very funny error message: lua: test.lua:32: bad argument #1 to 'toint' (userdata expected, got userdata). Any idea? EDIT: Okay, just to show that I'm smart and capable of improving myself, I'll answer my own question :D Oh, yes, did I mention that I'm humble, too? :D So, if anyone else is interested, the method is the following: local pointhere = alien.buffer(4) -- this creates a 4-byte buffer local tid = GetWindowThreadProcessId(hwnd_mywindow, pointhere) -- this fills tid and our 4-byte buffer local long_at_pointhere = pointhere:get(1, 'long') -- this tells that I want x bytes forming a 'long' value and starting at the first byte of the -- 'pointhere' buffer to be in 'long_at_pointhere' variable and let its type be 'long' I hope this helps those who meet the same difficulties I did. I there are any, of course. Edited 1 time(s). Last edit at 01/29/2010 03:00AM by gemisigo. |