AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GUI for AutoHotkey
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Fri Apr 09, 2004 10:23 pm    Post subject: GUI for AutoHotkey Reply with quote

Some ppl might already know this, but many would not.

the Au3GUIXP made by Larry, unlike his AutGUI for AU2 (which worked only with Au2), can be used with AutoHotKey to create great looking GUIs. Combined with the new Menu command in AHK in last version, one can create some very nice scripts.
(Thanx Chris & Larry)



a sample basic GUI script that also sends its output to a .ini file is given below. (run this script from the folder which has Au3GUIXP)

Code:
envset, GUI, title=Custom Title|background=15329769|action=9|file=GUI.ini|w=350|h=230
;adding  |exstyle=8 makes GUI always-on-top
;adding  |exstyle=4194304 makes a mirror image. ;)

envset, OBJ1, type=button|text=notepad|x=190|y=60|w=55|h=20|focussed=1|run=notepad
envset, OBJ2, type=input|text=some text|x=120|y=60|w=55|h=20
envset, OBJ3, type=icon|file=%windir%\cursors\dinosaur.ani|x=25|y=25|w=32|h=32|run=%comspec% /k
envset, OBJ4, type=combo|text=test1|x=80|y=100|w=200|h=21|data=Selection1;Selection2
envset, OBJ5, type=button|text=close|x=145|y=135|w=55|h=20|close=1|submit=1
envset, OBJ6, type=group|text=group|x=8|y=2|w=335|h=225
envset, OBJ7, type=radio|text=radio 1|x=212|y=170|w=85|h=15
envset, OBJ8, type=radio|text=radio 2|x=212|y=190|w=85|h=15
envset, OBJ9, type=checkbox|text=checkbox|x=93|y=170|w=75|h=15


runwait,au3guixp


available at http://www.hiddensoft.com/fileman/users/Larry/au3guixp.zip
_________________


Last edited by Rajat on Tue May 25, 2004 9:31 pm; edited 1 time in total
Back to top
View user's profile Send private message
dil
Guest





PostPosted: Tue Apr 13, 2004 12:43 am    Post subject: combo box gone mad Reply with quote

hi , great stuff you have here
im stuck with one problem , when using combo boxes

if on a window with a multiple of controls you select something on a combo box then save and exit,
the new selected values get written in the ini.

run the script again and change something on another control without touching the first combo box, you lose everything in gui.ini

i've tried all sort (to the best of my ability, im fairly new)
like, changing action=9 to different values,reading the ini when loading,load to variables then rewriting it again,with no luck.

any suggestions?

more scripts like this one please.
thanks
Back to top
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Tue Apr 13, 2004 3:30 am    Post subject: Reply with quote

its easy....if u want the values to stay in the .ini and want the new ones in a new file then change the statement '|file=GUI.ini' to maybe '|file=GUI1.ini' or something.

but maybe if u want to have that value in a script then just after the code above do this:
Code:
IniRead, value, GUI.INI, GUI, OBJ4

the %vlaue% variable holds ur selection. then u can just about do anything with the it.
like
Code:
msgbox,0,Result, The selection was %value%


or
Code:
IniWrite, %value%, Backup.ini, ComboSelection, GUI
(ofcourse the iniwrite above will stay only till you use it again to replace with new value)

Quote:
run the script again and change something on another control without touching the first combo box, you lose everything in gui.ini

this is designed to clean up entries left by old interface.
_________________
Back to top
View user's profile Send private message
dil
Guest





PostPosted: Wed Apr 14, 2004 9:06 pm    Post subject: Reply with quote

thanks for your help,
though this works,it involves a lot of ini reading and writing,i wondered
if i could use action=4
Quote:
4 = set the data to Environment Variables "GUI","OBJ1","OBJ2","OBJn"...


can i retrieve these variables just after runwait au3guixp
something like this perhaps

Code:
envset, GUI, title=Custom Title|background=15329769|action=4|w=350|h=230

envset, OBJ1, type=input|text=some text|x=120|y=60|w=55|h=20
envset, OBJ2, type=button|text=close|x=145|y=135|w=55|h=20|close=1|submit=1

runwait,au3guixp

;i want a message box to show what i typed in the input box here
msgbox,%OBJ1%


the msgbox,%OBJ1% definitely does not work or any variation with " in it.

if thats possible could you please let me know how to go about achieving this.

ps. i've got plenty more questions to come, keep you busy hey. thanks mate.
Back to top
Guest






PostPosted: Wed Apr 14, 2004 10:59 pm    Post subject: Reply with quote

well u've got a good question there... i tried it and had the same result as u did.

i'm not a pro at au3guixp either. its just that i shared an example GUI that might give new possibilities to AHK users.

well i guess larry might have an answer to that. u might try asking him at AU2 forum. www.hiddensoft.com/forum

he'll be glad and quick to help and will offer the best help u'll get on this subject... after all, he's coded it!!
Back to top
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Thu Apr 15, 2004 5:42 am    Post subject: Reply with quote

forgot logging on... the above post was by me.

i think ur question is already replied here:

http://www.hiddensoft.com/forum/index.php?showtopic=1965&hl=
_________________
Back to top
View user's profile Send private message
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Thu Apr 15, 2004 5:43 am    Post subject: Reply with quote

Chris this is an example of a case where envget is reqd (see link above).
_________________
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10464

PostPosted: Thu Apr 15, 2004 11:55 am    Post subject: Reply with quote

I browsed that topic but the need for EnvGet didn't jump out at me. Note that you can force an EnvGet using this example:

MyEnvVar = ; Make the script's own variable blank.
MyEnvVar = %MyEnvVar% ; Fetch the environment var into a script var.

If you still feel there's a need for EnvGet maybe you can give an example to illustrate.
Back to top
View user's profile Send private message Send e-mail
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Thu Apr 15, 2004 4:04 pm    Post subject: Reply with quote

Chris, first of all Thanx for the new version!... and sorry for not being specific about this reference... look at pg 2 (the same post) where the question is regarding working of 'action = 4' (probably 8th msg on the page)
and i tried this to get it done in AHK as u suggested.... it didn't work.

Code:
envset GUI, title=Custom Title|background=15329769|action=4|w=350|h=230
envset OBJ1, type=button|text=close|x=145|y=135|w=55|h=20|close=1|submit=1|focussed=1
envset OBJ2, type=combo|text=combo|x=80|y=100|w=200|h=21|data=ComboSelection1;ComboSelection2

runwait,au3guixp
OBJ2 =
OBJ2 = %obj2%
msgbox, %obj2%

_________________
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10464

PostPosted: Thu Apr 15, 2004 4:59 pm    Post subject: Reply with quote

Your code works for me if I comment out the "runwait,au3guixp" line (I don't have au3guixp installed). Can you think of any explanation for this?
Back to top
View user's profile Send private message Send e-mail
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Thu Apr 15, 2004 7:32 pm    Post subject: Reply with quote

to make things clear, this script (when running correctly) should return the text of the selection made in gui like Selection1 or Selection2, and not the OBJ# definition that's given in script.
u can try running the code examples (AU3) given by Larry on the above link to see what i mean.

now Chris maybe u should make a download of au3guixp... Smile its just ~26 kb download and all it requires it extracting the exe file to script's folder.
_________________
Back to top
View user's profile Send private message
dil
Guest





PostPosted: Thu Apr 15, 2004 8:12 pm    Post subject: Reply with quote

wow, looks like i've started something here,
still none the wiser, i'll let the pros sort this one out and wait till you guys find a solution.
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10464

PostPosted: Thu Apr 15, 2004 8:20 pm    Post subject: Reply with quote

I tried your code with both AutoIt2 and AutoIt3 and I get the same result as AutoHotkey. Maybe I'm doing something wrong, but if not it seems that Au3GuiXP's env. variables aren't being set or are lost before they can be retrieved by the script.

Here's the au3 version:
Code:
opt ("ExpandEnvStrings", 1)

envset ("GUI", "title=Custom Title|background=15329769|action=4|w=350|h=230")
envset ("OBJ1", "type=button|text=close|x=145|y=135|w=55|h=20|close=1|submit=1|focussed=1")
envset ("OBJ2", "type=combo|text=combo|x=80|y=100|w=200|h=21|data=ComboSelection1;ComboSelection2")

runwait ("au3guixp.exe")
msgbox (0, "title", "%obj2%")


Edit: Btw, I did run Au3GuiXP with the above tests. It's a nice piece of handiwork.


Last edited by Chris on Fri Apr 16, 2004 2:05 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Thu Apr 15, 2004 9:19 pm    Post subject: Reply with quote

there r 2 code examples posted by larry... (i've tested both) one requires the script to be in compiled form (process requirement) and other as itself starting a new process so passes the correct info.

this passes the selection to a new process (can be run as script)
Code:
EnvSet("GUI","action=4|run=" & @comspec & " /k echo %OBJ1%")
EnvSet("OBJ1","type=combo|data=goo;boo;doo|submit=1")
EnvSet("OBJ2","type=button|y=30|text=close|close=1")

Run("au3guixp")


this needs to be compiled and run (shows selection as messagebox)
Code:
If $CmdLine[0] = 1 Then Show()
EnvSet('GUI','action=4|run="' & @ScriptFullPath & '" parm')
EnvSet("OBJ1","type=combo|data=goo;boo;doo|submit=1")
EnvSet("OBJ2","type=button|y=30|text=close|close=1")

Run("au3guixp")

Func Show()
   MsgBox(4096,"Choice","You chose " & EnvGet("OBJ1"))
   Exit
EndFunc

_________________
Back to top
View user's profile Send private message
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Thu Apr 15, 2004 10:55 pm    Post subject: Reply with quote

this is what's really happening:
script creates obj definition -> available to au3guixp
au3guixp puts something in OBJ# var -> available to only the processes started by it.

this is something we do all the time when we use cmds in scripts like '%comspec% /c start %document%' (other processes don't know what's %document% is, but this instance of %comspec% does) i'm sorry if i don't make sense to someone... a bit technical, but i know i'm mostly right here.

but this discussion has unduly lengthened... so for me... this particular point ends here.... i'm still sticking with .ini method, it works and i'm content with it.
_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group