 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
DataLife
Joined: 27 Apr 2008 Posts: 232
|
Posted: Fri Jun 27, 2008 9:40 pm Post subject: |
|
|
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.....
Gui, Show, Autosize
return |
|
| Back to top |
|
 |
Guest
|
Posted: Sat Jun 28, 2008 12:11 pm Post subject: |
|
|
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 |
|
|
|
| Back to top |
|
 |
DataLife
Joined: 27 Apr 2008 Posts: 232
|
Posted: Sat Jun 28, 2008 6:21 pm Post subject: |
|
|
I was able to see your common dialogs function work, thanks to your last reply.
thanks very much
DataLife |
|
| Back to top |
|
 |
jballi
Joined: 01 Oct 2005 Posts: 537 Location: Texas, USA
|
Posted: Wed Jul 02, 2008 4:10 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 4116 Location: Belgrade
|
Posted: Wed Jul 02, 2008 7:55 am Post subject: |
|
|
| 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 _________________
 |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 4116 Location: Belgrade
|
Posted: Wed Jul 02, 2008 11:09 am Post subject: |
|
|
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... _________________
 |
|
| Back to top |
|
 |
jballi
Joined: 01 Oct 2005 Posts: 537 Location: Texas, USA
|
Posted: Thu Jul 03, 2008 1:26 am Post subject: |
|
|
| majkinetor wrote: | ... In your case you could use
- (*.ini;*.txt)
- (*.ini)|(*.txt)
|
I'll give it a try. Thanks. |
|
| Back to top |
|
 |
jballi
Joined: 01 Oct 2005 Posts: 537 Location: Texas, USA
|
Posted: Thu Jul 03, 2008 1:56 am Post subject: |
|
|
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... |
|
| Back to top |
|
 |
Joy2DWorld
Joined: 04 Dec 2006 Posts: 537 Location: Galil, Israel
|
Posted: Thu Jul 03, 2008 3:48 am Post subject: |
|
|
rollback not sound progressive.
posting additional older version may make more sense (if that is an issue). _________________ Joyce Jamce |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 4116 Location: Belgrade
|
Posted: Thu Jul 03, 2008 2:25 pm Post subject: |
|
|
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. _________________
 |
|
| Back to top |
|
 |
DataLife
Joined: 27 Apr 2008 Posts: 232
|
Posted: Wed Jul 09, 2008 2:36 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 4116 Location: Belgrade
|
Posted: Wed Jul 09, 2008 11:11 am Post subject: |
|
|
| 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. _________________
 |
|
| Back to top |
|
 |
Joy2DWorld
Joined: 04 Dec 2006 Posts: 537 Location: Galil, Israel
|
Posted: Wed Jul 09, 2008 2:25 pm Post subject: |
|
|
@majkinetor,
am all for change & advancement,
and it was funny the first time,
but...
sure looking forward to your NEW AVATAR! _________________ Joyce Jamce |
|
| Back to top |
|
 |
Joy2DWorld
Joined: 04 Dec 2006 Posts: 537 Location: Galil, Israel
|
Posted: Fri Aug 01, 2008 6:59 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
interactive dj
Joined: 03 Aug 2008 Posts: 2 Location: England
|
Posted: Sun Aug 03, 2008 11:48 am Post subject: Save bugs found |
|
|
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 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|