 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
ShyNovice Guest
|
Posted: Sat Apr 19, 2008 10:41 am Post subject: basic DllCall question |
|
|
Hello.
i'm trying to learn DllCall() thing.
i have tried like below. this returns no errorlevel (=0)
but doesn't affect as i expect
could anyone point me what's wrong?
| Code: | SetTitleMatchMode, 2
WinGet, hWND, ID, Notepad
DllCall("AnimateWindow", "hWnd", hWND, "uInt", 3000, "Str", AW_SLIDE) |
here is function reference for AnimateWindow
| Code: | http://msdn2.microsoft.com/en-us/library/ms632669(VS.85).aspx
BOOL AnimateWindow(
HWND hwnd,
DWORD dwTime,
DWORD dwFlags
); |
i never learn programming but i really wish to i can handle DllCall thing.
If you have any freetime, please inform me.
Thank you for reading. |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 1421
|
Posted: Sat Apr 19, 2008 9:34 pm Post subject: |
|
|
| http://msdn2.microsoft.com/en-us/library/ms632669(VS.85) wrote: | If the function fails, the return value is zero. The function will fail in the following situations:
...
* If the thread does not own the window. Note that, in this case, AnimateWindow fails but GetLastError returns ERROR_SUCCESS. |
I'm not sure how you would make your script the owner of a window like notepad.
btw: DllCall is very tricky for a beginner to use and M$DN doesn't make things all that much easier. When you read about flags like AW_SLIDE, that is simply a binary flag stored in a const variable with that particular name.
So the DllCall should look like this: | Code: | | DllCall("AnimateWindow", "UInt", hWND, "UInt", 3000, "UInt", 0x50002 ) |
where that last parameter is the sum of each binary flag you want to give the function. _________________ My Home Thread
More Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags ! |
|
| Back to top |
|
 |
ShyNovice Guest
|
Posted: Sun Apr 20, 2008 3:54 am Post subject: |
|
|
| [VxE] wrote: | So the DllCall should look like this: | Code: | | DllCall("AnimateWindow", "UInt", hWND, "UInt", 3000, "UInt", 0x50002 ) |
where that last parameter is the sum of each binary flag you want to give the function. |
Thank you for kindly answer.
i don't care which function it is, i just want to learn that usage of DllCall
now i got what's i mistook for hWND. (type)
but i still don't get that how i can get the 'binary flag'?
is it a binary that changes each time i call the function or is it a constant binary?
whtever it is, how to get the right binary?
msgbox % AW_SLIDE ?? |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 1421
|
Posted: Sun Apr 20, 2008 5:49 am Post subject: |
|
|
To find more info on items like AW_Slide, try google
With windows functions that take a number of flags in the form of an Int or DWord or Long (maybe some other types too, like 'byte'...), that parameter, in machine language looks like | Code: | | 0000 0000 0000 0100 0000 0000 0000 0001 |
those little red '1's are the flags, and their positions are interpreted by the function to mean different things. In the above example, the two flags would be equivalent to 0x40001. To use multiple flags, you can either binary-OR them ("|" in AHK ) or add them together. When passing such a number with a DllCall, it is not necessary to explicitly specify a hex number, an equivalent decimal will work just as well.
typically, when a c++ program uses a Dll, that library is linked to the compiled program so that all constants (like AW_SLIDE) are already defined and ready for use. I'm not sure how you would go about loading constants and enums from a Dll directly into an AHK script. I imagine it would be more troublesome than just googling the relevant constants and manually pasting them into a script  _________________ My Home Thread
More Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags ! |
|
| Back to top |
|
 |
ShyNovice Guest
|
Posted: Sun Apr 20, 2008 6:37 am Post subject: |
|
|
That answer was totally GREAT!!!
Thank you [VxE], i went to google after i requested additional explanation
and i found the constant 0x40001.
but it wasn't same as your answer. (0x50002)
every site and every header files talked to me that AW_SLIDE is 0x40001
which made me confused.
| Quote: | | you can either binary-OR them ("|" in AHK ) or add them together. |
i still don't get well about this 'adding' part.
but i'll find more on google
Once again, thank you [VxE] i could step to forward by your answer |
|
| Back to top |
|
 |
dmatch
Joined: 15 Oct 2007 Posts: 113
|
Posted: Mon Apr 21, 2008 3:21 pm Post subject: This may help |
|
|
Many of those flags/constants used in Windows API calls can be found using a tool for fetching constants posted by SKAN here:
http://www.autohotkey.com/forum/topic19766.html
Just thought this might help.
dmatch |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|