Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Windows API


  • Please log in to reply
20 replies to this topic
Marcus013
  • Members
  • 5 posts
  • Last active: Sep 14 2012 10:27 AM
  • Joined: 14 Sep 2012
It is Windows Application Programming Interface. This basically means that Windows has built in functions that programmers can use. These are built into its DLL files. (Dynamic Link Library).

FrostByte
  • Members
  • 148 posts
  • Last active: Sep 16 2015 05:56 PM
  • Joined: 08 Nov 2012

Ah.. I seriously need to look into AutoHotkey_H.. Windows API don't confuse me. DllCall() DOES. I know what types of parameters to pass, and what to put into the call of the function, yet how to do such a task is beyond my mind. If anyone can help me with either AHK_H or _L that would be pleasant!

 

--Frosty


FrostByte and the Artemis Asylrum® Corporation
View my projects: Artemis Media Player

FrostByte62.com is down. I'll find another place to host my stuff soon...after I get done procrastinating some more. :)


guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011

DllCall has nothing to do with AHK_H

 

just post your DllCall question in the Support forum



FrostByte
  • Members
  • 148 posts
  • Last active: Sep 16 2015 05:56 PM
  • Joined: 08 Nov 2012

guest3456: I know DllCall has nothing to do with AutoHotkey_H. Windows API does. I looked through this topic and saw that AutoHotkey_H was different with Windows API. I've just figured out that I don't have a problem with DllCall() itself, it's Windows API, and how to call the API functions correctly.

I know what parameters to pass to the function, yet I honestly can't seem to get it right. This forum (programming) is something like the support forum, but for micellaneous languages, and Windows API (at least, I consider it to be) is like another language, to a point. I'm glad that there's a learning process to it, and how long the process is going to be: I don't know. I believe it will take me a while.

 

--Frosty


FrostByte and the Artemis Asylrum® Corporation
View my projects: Artemis Media Player

FrostByte62.com is down. I'll find another place to host my stuff soon...after I get done procrastinating some more. :)


guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011

let me explain

 

i'll try to start your learning process off right smile.png

 

the Windows API are simply functions for you to interact with different windows on the Windows OS. microsoft makes these functions available to make programming easier. these api functions are available through the use of .DLL files that you find in the C:\Windows\system32 directory. any  programming language that can call functions from a .dll can use the Windows API.

 

the Windows API has nothing to do with AHK_H either. the only thing that has to do with AHK_H is HotKeyIt's WinApi wrapper that he wrote to make Windows API programming object oriented. otherwise AHK_H would be no different than AHK_Basic or AHK_L

 

in the second post of the thread, HotKeyIt linked to his WinApi wrapper. here is his example of how its used:

(requires AHK_H and WinApi wrapper)

 

A:={} ;here an existing object will be passed to WinApi and functions will be added.
WinApi("AnimateWindow=WinAni sleep",A) ;enable only 2 function and rename AnimateWindow to WinAni

Gui,+LastFound
hwnd:=WinExist()
Gui,Show,Hide w400 h600

A.WinAni(hwnd,1000,0x20000|0x10) ;show Window
A.sleep(1000) ;sleep 1000 ms
A.WinAni(hwnd,1000,0x10000|0x10) ;hide Window
ExitApp

 

 

 

now, the same code could be written in normal AHK Basic like so, calling the same two Windows API functions (AnimateWindow and Sleep) directly through DllCall:

 

Gui,+LastFound
hwnd:=WinExist()
Gui,Show,Hide w400 h600

DllCall("AnimateWindow", "Uint", hwnd, "int", 1000, "Uint", 0x20000|0x10)
DllCall("Sleep", "int", 1000)
DllCall("AnimateWindow", "Uint", hwnd, "int", 1000, "Uint", 0x10000|0x10)
ExitApp

 

 

 

how do you know what values to pass to the AnimateWindow and Sleep functions that you call through the DllCall? well, you'd have to look on the MSDN site for the parameters:

AnimateWindow

Sleep

 

conveniently, HotKeyIt has also written a wrapper for the AnimateWindow api already for use with basic AHK:

http://www.autohotke...sier-than-ever/

many users have done similar things for commonly used Win Api calls if you browse through the Scripts forum

 

 

finally, to bring this full circle, most AutoHotkey basic commands themselves are merely wrappers of the Windows API !

for example, when you use the normal WinActivate command, it is merely wrapping the SetForegroundWindow api call

WinActivate, ahk_id %hwnd%

 

would be similar to doing this:

DllCall("SetForegroundWindow", "Uint", hwnd)

 

 

hope that helps

 

as i said before, if you need help with using DllCall, you should post in the Support forum because more people will see it. the Windows API is not like another language. it is merely the exposed API that allows different languages to interact with Microsoft Windows. 

 

 

here would be an example of calling the same Windows API function SetForegroundWindow from a different language, C#

 

class Program
{
static void Main(string[] args)
{
 System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcessesByName("notepad");
   if (p.Length > 0)
   { 
     SetForegroundWindow(p[0].MainWindowHandle);
   }
 }
}

DllImport("user32.dll")]
public static extern bool SetForegroundWindow(IntPtr hWnd);

 

according to

http://geekswithblog.../01/116510.aspx



FrostByte
  • Members
  • 148 posts
  • Last active: Sep 16 2015 05:56 PM
  • Joined: 08 Nov 2012

OMG THANKS guest3456! I'm guessing you helped... just maybe A LOT. I owe you one!!

 

--Frosty


FrostByte and the Artemis Asylrum® Corporation
View my projects: Artemis Media Player

FrostByte62.com is down. I'll find another place to host my stuff soon...after I get done procrastinating some more. :)