AutoHotkey Community

It is currently May 27th, 2012, 12:02 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: December 29th, 2010, 6:35 pm 
I tried to run k3ph's spectacular x-mas script with the latest version of AHK_L and it didn't work. However, it runs fine using an original AHK 1.0.48. Can you tell me why?


Top
  
Reply with quote  
 Post subject:
PostPosted: December 29th, 2010, 9:46 pm 
I have found out that it must have something to do with the DllCall function as with AHK DllCall(A_Temp . "\BASS.dll\BASS_MusicLoad", UInt, mem, UInt, &file, UInt64, offset, UInt, length, UInt, flags, UInt, freq) returns a handle while it does not when run with AHK_L.

Using bass.dll and song.mo3 from k3ph's script (just comment out the
FileDelete commands and find them in your TEMP directory and copy them to the directory which the script is running in) and this
code

Code:
SetBatchLines,-1
Thread, NoTimers

BASS_Init(device,freq,flags,win,clsid){
   global
   BassDll:=DllCall("LoadLibrary", "str", "\BASS.dll")
   Return DllCall("\BASS.dll\BASS_Init", Int, device, Int, freq, Int, flags, UInt, win, UInt, clsid)
}

BASS_ChannelPlay(handle,restart){
   ;Return DllCall("\BASS.dll\BASS_ChannelPlay", UInt, handle, Int, restart)
   Return DllCall("\BASS.dll\BASS_ChannelPlay", UInt, handle, Int, restart, Cdecl Int)   
}

BASS_MusicLoad(mem,file,offset,length,flags,freq){
   Return DllCall("\BASS.dll\BASS_MusicLoad", UInt, mem, UInt, &file, UInt64, offset, UInt, length, UInt, flags, UInt, freq)
}

BASS_ChannelGetLength(handle,mode){
   Return DllCall("\BASS.dll\BASS_ChannelGetLength", UInt, handle, UInt, mode, UInt64)
}

BASS_ChannelBytes2Seconds(handle,pos){
   Return DllCall("\BASS.dll\BASS_ChannelBytes2Seconds", UInt, handle, UInt64, pos, Double)
}

BASS_ErrorGetCode(){
   Return DllCall("\BASS.dll\BASS_ErrorGetCode", Int)
}

BASS_Free(){
   global
   Return DllCall("\BASS.dll\BASS_Free", UInt, true),
             DllCall("FreeLibrary", UInt, BassDll)
}

onexit,exit
bass=BASS.dll
fullbass=bass
fullfile=song.mo3
; -------------- Init ------------------------------
BASS_Init(-1,44100,0,0,0)
; -------------- Load ------------------------------
hStream:=BASS_MusicLoad( False, fullfile, 0, 0, 0x40000+0x20000+0x1000, 44100)
MsgBox,,hstream,%hstream%
a:=BASS_ErrorGetCode()
MsgBox ,,ErrorCode, %a%,
; -------------- GetLength ------------------------------
hStream_time:=Floor(BASS_ChannelBytes2Seconds(hStream,BASS_ChannelGetLength(hStream,0)))
hStream_sleep:=hStream_time*1000
; -------------- Play ------------------------------
a:=BASS_ChannelPlay( hStream, 0)
MsgBox,,ChannelPlay,%a%
a:=BASS_ErrorGetCode()
MsgBox ,,ErrorCode, %a%,
sleep %hStream_sleep%

exit:
  BASS_Free()
  ExitApp


I get MessageBoxes as follows:

AHK: -1610612735 (a valid handle) / 0 (no error) / 1 (ChannelPlay successful) / 0 (no error)


AHK_L ANSI: -1610612735 / 0 / 1 / 0 --> however, this only works when the "Cdecl Int" in the DllCall to BASS_ChannelPlay is removed (see the commented line above), otherwise I get an empty string insted of 1 and it doesn't play anything


AHK_L Unicode: 0 (no handle) / 2 ( BASS_ERROR_FILEOPEN) / 0 (ChannelPlay failed) / 5 (BASS_ERROR_HANDLE)

What has to be changed to make the script run with AHK_L Unicode and why does it run with AHK_L ANSI only without "Cdecl Int"?


Top
  
Reply with quote  
 Post subject:
PostPosted: December 30th, 2010, 1:29 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
This thread is for discussion about the latest release, not for requesting help with incompatible scripts.
Quote:
Due to some fundamental differences between AutoHotkey and AutoHotkey_L (particularly Unicode and x64 builds), scripts written for AutoHotkey may not work as expected on AutoHotkey_L. For details of known compatibility problems and solutions, refer to the following:
Source: AutoHotkey_L (recently added)

Since this one is simple, I will post the answers:
  1. BASS expects ANSI strings, but the script is passing it a Unicode string. Replace UInt, &file with AStr, file.
  2. DllCall(..., Cdecl Int) was never valid, but in AutoHotkey Basic this error is not caught. Use quotation marks.
Quote:
Note: When specifying an argument type or return type that does not contain a space or asterisk, the quotes around it may be omitted.
Source: DllCall


Top
 Profile  
Reply with quote  
PostPosted: December 30th, 2010, 8:39 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Quote:
1.0.91.04 - December 29, 2010
Fixed (Unicode): RegExReplace omitted all text up to StartingPosition (broken by v1.0.90.00).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 1st, 2011, 12:56 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Quote:
1.0.91.05 - January 1, 2011
Fixed: Cleanup code in COM method calls was freeing the wrong parameters.
Fixed (ANSI): DllCall set incorrect length for wstr parameters on output.
Fixed: Variadic function calls were unstable when param object was empty.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2011, 5:31 am 
Offline

Joined: December 13th, 2006, 7:10 am
Posts: 118
I was away of AHK during a whole year. I'm very glad to see all of these inprovements.
I've read the roadmap, especially http://www.autohotkey.com/misc/AutoHotkey-v2.htm and I must say "yes!", breaking backward-compatibility would lead in a cleaner way to write scripts.

Happy New Year to everyone !

(2011 is really starting good)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot 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