AutoHotkey Community

It is currently May 26th, 2012, 10:19 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

Do you think that Prior VarSetCapacity() should be added automatically?
Yes, i'm tired of adding VarSetCapacity() manually.
No, i don't need it
You may select 1 option

View results
Author Message
PostPosted: July 6th, 2008, 10:53 pm 
Offline

Joined: March 11th, 2008, 11:36 pm
Posts: 291
Introduction
    Since using WinAPI requires general knowledges of programming. beginners never gets a chance to use WinAPI although it's possibly most powerful extension of AutoHotkey. When i'm not familar with WinAPI, i've so impressed by Lexikos's StructParser which helps novice to use structs without much Knowledge. so i tried to make something similar that would help beginners to use WinAPI easily. it may not so helpful to experts but at least it'll save your time. Finally, i would like to thank PhiLho for providing useful information about data types between WinAPI and AHK. (i've forgot the link at the moment. i'll add later)

Briefing
    This script will automatically parse MSDN's WinAPI function definition to AHK's DllCall form even with single hotkey.


Showcase
    Image


Usage
    1) Connect to MSDN with any browser (double clicking tray icon will do this)
    2) go to any function definition page
    3) select function definition as shown above then press Win + C
    4) parsed text will be stored in clipboard

Features
    1) Data types will be converted from WinAPI to AHK automatically
    2) If a function requires pointer suitable operator will be inserted automatically.
    3) Right DLL File name will be inserted automatically (see list at the bottom)
    4) Entry point (Ansi/Unicode) will be treated too. (always Ansi)
    5) If a function has return value, variable assignment will be inserted by hugarian notation.

Limitations
    1) You have to input arguments manually depend on MSDN definition.
    2) Parser will handle pointers automatically but it's not accurate always. so read MSDN's definition carefully!
    3) It does not parse structs. use Lexiko's StructParser or corrupt's ahkStructLib2 together
    4) It does not lookup Constants, use SKAN's Win32 Constants lookup together

Known Issues
    1) Gdi+ functions are not supported and will not. Take a look at tic's Gdi+ Library
    2) If a function contains CALLBACK, CONST will not work properly.
    3) This script is not perfect. This script does not guarantee at all though will work properly on most functions



Download EasyWinAPI_Rev_004.zip


i'd not post source code for now but later. included free MSDN icon borrowed from Here. Thanks to author
If you've encourtered that script doesn't parses properly report me the function name Thanks.


Supported Dll Files (If you call function that is in any other dll file, you have to type manually)
ADVAPI32.DLL / COMCTR32.DLL / COMDLG32.DLL / GDI32.DLL / GDIPLUS.DLL / IPHLPAPI.DLL / KERNEL32.DLL / MSVCRT.DLL / NTDLL.DLL / PSAPI.DLL / SHELL32.DLL / USER32.DLL / WININET.DLL / WINMM.DLL.

_________________
Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com


Last edited by heresy on July 9th, 2008, 9:28 am, edited 3 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 8th, 2008, 1:35 am 
Offline

Joined: July 21st, 2006, 12:26 am
Posts: 223
great

_________________
                                  [ profile | ahk.net | ahk.talk ]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 8th, 2008, 1:58 am 
Offline

Joined: January 12th, 2008, 7:45 pm
Posts: 131
wow, very nice!! Maybe this will help me understand Dllcalls etc...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 8th, 2008, 1:54 pm 
Offline

Joined: March 11th, 2008, 11:36 pm
Posts: 291
300W wrote:
Maybe this will help me understand Dllcalls etc...
Basically, understanding Dllcall/WinAPI needs knowledge of C/C++. i spend about 3 months to understand Dllcall and WinAPI without C/C++ knowledges which is inefficiency. i believe this script will bring you to Dllcall/WinAPI world as quickly as possible even if you never experienced C/C++ before. all you need to do is reading MSDN carefully for arguments and using Lexikos or corrupt's structures helper and SKAN's constants look up tool.

_________________
Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 8th, 2008, 2:29 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
C++ isn't necessary.
Only to better understand COM internals, but Win API is only C.

Thx for this script.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2008, 9:38 am 
Offline

Joined: March 11th, 2008, 11:36 pm
Posts: 291
@majkinetor
Thanks for the clarification majkinetor.

@Everyone
i've added a poll to decide adding prior VarSetCapacity() or not for the case that the DllCall requires pointer to return something. but the problem is that i have no idea to determine the optimal buffer size for each functions. sometimes it'll waste of memory sometimes returned Strings will be truncated due to the unoptimal capacity of the Var. however i think it'll be helpful to beginners. it'll look like below. let me hear your opinion about this issue.

Code:
VarSetCapacity(lpFilename, 128) ;128 is static capacity for all the functions
dwRes := DllCall("GetModuleFileNameA", "UInt", hModule, "Str", lpFilename, "UInt", nSize) ;nSize should be 128 but it will not be treated though

_________________
Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 14th, 2008, 7:07 pm 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
I vote Yes!

This is probably the best tool here on AHK imo.

With this script i can easily use the Windows API something i could now do before!

Thanks!!!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 19th, 2008, 5:52 am 
Offline

Joined: March 11th, 2008, 11:36 pm
Posts: 291
Fry wrote:
I vote Yes!

This is probably the best tool here on AHK imo.

With this script i can easily use the Windows API something i could now do before!

Thanks!!!
Thank you Fry, i'm glad that it helped you so. i'd like to see more opinions about VarSetCapacity() until i have clear solution. This tool can be more useful when used with SKAN's constants lookup tool and Lexikos's StructParser tool. with these tools, you can parse almost everything of Win32 API.

anyone have seen any parsing failure. please let me know

_________________
Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 19th, 2008, 5:56 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
Ooh. Definitely like this script! DllCalls have always been tricky for me... =x

Also, vote is yes. I hate having to set variable capacity


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 19th, 2008, 6:00 am 
Offline

Joined: March 11th, 2008, 11:36 pm
Posts: 291
Krogdor wrote:
Ooh. Definitely like this script! DllCalls have always been tricky for me... =x

Also, vote is yes. I hate having to set variable capacity


Thanks for your opinion Krogdor. i might add On/Off trigger for adding VarSetCapacity(). cause some people doesn't like it.

_________________
Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 24th, 2008, 12:22 pm 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Very nice! :D

Any idea of releasing the code in near future?

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 1st, 2008, 10:33 am 
Offline

Joined: December 19th, 2006, 2:14 pm
Posts: 72
Location: France
Nice one Heresy.

As Skan asked, would you mind sharing code ?

For vote : Yes with ability to disable through right click on systray icon.

Further suggestion, I know it's not officially supported, but digging deeper might help : parsing WDK.

Try parsing this :
Code:
NTSTATUS
  ZwOpenFile(
    OUT PHANDLE  FileHandle,
    IN ACCESS_MASK  DesiredAccess,
    IN POBJECT_ATTRIBUTES  ObjectAttributes,
    OUT PIO_STATUS_BLOCK  IoStatusBlock,
    IN ULONG  ShareAccess,
    IN ULONG  OpenOptions
    );

_________________
Assembler-coded MCode.ahk ASCII85.ahk library


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 29th, 2008, 9:56 pm 
Offline
User avatar

Joined: September 8th, 2008, 12:26 am
Posts: 1048
Location: Ploieşti, RO
http://www.autohotkey.com/forum/viewtopic.php?p=222648

I hope moderators won't move this one too.

_________________
AHK tools by Drugwash (AHK 1.0.48.05 and Win98SE)


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 25th, 2009, 11:21 am 
heresy wrote:
i'd not post source code for now but later.
Am I allowed to ask what the idea behind that is?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 2nd, 2010, 2:24 pm 
this is ridiculous

where is the source?

you really expect us to run your exe?


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: xXDarknessXx and 7 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group