wp83ec5f64.png
wpcff022fe.png
wpe05f0f24.png
wp7bd4f988.png
wp3a644f2b.png
wp794b7de1.png
wp6b867d8f.png
wpbe4b707d.png

 

System Wide Hot Key (continued)

 

Next let’s switch over to the window we created earlier and drop an Image control on to the window

 

Our next step will be to right click on the window and choose code.  Make sure you’re in the code area for the window and not the image area.

 

Now in the global section paste the following code;

 

 

 

 

 

Next in the initializations section we’re going to paste a little and explain a little.  Start by copying and pasting the following:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

You’ve probably encountered everything up until the line that reads “nAtomPointer = &bufAtomString”.  What we’re doing here is referred to as “pointing”.  So if you see the Ampersand symbol in code in windev, you know that it is referring to a “Pointer”.  And remember if you’re using an API that needs a callback, add an ampersand to the beginning of that procedure name in the actual call to API().

 

We’re created an integer variable called nAtomPointer.  This variable will hold the memory address of the string variable bufAtomString.  We will use this pointer in the “GlobalAddAtomA” function to gain a unique id that will later be passed to the RegisterHotKey function.

 

In the next line we actually make the API call using the API() function.  The first part of this call is the name of the DLL that function we need is located in.  Next is the actual name of the function we need, in this case “GlobalAddAtomA”.  And finally the nAtomPointer which is the pointer to the memory address for bufAtomString.

 

Now we need to get the Handle of the of our main window.  To do this we’ll use the “Handle()” function by passing the name of the window to it.

 

And then finally we will activate our hotkey by calling the API() function again with the appropriate parameters.

 

The final thing we need to do is use the WinDev “Event()” function to tell WinDev to watch for certain system messages.  In our case we need to look for the “WM_HOTKEY” message and fire the “ScreenCap” procedure if it’s found.  I have to say this is about the easiest method of creating an event I’ve seen.

I

 

Next Page

 

 

gnOrigX, gnOrigY is int

 

FunctionResult is boolean

hWnd is int

id is int = 2

fsModifiers is int = Null

vk is int = VK_F9

 

nAtomPointer is int

bufAtomString is Buffer

lpString is int

bufAtomString = "scooby"

nAtomPointer = &bufAtomString

 

id = API("KERNEL32","GlobalAddAtomA",nAtomPointer)

hWnd = Handle(winMain)

FunctionResult=API("USER32","RegisterHotKey",hWnd,id,fsModifiers,vk)

Event("ScreenCap", "*.", WM_HOTKEY)