AutoHotkey Community

It is currently May 27th, 2012, 12:53 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: August 8th, 2011, 12:25 pm 
Offline

Joined: December 17th, 2007, 6:39 pm
Posts: 235
Location: Galati, Romania
I need to store some AHK code in a variable for use with AHK.dll. How do you advise me to do this?

_________________
MusicSuite - play with and study music using MIDI


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 8th, 2011, 12:45 pm 
Offline

Joined: October 11th, 2010, 6:15 pm
Posts: 1211
Location: Right behind you
Two ways I can think of however since you've provided no examples of this code or what you wish to accomplish with it I'll hav eot generalize a bit.
This first way would be to store it in a variable like your post states:
Code:
variable =
(
;your code
)
msgbox % variable
The second way would to store it in a seperate .ahk file and run it through your original script.
main.ahk
Code:
run, test.ahk
test.ahk
Code:
msgbox, you've just run test.ahk
This way you can also create and/or update a file with text and save it.

Again since I don't know what your wanting to do that's the best I can come up with.

_________________
COM Tutorial for Webpages
COM Tutorial for Excel


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 8th, 2011, 1:14 pm 
Offline

Joined: December 17th, 2007, 6:39 pm
Posts: 235
Location: Galati, Romania
I know exactly what I am doing, and I need to store the code in a variable, not in a file. I want to know whether I should use Join, LTrim, etc and preced problematic characters with the escape character `, or maybe there is another simpler way.

_________________
MusicSuite - play with and study music using MIDI


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 8th, 2011, 1:21 pm 
Offline

Joined: October 11th, 2010, 6:15 pm
Posts: 1211
Location: Right behind you
Again no one can help you if you don't A post your code and B explain what your trying to do.

>>I need to store the code in a variable

Tells me nothing.

_________________
COM Tutorial for Webpages
COM Tutorial for Excel


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 8th, 2011, 1:44 pm 
Offline

Joined: December 17th, 2007, 6:39 pm
Posts: 235
Location: Galati, Romania
I am not able to post the code right now; I'm working on a complex program with which I am going to participate in an IT contest, and I am forbidden to do so by the rules of a contest. (I promise I'll post the program and code afterwards, btw a very old version of it is in my signature)

Let me take an example
Code:
;; Example of the code I want to include
x := "This is a test."
msgbox, Value of x is %x%

;; plus some other few hundred lines of code


Code:
;; Example of the script main file
hModule:=DllCall("LoadLibrary","Str",dll_location) ; load the Autohotkey.dll file
code := ??? (how should I assign the code above?)
pointerLine:=DllCall(dll_location "\addScript","Str",code)


Thank you for helping me, and please excuse me if I am a bit grumpy, I'm in a rush to add as many new features as I can to the program.

_________________
MusicSuite - play with and study music using MIDI


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 8th, 2011, 1:50 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
I suggest to use CreateScript, which was written for this.

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 8th, 2011, 4:12 pm 
Offline

Joined: December 17th, 2007, 6:39 pm
Posts: 235
Location: Galati, Romania
Now here's another problem...

Code:
DllCall(MultiDLL1  "\addFile","Str",A_ScriptDir . "\_player.ahk","Uchar",1,"Cdecl UInt")


This gives me access violation. What's wrong? :|

Note: MultiDLL1 is the location of AHK.dll.

_________________
MusicSuite - play with and study music using MIDI


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 8th, 2011, 7:50 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
addFile is used to add files to running script. First start script using ahkdll or ahktextdll :!:

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 8th, 2011, 9:15 pm 
Offline

Joined: December 17th, 2007, 6:39 pm
Posts: 235
Location: Galati, Romania
Changed I still get 0xc0000005 when it loads.
Edit: fixed it. Thanks. But still, how can I store the script in a variable? (so that I do not use "ahkdll" but "ahktextdll") Should I just use Join or LTrim and preced all problematic characters with ` ?

_________________
MusicSuite - play with and study music using MIDI


Last edited by Petru on August 8th, 2011, 9:20 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 8th, 2011, 9:18 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Can you post your script?

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 8th, 2011, 9:20 pm 
Offline

Joined: December 17th, 2007, 6:39 pm
Posts: 235
Location: Galati, Romania
Forgive me, I fixed it. I'm just very clumsy. See post above.

_________________
MusicSuite - play with and study music using MIDI


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 8th, 2011, 9:37 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Quote:
how can I store the script in a variable?
However you like, e.g.
Code:
script:="MsgBox % A_Now`nMsgBox % A_UserName`nExitApp"

Code:
script:="
(
MsgBox % A_Now
MsgBox % A_UserName
ExitApp
)"


You can also use CreateScript() as I suggested above:
Code:
dll:=AhkDllThread()
dll.ahktextdll(CreateScript("<MyDll:MyDll>`nfunc{}"))
While !dll.ahkReady()
   Sleep 10
While dll.ahkReady()
   Sleep 100
ExitApp


;start of dll script
<MyDLL:
Gui,Add,Button,gMyDllButton,Test Dll
Gui,Show
Return
MyDllButton:
MsgBox % func()
GuiClose:
ExitApp
;end of dll script
MyDLL>:
Return

func(){ ;function is also included
   Return "message from AutoHotkey.dll"
}

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 8th, 2011, 10:00 pm 
Offline

Joined: December 17th, 2007, 6:39 pm
Posts: 235
Location: Galati, Romania
You are very kind but I am really unable to use your function, because my functions depend on other functions which in turn depend on other ones... my code is too tangled for your function to work.

Now I'm having trouble with something else... :(
Code:
DllCall(A_ScriptDir . "\MultiDLL" . th . ".dll\ahkpostfunction",...)
Again this gives me access violation. I hope I'm dreaming...

_________________
MusicSuite - play with and study music using MIDI


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 9th, 2011, 5:58 am 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Please note, all Dll function names are case sensitive, so it is
Code:
ahkPostFunction

Can you please post your full script, or at least one that reproduces the problem :!:

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 9th, 2011, 11:51 am 
Offline

Joined: December 17th, 2007, 6:39 pm
Posts: 235
Location: Galati, Romania
See this. The dll inside is your dll.

_________________
MusicSuite - play with and study music using MIDI


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, chaosad, MSN [Bot] and 22 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