AutoHotkey Community

It is currently May 27th, 2012, 1:47 am

All times are UTC [ DST ]




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 237 posts ]  Go to page Previous  1 ... 12, 13, 14, 15, 16  Next
Author Message
 Post subject:
PostPosted: January 16th, 2010, 3:01 am 
Offline

Joined: November 30th, 2008, 1:51 pm
Posts: 73
@Lexikos
It seems those lines should be...
Code:
output_var.ByteLength() = is_binary_clipboard ? bytes_actually_read
         : (VarSizeType)_tcslen((LPCTSTR) output_buf) * sizeof(TCHAR);

The original code uses bytes_actually_read - 1, but after I read the current code I think it shouldn't be -1.

@fincs
Please read the codes in os_version.cpp, Win95orLater, Win98orLater, and WinMeorLater are set only when the system is Win9x.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 16th, 2010, 10:33 am 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
Ah, I knew I was missing something :p

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 16th, 2010, 4:55 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
jackieku wrote:
The original code uses bytes_actually_read - 1, but after I read the current code I think it shouldn't be -1.
I think that would make it inaccurate. See below:
Code:
-- script2.cpp/BIF_StrLen()
? aParam[0]->var->Length() + aParam[0]->var->IsBinaryClip() // i.e. Add 1 if it's binary-clipboard, as documented.

-- var.cpp/AssignClipboardAll()
mByteLength = actual_space_used - sizeof(TCHAR); // Omit the final zero-byte from the length in case any other routines assume that exactly one zero exists at the end of var's length.

I suppose it was originally intended to use the last byte of the binary clipboard data as the variable's null-terminator (while still including it in StrLen()), but since it isn't necessarily going to be zero (null) when read from an arbitrary file, it might not be safe.

Perhaps we should change mByteLength to match the actual size of the data, and also ensure the usual null-terminator is present (remove the - 1 from A below). Running the script below caused two assertion failures, leading me to lines A and B.
Code:
Clipboard := "TEST"
a := ClipboardAll
b := a
Code:
--A: var.cpp/AssignClipboardAll()
if (!Assign(NULL, space_needed - 1, true, false))

--B: var.cpp/AssignBinaryClip()
if (!Assign(NULL, source_var._CharLength()))
...
LPVOID binary_contents_max = (char *)binary_contents + source_var.mByteLength + sizeof(TCHAR);

--C: script.cpp/Perform()
? ARGVARRAW2->Length() + 1 // +1 to include the entire 4-byte terminator, which seems best in this case.

A should be SetCapacity() as space_needed is in bytes. It would make sense to add aExactSize=true, aObeyMaxMem=false to B, for consistency with A and because it is unlikely that the variable will need the extra space.

There's may be something else I've missed.


Edit - Hmm, the following shows "1,0" on AutoHotkeyU whereas it should show ",-2" ;)
Code:
MsgBox % DllCall("MulDiv", "int", 2, "interchangable", 4, "integer", 8, "intriguing") "," ErrorLevel
I'll take care of this one...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 20th, 2010, 3:09 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
In the current commit, Debugger::OutputDebug and Debugger::FileAppend allocate memory via tmalloc and never free it. I'll be replacing it with something like the following, which avoids any allocations if the response buffer is already large enough (i.e. from a previous packet):
Code:
int Debugger::WriteStreamPacket(LPCTSTR aText, LPCSTR aType)
{
   int err;
   size_t aTextLen = (_tcslen(aText)+1) * sizeof(TCHAR);
   mResponseBuf.WriteF("<stream type=\"%s\">", aType);

   // We could calculate the total required size in advance, but it would offer
   // minimal benefit to performance and significantly impact readability:

   DEBUGGER_EXPAND_RESPONSEBUF_IF_NECESSARY(DEBUGGER_BASE64_ENCODED_SIZE(aTextLen));
   mResponseBuf.mDataUsed += Base64Encode(mResponseBuf.mData + mResponseBuf.mDataUsed, (char*) aText, aTextLen);
   mResponseBuf.Write("</stream>");
   return SendResponse();
}

void Debugger::OutputDebug(LPCTSTR aText)
{
   if (!mHasStdErrHook)
      OutputDebugString(aText);
   else
      WriteStreamPacket(aText, "stderr");
}

bool Debugger::FileAppend(LPCTSTR aText)
{
   if (!mHasStdOutHook)
      return _fputts(aText, stdout) >= 0;
   else
      return WriteStreamPacket(aText, "stdout") == DEBUGGER_E_OK;
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Convert .ahk to .exe
PostPosted: January 27th, 2010, 1:27 pm 
Hi, is there any way how to transfer scripts created using your unicode AHK from .ahk to .exe file?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2010, 10:30 am 
Offline

Joined: March 23rd, 2006, 2:20 pm
Posts: 128
Quote:
ahk --> exe?

Yes
AutohotkeySC.bin is in the zip


Report this post
Top
 Profile  
Reply with quote  
 Post subject: URLDownloadToFile
PostPosted: February 2nd, 2010, 2:33 pm 
Offline

Joined: April 24th, 2009, 5:24 pm
Posts: 9
Am I right in thinking that URLDownloadToFile is not working in AHKU?

_________________
Scribbly


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: URLDownloadToFile
PostPosted: February 2nd, 2010, 3:52 pm 
Offline

Joined: November 30th, 2008, 1:51 pm
Posts: 73
scribbly wrote:
Am I right in thinking that URLDownloadToFile is not working in AHKU?

It works here.
Please try the Unicode build of AutoHotkey_L (see the first post) first. If it fails, please give us more details about your problem.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: URLDownloadToFile
PostPosted: February 3rd, 2010, 12:27 am 
Offline

Joined: April 24th, 2009, 5:24 pm
Posts: 9
jackieku wrote:
scribbly wrote:
Am I right in thinking that URLDownloadToFile is not working in AHKU?

It works here.
Please try the Unicode build of AutoHotkey_L (see the first post) first. If it fails, please give us more details about your problem.


OK Thanks. I thought I saw a previous post that questioned if it was done, so I only tried once.

I'll investigate further, thanks

_________________
Scribbly


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 6:48 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
I tested using the following:
Code:
UrlDownloadToFile, http://www.autohotkey.com/forum/viewtopic.php?p=328839#328839, %A_Desktop%\test.html
MsgBox % ErrorLevel

In L43 Unicode build there is a slight delay, then the command returns with ErrorLevel=1 and no file is created.
In L43 ANSI build, it completes successfully.

scribbly, please confirm how you were specifying the path for UrlDownloadToFile. I've identified an issue with A_Desktop and similar built-in variables (specifically, ones which use ReadRegString) which prevents the code above and below from working correctly:
Code:
MsgBox %A_Desktop%\test.html  ; omits \test.html

For the time being, the following appears to work:
Code:
MsgBox % A_Desktop "\test.html"
It should be fixed in the next revision.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 2:59 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Hello.

I am trying to use Spell module with Unicode dictionaries. The module is very simple and it consist of several wrapped dll calls.

I used this code to tryout Serbian dictionary.

Code:
  word = абажуре

  hSpell := Spell_Init("dic\sр.aff", "dic\sr.dic")
  enc := SPell_GetEncoding(hSPell)
  MsgBox % enc  ; should be UTF-8

  msgbox % "Word: " word "`n" Spell_Spell(hSpell, word)   
return

#include Spell.ahk


Spell_Spell takes the word and checks if it exists in the dictionary. It works correctly with English example. but fails for Serbian dict. I also tried Latin dict with same effects.

I didn't try in to do the same in C but I thought its not needed because those are standard OpenOffice dictionaries.

Can you maybe help ?
TIA.

_________________
Image


Last edited by majkinetor on February 3rd, 2010, 10:43 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 3:27 pm 
Offline

Joined: April 24th, 2009, 5:24 pm
Posts: 9
Lexikos wrote:
I tested using the following:
scribbly, please confirm how you were specifying the path for UrlDownloadToFile. I've identified an issue with A_Desktop and similar built-in variables (specifically, ones which use ReadRegString) which prevents the code above and below from working correctly:
Code:
MsgBox %A_Desktop%\test.html  ; omits \test.html

For the time being, the following appears to work:
Code:
MsgBox % A_Desktop "\test.html"
It should be fixed in the next revision.


I think you've nailed it, my code:
Code:
   
sFile = %A_SCRIPTDIR%\full.html
...
URLDownloadToFile, %sURL%, %sFile%


I presume %A_SCRIPTDIR% is the culprit??

_________________
Scribbly


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 3:32 pm 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
@majkinetor:
Try the FileEncoding command, it may help...

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 6:29 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Nvm, i figured it out.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 4th, 2010, 11:24 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
scribbly wrote:
I presume %A_SCRIPTDIR% is the culprit??
No, A_ScriptDir is based on a static string calculated at startup, and does not use ReadRegString which is where the problem I encountered actually was/is. If it were the same problem, MsgBox %sFile% would show only the contents of A_SCRIPTDIR. From A_ProgramFiles to A_MyDesktop and a few others use ReadRegString.

The following completes successfully for me with the earlier L43 Unicode build:
Code:
sFile = %A_SCRIPTDIR%\full.html
sURL = http://www.autohotkey.com/forum/viewtopic.php?p=328643#328643
URLDownloadToFile, %sURL%, %sFile%
MsgBox % ErrorLevel
Did you check sURL and sFile immediately before URLDownloadToFile?
Code:
MsgBox %sURL%`n%sFile%
FileAppend, sURL=%sURL%, %sFile%  ; Confirm the script can write to sFile.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 237 posts ]  Go to page Previous  1 ... 12, 13, 14, 15, 16  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: oldbrother and 13 guests


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