Keystrokes to Windows

BlitzMax Forums/BlitzMax Programming/Keystrokes to Windows

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hi,
It seems that the 1.16 compiler does not like the previous method I was using to declare the functions.

I do not have time yet to go through and change everything but this code works for me. Try it out and see what happens. Do not forget to change the dll location
Const AU_Default:Int=(-2147483647)

Extern "win32"
  Function  WinExec(lpCmdLine$z,nCmdShow:Int)
End Extern

Local path$="D:\assari\blitzmax\autoit-v3\AutoItX"  'CHANGE THIS TO YOUR OWN LOCATION!!!
Global DLLHandle=loadlibraryA(path$+"AutoitX3.dll")
Global AutoIT_Init()"win32"=GetProcAddress(DLLHandle, "AU3_Init") 'Init(void);
Global AutoITX_ClipGet(szClip:Byte Ptr, nBufSize:Int)"win32"=GetProcAddress(DLLHandle, "AU3_ClipGet") 

Function AUTOIT_ClipGet$(nBufSize:Int=255)
Local stuff:Byte[nBufSize]
	AUTOITX_ClipGet(stuff,nBufSize)
	Local ret$=string.FromCString(stuff)
	Return ret$
End Function

Global AutoIT_ClipPut(szClip$z)"win32"=GetProcAddress(DLLHandle, "AU3_ClipPut") 'ClipPut(const char *szClip);
Global AutoIT_WinWaitActive(szTitle$z, szText$z,  nTimeOut:Long)"win32"=GetProcAddress(DLLHandle, "AU3_WinWaitActive") 
Global AutoIT_AutoItSetOption(szOption$z, nValue:Long)"win32"=GetProcAddress(DLLHandle, "AU3_AutoItSetOption") 
Global AutoITX_Send(f$z, nmode:Long)"win32"=GetProcAddress(DLLHandle,"AU3_Send")
Function AUTOIT_Send(f:String, nmode:Long=0)
   Return AUTOITX_Send(f,nmode)
End Function

Local r=AutoIT_Init()

AUTOIT_ClipPut("This text is in the Clipboard") 'Put text to clipboard
Local c$=AUTOIT_Clipget() 'Get text from clipboard

WinExec("Notepad.exe",1) 'runs notepad
AUTOIT_WinWaitActive("Untitled","",1000) 'Wait for Notepad window for 1000ms

AUTOIT_AutoItSetOption("SendKeyDelay", 10) ' Delay keypresses
AUTOIT_Send(c) 'send string to window
AUTOIT_Send("{ALTDOWN}{F4}{ALTUP}")  'send ALT-F4 to active window
'or AUTOIT_Send("!{F4})

End