Jump to content

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

Execute AHK code dynamically!


  • Please log in to reply
54 replies to this topic
Micha
  • Members
  • 539 posts
  • Last active: Dec 31 2011 01:43 PM
  • Joined: 15 Nov 2005
Hi,
I had something like that in mind to write a "debugger" for AHK-scripts.
Therefore the script must be capable to dynamically execute lines of another script and trace the results.

You have done almost all of the work.
GREAT!

Since I'm still working on the HTML-control I don't have time at the moment to create such a debugger but it's good to know the most time consuming part is already done.

Has somebody else thought about the idea (and eventually have more time :-) ) ?

Ciao
Micha

.AHK
  • Members
  • 657 posts
  • Last active: Nov 27 2008 04:10 AM
  • Joined: 26 Apr 2006
Jonny, I downloaded your script to be used with my abbreviation expansion program. However, I do not think this command is supported (::text::expansion)? It may be and I am just overlooking it. By the way, great script. It will be very useful.

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006
Hej, this script is great.
Very very cool.

Thank you.

2 Micha
O... I think about it all the time :)

EDIT: Please note at the first post that commands should be specified with commas or they will not be executed. For instance, execute("msgbox") or execute("msgbox sometxt") don't work while execute("msgbox,") do.
This is not stated anywhere.
Posted Image

WarrenFaith
  • Members
  • 11 posts
  • Last active: Jul 21 2006 01:09 PM
  • Joined: 11 Jul 2006
Ok so after my tests FileReadLine didnt work with dynamic filename so i tried this script for FileReadLine but it seems to make nothing?!
So can someone help me in this case?

Nothing works:
FileReadLine, line, %file%, 2
execute("FileReadLine, line, %file%, 2")
output := execute("FileReadLine, line, %file%, 2")


engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
with the version posted, I had to change the cmd.ahk script to this:
#include execute.ahk
#singleinstance off
#notrayicon

gui,add,edit,readonly vcmdedit w250 h250
gui,add,edit,vcmdfield
gui,add,button,default hidden gsubmit x10 y10 w1 h1
menu,Menubar,add,&Menu,:TRAY
gui,menu,Menubar
gui,+resize
gui,show,center,AutoHotkey Prompt
return

guisize:
new_w := (A_GuiWidth - 20)
new_h := (A_GuiHeight - 39)
field_y := (A_GuiHeight - 30)
guicontrol,move,cmdedit,w%new_w% h%new_h%
guicontrol,move,cmdfield,w%new_w% y%field_y% x10
return

submit:
gui,submit,nohide
guicontrol,,cmdedit,Working...
stringsplit,param,cmdfield,`,
guicontrol,,cmdedit,% "Output: " . execute(param1 . "," . param2 . "," . param3 . "," . param4 . "," . param5 . "," . param6 . "," . param7 . "," . param8 . "," . param9 . "," . param10) . "`nErrorLevel: " . ErrorLevel . "`n`nOutput Array:`n1: " . r1 . "`n2: " . r2 . "`n3: " . r3 . "`n4: " . r4 . "`n5: " . r5 . "`n6: " . r6 . "`n7: " . r7
guicontrol,,cmdfield,
r1=
r2=
r3=
r4=
r5=
r6=
r7=
return

guiclose:
exitapp


  • Guests
  • Last active:
  • Joined: --
execute("MsgBox", "blah")

=> Too many parameters passed to function

Did't work!

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005

execute("MsgBox", "blah")

=> Too many parameters passed to function


please try

execute("MsgBox, blah")


Deller
  • Members
  • 239 posts
  • Last active: Dec 08 2011 08:36 PM
  • Joined: 21 Nov 2007
Beautiful

tinkumd
  • Guests
  • Last active:
  • Joined: --
i tried this and failed:
x = 5 ;
execute("Msgbox, %x%")

I get a box with %x% instead of 5.

Joy2DWorld
  • Members
  • 562 posts
  • Last active: Jun 30 2014 07:48 PM
  • Joined: 04 Dec 2006

Posted: Sun Dec 30, 2007 7:26 am Post subject: can't put variables in as parameters to execute

--------------------------------------------------------------------------------

i tried this and failed:
x = 5 ;
execute("Msgbox, %x%")

I get a box with %x% instead of 5.



try
execute("Msgbox," x )

which would seem to make more sense.



(but what do I know...)
Joyce Jamce

tinkumd
  • Guests
  • Last active:
  • Joined: --
thanks, that worked with
execute("Msgbox," x)

is there a way to change the name of a variable dynamically?

one separate question:
for example make the user input the name of the variable and then assign some result to that variable?

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
why do you need to do that dynamically?

you can use stringreplace to do this, in theory

TheIrishThug
  • Members
  • 419 posts
  • Last active: Jan 18 2012 02:51 PM
  • Joined: 19 Mar 2006
y = Hi there!
x = y
execute("Msgbox," %x%)

That should get you what you want. X is a variable who's contents is the name of a variable.
execute("Msgbox," %x%) // contents of the variable x names
execute("Msgbox," x)   // contents of x


tinku99
  • Members
  • 560 posts
  • Last active: Feb 08 2015 12:54 AM
  • Joined: 03 Aug 2007
Actually what i was trying to do was easy, sorry.
inputbox, x
%x% = 5
execute("MsgBox," x "=" %x%)

How can I get the gui-wrapper equivalient of
execute("Msgbox," x )
to work ?
Thanks

Joy2DWorld
  • Members
  • 562 posts
  • Last active: Jun 30 2014 07:48 PM
  • Joined: 04 Dec 2006

How can I get the gui-wrapper equivalient of
execute("Msgbox," x )
to work ?
Thanks


gosh, is there such a thing. cool.

(er, what is advantage of it ?)
Joyce Jamce