AutoHotkey Community

It is currently May 26th, 2012, 8:39 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 157 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8, 9, 10, 11  Next
Author Message
 Post subject:
PostPosted: June 27th, 2008, 9:40 pm 
Online

Joined: April 27th, 2008, 5:28 pm
Posts: 489
I am new to autohotkey. I tried your example 2 code and I get Call to non-existent function error message. I do not understand calling a function.

I created a GUI and would like to allow the user to change the color. Does this code below display windows color dialog box then return the color code in a variable called pcolor or color? Does it return hex or RGB code?

Here is your example 2 code.

;create gui and set text color

CmnDlg_Font( font := "Courier New", style := "s16 bold italic", color:=0xFF)

Gui Font, %Style% c%Color%, %Font%
Gui, Add, Text, ,Hello world..... :roll:
Gui, Show, Autosize
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 28th, 2008, 12:11 pm 
First, please use "code" and "/code" tags when posting code to the forum.

DataLife wrote:
I am new to autohotkey. I tried your example 2 code and I get Call to non-existent function error message. I do not understand calling a function.

See #Include and/or Libraries of Functions in the help file.
Which will tell you to either put the library file in the standard lib directory
or to use #Include in your script file.

DataLife wrote:
Does this code below display windows color dialog box then return the color code in a variable called pcolor or color? Does it return hex or RGB code?
Yes it displays a windows color dialog. As for the variables and return, you MUST READ the help file. See Function, parameters (especially 'byref') and return types.


Code:
   ;create gui and set text color
   #Include CmdDlg.ahk ; be sure to add path to CmdDlg.ahk if it is not in the same dir as your script
   CmnDlg_Font( font := "Courier New", style := "s16 bold italic", color:=0xFF)

   Gui Font, %Style% c%Color%, %Font%
   Gui, Add, Text, ,Hello world.....  :roll:
   Gui, Show, Autosize
return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 28th, 2008, 6:21 pm 
Online

Joined: April 27th, 2008, 5:28 pm
Posts: 489
I was able to see your common dialogs function work, thanks to your last reply.

thanks very much
DataLife


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 2nd, 2008, 4:10 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 774
Location: Texas, USA
v4.04

I just started to try to use the Open and Save functions and ran into problems.

The Save function doesn't generate a dialog at all. There appears to be extra junk in the first parameter. Should be an easy fix.

I'm having trouble using the "Filters" parameter. For example, I'm using "*.txt|*.ini" as the filter. The dialog is displayed with filters in place but no files are displayed if either filter is selected.

Thanks for your help.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 2nd, 2008, 7:55 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Quote:
There appears to be extra junk in the first parameter. Should be an easy fix.

THere was some reason for that junk, I remember, but looking at it now it looks like junk indeed :)

I'll check it during the day. Thx

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 2nd, 2008, 11:09 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
I checked it. Works OK, but you wrongly used filter. I put example on the first page. Check it out.

For instance:
Code:
CmnDlg_Save(hGui, "Select several files", "All Files (*.*)|Audio (*.wav; *.mp2; *.mp3)|Documents (*.txt)", "", "c:\")


In your case you could use

  • (*.ini;*.txt)
  • (*.ini)|(*.txt)


About the junk "-" in Save call, i removed it, althogh I know it had a purpose. Thats what happens when you don't comment your own work...

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2008, 1:26 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 774
Location: Texas, USA
majkinetor wrote:
... In your case you could use

  • (*.ini;*.txt)
  • (*.ini)|(*.txt)

I'll give it a try. Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2008, 1:56 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 774
Location: Texas, USA
v4.10

The new version appears to include a number of undocumented new features/methods. For example: The callback labels to the Find and Replace functions must now be to functions instead of subroutines. Without making these changes, the developers calls to the Find and Replace functions will just stop working.

You might want to rollback the new version until the updated documentation is ready.

Them be my thoughts...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2008, 3:48 am 
Offline

Joined: December 4th, 2006, 10:35 am
Posts: 561
Location: Galil, Israel
rollback not sound progressive.

posting additional older version may make more sense (if that is an issue).

_________________
Joyce Jamce


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2008, 2:25 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Ah, yes, sorry about that. I totaly forgot to note aboout those changes.
However it was available in documentation all the time. Perhaps you need to reload manual page. It shows that label is changed with function.

There will be no version keeping for this project.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2008, 2:36 am 
Online

Joined: April 27th, 2008, 5:28 pm
Posts: 489
I am using CmnDlg for the color dialog box. Why do I only get black custom colors on the color dialog box that pops up, instead of the rainbow of colors the windows color dialog box gives?

thanks
DataLife


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2008, 11:11 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Quote:
instead of the rainbow of colors the windows color dialog box gives?

OS doesn't give any rainbows, applications do that.
This part of the dialog and saving custom colors to registry may one day get implemented tho... its low priority for me and somebody else may do it.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2008, 2:25 pm 
Offline

Joined: December 4th, 2006, 10:35 am
Posts: 561
Location: Galil, Israel
@majkinetor,
am all for change & advancement,
and it was funny the first time,
but...

sure looking forward to your NEW AVATAR!

_________________
Joyce Jamce


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 1st, 2008, 6:59 am 
Offline

Joined: December 4th, 2006, 10:35 am
Posts: 561
Location: Galil, Israel
if helps, might have been looking for this regards cust colors.

something like this on dll return


Code:
  paChooseColor :=  NumGet(sCHOOSECOLOR,16)
   
    loop 16
   numput(numget(paChooseColor + 0, (a_index - 1) * 4),aChooseColor,(a_index - 1) * 4)   


  ;covert from rgb



and at top of function
Code:
   static aChooseColor, setup
   if !setup
      setup := "setup" . VarSetCapacity(aChooseColor, 64, 0)

_________________
Joyce Jamce


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Save bugs found
PostPosted: August 3rd, 2008, 11:48 am 
Offline

Joined: August 3rd, 2008, 11:16 am
Posts: 2
Location: England
I have only just joint the AHK forum and been using AHK for a month now but the wealth of support, examples and information on this forum has helped me use AHK from being a novice.
Now onto the feedback.
I need to choose a file to save some information to while in my script and thanks to majkinetor cmndlg module it did the trick except I have found the following problems and have (in my basic way) corrected them in my version of the the cmndlg_save2 script.

Firstly if the user typed in a filename and extention the function would return a file with two extentions
Secondly the function some how changes the A_WorkingDir - this took me ages to discover why my main script did not work when I included the cmndlg_save so I now temp store the workingDir and set it back at the end

If these findings are of any help perhaps they could be more elegantly coded in majkinetor master function.

Code:
CmnDlg_Save( hGui=0, Title="", Filter="", defaultFilter="", Root="", defaultExt="", flags="overwriteprompt HIDEREADONLY" ) {
tempworkdir =%A_workingdir%
   static OFN_CREATEPROMPT:=0x2000, OFN_DONTADDTORECENT:=0x2000000, OFN_EXTENSIONDIFFERENT:=0x400, OFN_FILEMUSTEXIST:=0x1000, OFN_FORCESHOWHIDDEN:=0x10000000, OFN_HIDEREADONLY:=0x4, OFN_NOCHANGEDIR:=0x8, OFN_NODEREFERENCELINKS:=0x100000, OFN_NOVALIDATE:=0x100, OFN_OVERWRITEPROMPT:=0x2, OFN_PATHMUSTEXIST:=0x800, OFN_SHOWHELP:=0x10, OFN_NOREADONLYRETURN:=0x8000, OFN_NOTESTFILECREATE:=0x10000
starterror:
   IfEqual, Filter, ,SetEnv, Filter, All Files (*.*)
   SplitPath, Root, RootFile, RootDir

   hFlags := 0x80000                        ;OFN_ENABLEXPLORER always set
   loop, parse, flags,%A_TAB%%A_SPACE%,%A_TAB%%A_SPACE%
      if A_LoopField !=
         hFlags |= OFN_%A_LoopField%

   VarSetCapacity( FN, 0xffff )
   VarSetCapacity( lpstrFilter, 2*StrLen(filter))
   VarSetCapacity( OFN ,90, 0)

   if RootFile !=
        DllCall("lstrcpyn", "uint", &FN, "uint", &RootFile, "int", StrLen(RootFile)+1)
   ; Contruct FilterText seperate by \0
   delta := 0                              ;Used by Loop as Offset
   loop, Parse, Filter, |
   {
      desc := A_LoopField,         ext := SubStr(A_LoopField, InStr( A_LoopField,"(" )+1, -1)
      lenD := StrLen(A_LoopField)+1,   lenE := StrLen(ext)+1            ;including /0

      DllCall("lstrcpyn", "uint", &lpstrFilter + delta, "uint", &desc, "int", lenD)
      DllCall("lstrcpyn", "uint", &lpstrFilter + delta + lenD, "uint", &ext, "int", lenE)
      delta += lenD + lenE
   }
   NumPut(0, lpstrFilter, delta, "UChar" )  ; Double Zero Termination

   ; Contruct OPENFILENAME Structure
   NumPut( 76,             OFN, 0,  "UInt" )    ; Length of Structure
   NumPut( hGui,          OFN, 4,  "UInt" )    ; HWND
   NumPut( &lpstrFilter,    OFN, 12, "UInt" )    ; Pointer to FilterStruc
   NumPut( 0,             OFN, 16, "UInt" )    ; Pointer to CustomFilter
   NumPut( 0,             OFN, 20, "UInt" )     ; MaxChars for CustomFilter
   NumPut( defaultFilter,    OFN, 24, "UInt" )    ; DefaultFilter Pair
   NumPut( &FN,          OFN, 28, "UInt" )    ; lpstrFile / InitialisationFileName
   NumPut( 0xffff,          OFN, 32, "UInt" )    ; MaxFile / lpstrFile length
   NumPut( 0,             OFN, 36, "UInt" )     ; lpstrFileTitle
   NumPut( 0,             OFN, 40, "UInt" )     ; maxFileTitle
   NumPut( &RootDir,       OFN, 44, "UInt" )    ; StartDir
   NumPut( &Title,          OFN, 48, "UInt" )     ; DlgTitle
   NumPut( hFlags,          OFN, 52, "UInt" )    ; Flags
   NumPut( &defaultExt,    OFN, 60, "UInt" )    ; DefaultExt

res := DllCall("comdlg32\GetSaveFileNameA", "Uint", &OFN )
   IfEqual, res, 0, goto endreturn2

   adr := &FN,  f := d := DllCall("MulDiv", "Int", adr, "Int",1, "Int",1, "str"), res := ""
   if StrLen(d) != 3         ;windows adds \ when in root of the drive and doesn't do that otherwise
      d.="\"
  StringSplit, d_, d, "."
  if d_0>2
  {
    d_1 := SubStr(d, 1, -1)
    msgBox, 4144, %Title%, You have entered too many file extentions for the File`n%d_1%`n`nClick on a file or type just the file name
    goto starterror
    }
  goto endreturn1
endreturn2:
d=
endreturn1:
  setworkingdir %tempworkdir%
   return SubStr(d, 1, -1)
}

_________________
Regards
Martin


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 157 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8, 9, 10, 11  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot], Google [Bot], Google Feedfetcher, MSN [Bot], SKAN, Stigg and 21 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