AutoHotkey Community

It is currently May 27th, 2012, 8:13 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 29 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: January 12th, 2012, 3:26 am 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
I have created a little GDI Printing Library (requires tics GDI+ Library)
which allows easy printing via GDI and GDI+.

I would like you to test the library and report back.
i'm especially interested if it works on all windows versions and on all AHK_L versions.

the SGDIPrint.ahk:
Code:
code removed due to protest.
http://www.autohotkey.com/forum/viewtopic.php?t=81795

Thanks for your time and help in advance.


Last edited by Zed Gecko on January 28th, 2012, 3:02 am, edited 8 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 12th, 2012, 2:31 pm 
Printed, scaned, uploaded here.
Tested on: Win XP, AHK_L 1.1.05.01, unicode build, 32 bit.
:)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 12th, 2012, 2:40 pm 
Offline

Joined: August 7th, 2011, 1:23 pm
Posts: 754
Printed on pdf and uploaded here. Configuration in my sig.

_________________
Win7 - Firefox 10.0.2 - AHK_L 1.1.07.00
Please bear with me and my English which is so bad at times that even I don't understand myself


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 12th, 2012, 4:11 pm 
Offline
User avatar

Joined: May 28th, 2011, 9:03 am
Posts: 466
Location: Germany
Tested on Vista 32 with AHK 1.1.05.06 U32 -> working!

M2C:
  • The original GDIP.ahk by tic is not 64-bit safe, but fincs made a 64-bit version some times ago you can find here.
  • If you want to make your own script 64-bit safe, you should take fincs' advice given in his posting.
  • I'd suggest to create additional functions for text output or use appropriate GDIP functions if available.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 12th, 2012, 9:05 pm 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
Thank you, lib Tester, Odlanir and just me,
from the results i am now assuming it works on all 32bit OS >= Win2k with both Unicode and ANSI AHK_L.

i'll try to implement support for the 64bit systems,
but i'll have to study some code (thanks again, just me, for the link)
and i have no 64bit-system, so i'll be totally dependent on friendly testers in this forum.

regarding additional functions,
i plan to implement a few helper funtions, like fill-rectangle-with-text and place-bitmap,
but i don't want to re-wrap the whole gdiplus-lib. anyway, if you have any ideas, fell free to mention them.

i'll work on the 64-bit issue first, though.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 13th, 2012, 11:58 pm 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
I have changed the lib to be 64bit compatible, i hope.

now i really need some 64bit-Testers.

please test the library with the test-script (make shure your gdip.ahk is >= v1.44) and report back. Thanks in advance.
SGDIPrint.ahk
Code:
code removed due to protest.
http://www.autohotkey.com/forum/viewtopic.php?t=81795


Last edited by Zed Gecko on January 28th, 2012, 3:01 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2012, 12:33 am 
I used fincs's 64bit compatible version of GDI+ library http://www.autohotkey.com/forum/post-470442.html.

And by running test-script.ahk with SGDIPrint.ahk included, I only get "Adobe PDF" in the message box and after that, the script crashes.

AHK_L 1.1.05.06 Unicode 64bit, Windows 7 64bit


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2012, 12:49 am 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
thanks, Guest.
could you (or someone else) run this script and report back with the last seen MsgBox?
Code:
code removed due to protest.
http://www.autohotkey.com/forum/viewtopic.php?t=81795


[or of coarse fix the lib, if you already know the problem :-)]


Last edited by Zed Gecko on January 28th, 2012, 3:02 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2012, 1:08 am 
I'm the above guest. The last seen message is "Loop 2" and the script crashes.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2012, 1:56 am 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
thanks again, could you try?
Code:
code removed due to protest.
http://www.autohotkey.com/forum/viewtopic.php?t=81795


Last edited by Zed Gecko on January 28th, 2012, 3:03 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2012, 2:48 am 
This time, I get the message "globfree" and the script crashes. I just noticed that uint in the line DllCall("GlobalFree","uint",&pPrinterEnum) should be ptr. But changing it to ptr in the line did not fix the script's crashing.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2012, 3:34 am 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
thanks again.
the globalfree-function-call was in there by accident.

i'm up for a new round

SGDIPrint.ahk
Code:
code removed due to protest.
http://www.autohotkey.com/forum/viewtopic.php?t=81795


Last edited by Zed Gecko on January 28th, 2012, 3:00 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2012, 4:11 am 
I get
error wrote:
---------------------------
test-script4.ahk
---------------------------
Error in #include file ...\Tests\SGDIPrint\Lib\SGDIPrint.ahk":
This DllCall requires a prior VarSetCapacity. The program is now unstable and will exit.

Line#
115: WinGet,MainhWnd,ID,ahk_pid %mainPID%
116: DetectHiddenWindows,%T_DetectHiddenWindows%
117: NULL := ""
119: VarSetCapacity(pPrinter , A_PtrSize, 0)
120: out := DllCall("Winspool.drv\OpenPrinter", "Ptr", &pPrinterName, "PtrP", pPrinter, "UInt", NULL, "Ptr")
122: sizeDevMode := DllCall("Winspool.drv\DocumentProperties", "Ptr", MainhWnd, "Ptr", pPrinter, "StrP", pPrinterName, "Ptr", &pDevModeOutput, "Ptr", &pDevModeInput, "UInt", 0)
124: VarSetCapacity(pDevModeOutput , sizeDevMode, 0)
---> 125: out2 := DllCall("Winspool.drv\DocumentProperties", "Ptr", MainhWnd, "Ptr", pPrinter, "StrP", pPrinterName, "Ptr", &pDevModeOutput, "Ptr", &pDevModeInput, "UInt", 2)
127: if ((dmOrientation = 1)||(dmOrientation = 2))
128: NumPut(dmOrientation, pDevModeOutput, 44, "Short")
129: if dmCopies is integer
130: {
131: if (dmCopies > 0)
132: NumPut(dmCopies, pDevModeOutput, 54, "Short")
133: }

The current thread will exit.
---------------------------
OK
---------------------------



By the way, I just noticed,
Zed Gecko wrote:
Code:
...
out := DllCall("Winspool.drv\EnumPrinters", "UInt", PRINTER_ENUM_NAME, "Str", NULL, "UInt", Level, "Ptr", 0, "UInt", 0, "UIntP", pcbNeeded, "UIntP", pcReturned)
pcbGranted := VarSetCapacity(pPrinterEnum , pcbNeeded)

out := DllCall("Winspool.drv\EnumPrinters", "UInt", PRINTER_ENUM_NAME, "Str", NULL, "UInt", Level, "Ptr", &pPrinterEnum, "UInt", pcbGranted, "UIntP", pcbNeeded, "UIntP", pcReturned)
msdn wrote:
BOOL EnumPrinters(
__in DWORD Flags,
__in LPTSTR Name,
__in DWORD Level,
__out LPBYTE pPrinterEnum,
__in DWORD cbBuf,
__out LPDWORD pcbNeeded,
__out LPDWORD pcReturned
);

pcbNeeded [out]

A pointer to a value that receives the number of bytes copied if the function succeeds or the number of bytes required if cbBuf is too small.
pcReturned [out]

A pointer to a value that receives the number of PRINTER_INFO_1, PRINTER_INFO_2 , PRINTER_INFO_4, or PRINTER_INFO_5 structures that the function returns in the array to which pPrinterEnum points.
So, the types for the last two parameters of EnumPrinters should be ptrp.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2012, 4:53 am 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
Quote:
So, the types for the last two parameters of EnumPrinters should be ptrp.
i'm not shure, but i don't think so. LPDWORD is afaik a pointer to a DWORD (which is 4bytes like UInt on both 32&64bit), the pointer to a pointer wold point to a 4byte value on 32bit and a 8byte value on 64bit.


Quote:
124: VarSetCapacity(pDevModeOutput , sizeDevMode, 0)
---> 125: out2 := DllCall("Winspool.drv\DocumentProperties", "Ptr", MainhWnd, "Ptr", pPrinter, "StrP", pPrinterName, "Ptr", &pDevModeOutput, "Ptr", &pDevModeInput, "UInt", 2)
Damned,
i have no idea what could cause that.
Help!
Can anybody explain or fix this issue?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2012, 5:45 am 
Zed Gecko wrote:
Damned,
i have no idea what could cause that.
Help!
Can anybody explain or fix this issue?
I placed this line in front of the line causing the error,
Code:
outputdebug, % "sizeDevMode: " sizeDevMode
And it said, -1.
msdn DocumentProperties wrote:
If the function fails, the return value is less than zero.
So, the previous function seems to be failed so it's not returning the size.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 29 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, migz99 and 66 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