Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 4 Jahren, 1 Monat
Letzter Beitrag:
vor 4 Jahren, 1 Monat
Beteiligte Autoren:
Tor-Bjarne, Peter Holemans, Yogi Yang

Help with API

Startbeitrag von Tor-Bjarne am 21.03.2014 12:03


Using WinDev v18 ,01a180063c

I cant get the Sendkey(keys,handle) to work, gets red in editor (I send Bug report to PC-Soft later).

So I was planning to prototype an API to get the job done.

But since I`m fairly new to WinDev I wonder if I could get help prototyping the function in WinDev.

MS Definition is:

_In_ UINT nInputs,
_In_ LPINPUT pInputs,
_In_ int cbSize

I Tried something like:

grScaleval = 23.12345
S is string = grScaleval
i is int = Length(s)
n is int = Length(s)


I know this is wrong since it dont work :) - But I could not find a n = SizeOf(s), or not shure if S is an correct array og characters and so fort.
Link til MS Definition

Any tips would be great :)



Hi Tor-Bjarne,

A few things I need to know first:
- Is the API (DLL) 32 or 64 bit
- Is your WX app 32 or 64 bit

Some remarks on your code:
- To communicate with API's you can't use WX strings
- API's in general communicate via memory pointers (typically e.g. a variable lpxxx stands in C for Long Pointer xxx), meaning you should pass your variables by reference (the memory pointer) by using the ampersand...

So you certainly need to recode your call into something like:

grScaleval is ASCII string on 256 (We need to know the max length in bytes of the possible input string)
grScaleval = "23.12345"
i is unsigned int on 4 bytes = Length(grScaleval) (32bit DLL = 4 bytes / 64bit DLL = 8 bytes)
n is int on 4 bytes = Length(grScaleval)

Just my 2 cents,

Peter H.

von Peter Holemans - am 21.03.2014 13:40
Hello Tor-Bjarne,

Personally I would advise you to check out AutoIT. You can either use its DLL or ActiveX to send Keys and much much more! It is very powerful and we tend to use it a lot in our Apps developed in VB6.

I don't have any experience of using it from WX though.


Yogi Yang

von Yogi Yang - am 21.03.2014 15:03

Peter H, Tank you for your reply. - sorry forgot to say win32

Yogi - Will Check it out, I also got a clarion Dll called Sendkeys.dll that takes a Cstring and a handle as parameters that I can try.

My problem for the moment is a existing product needs to send weight as keyboard strings to an Excel book by monday.

I already have a lot of Excel functions in my app. But this particular (new) client wants to open a Excelbook, select a cell. And press the [Send weight] button on a scale and get the imputed value into excel. (one or selveral times in one or several books) så my usual "Take control over excel" functions does not work in this scenario, and sendkeys seems to make my problem/challange "go-away" :)

I offcourse (Stupid as I am), searched up Sendkeys in the documentation and noticed I could get away with a simple SendKey(grScaleval,SysWinActive()) and told the client it would be in the product within a hour.

This was cool until WinDev editor showed up in red compaining about "No syntax of SendKey is compatible"
- so I told my prospect/client Uh.. I need until monday to sort it out.
- Then I discovered in windows there`s no easy way to send some keyboard-pressed characters, needs structures, unions and what not. (And it`s the reason why I use tools as WinDev)

So I`m a bit stressed by the fact that a simple task suddenly gets complicated.

Then today, on top of all that, I discovered I can`t read, it is Sendkey not keys and the reason for WinDev to give an error is my first parameter (String) not the second (handle) - So after waisting a lot of my time, and some of yours I have to say "My BAD" WinDev`s SendKey works as a charm.

Procedure SendkeyS(grascaleval)
//Sends keys to whatever window is active (on top)
s is string = grScaleval

FOR i = 1 TO Length(s)
SendKey(s[[i TO i]],SysWinActive())


von Tor-Bjarne - am 22.03.2014 12:44
Hi T-B,

Why, as a temporary solution before implementing it via a Windows DLL or COM object, don't you make use of the Windows Clipboard.
You app, sends the scale value to the clipboard and a simple paste by the user copies it in the current application (Excel in your case).
Windev offers standard clipboard functions for that...

Just an idea,

Peter H.

von Peter Holemans - am 24.03.2014 08:29
Peter H,

As written in my previous post in the line "I cant read", I wrote "I got SendKey to work", so project is delivered and in test as we speak :)


von Tor-Bjarne - am 24.03.2014 11:47
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.