Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

GUI for AutoHotkey


  • Please log in to reply
15 replies to this topic
Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
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)

Posted Image

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)

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.hiddensof... ... 3guixp.zip

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


dil
  • Guests
  • Last active:
  • Joined: --
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

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
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:
IniRead, value, GUI.INI, GUI, OBJ4
the %vlaue% variable holds ur selection. then u can just about do anything with the it.
like
msgbox,0,Result, The selection was %value%

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

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.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


dil
  • Guests
  • Last active:
  • Joined: --
thanks for your help,
though this works,it involves a lot of ini reading and writing,i wondered
if i could use action=4

4 = set the data to Environment Variables "GUI","OBJ1","OBJ2","OBJn"...


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

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.

  • Guests
  • Last active:
  • Joined: --
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!!

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
forgot logging on... the above post was by me.

i think ur question is already replied here:

http://www.hiddensof... ... c=1965&hl=

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
Chris this is an example of a case where envget is reqd (see link above).

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
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.

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
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.

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%

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
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?

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
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... :) its just ~26 kb download and all it requires it extracting the exe file to script's folder.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


dil
  • Guests
  • Last active:
  • Joined: --
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.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
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:
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.

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
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)
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)
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

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
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.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat