AutoHotkey Community

It is currently May 27th, 2012, 3:32 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: June 28th, 2010, 9:29 pm 
Hi all, i am trying to make an aplication with Visual Basic 6.0 and AutoHotKey. I want to make an Autohotkey script that lets me send parameters to him, and run a part of the code script acording the parameter sended.
I read the the part "Passing Command Line Parameters to a Script" from the Autohotkey's Manual but it doen't serv me. Because is a command line parameters on execute time and i want to pass parameters at the same time of the script is running. In this way i can "say" what i want to my autohotkey script do through Visual Basic.

For example, I send trough Visual Basic the word "E-mail", then the Script:

If var = "E-Mail"
{
code
}

Lot of thanks


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 28th, 2010, 9:36 pm 
Offline

Joined: January 7th, 2009, 7:03 pm
Posts: 43
Medium difficulty task.

Either have to use the clipboard to transfer the data, or use window messages.

I believe window messages would be the best solution, as it will not interrupt anything of the user, and wont rely on the clipboard issues you may run into (clipboard times out every now and then).

I don't know the relevant code for Visual Basic, but in ahk its
Code:
PostMessage, 0x8888, , %MouseCoords%, , ahk_id %CurWinHwnd%

And in the ahk script you would do
Code:
OnMessage(0x8888, "UnPause")

UnPause(wParam, lParam, msg, hwnd)
{
MsgBox % "hi"
}


Lookup OnMessage() in autohotkey help files.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 28th, 2010, 9:48 pm 
Offline

Joined: March 19th, 2009, 5:08 pm
Posts: 548
Location: Texas, USA
Sure sounds like you're launching an AHK using VB...

This will pull your first command line param into the variable named "var" that you specified...

Code:
var=%1%
If var = "E-Mail"
{
code
}

_________________
Aren't you glad that I didn't put an annoying gif here?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Reply
PostPosted: June 28th, 2010, 10:11 pm 
Yes i tryed this way. But i want to send parameters after the script is running, not at execute time.
And if this way is posible i don't know how is the command ms-dos console.

Thanks a lot !!!


Report this post
Top
  
Reply with quote  
 Post subject: Reply
PostPosted: June 29th, 2010, 1:09 am 
This is my ahk script:
---------------------------------------------------------------------------------

OnMessage(0x0C, "READTHE")

READTHE(wParam, lParam)
{
Send {F9 down}{F9 up}
Sleep, 100
MouseClick, left, 285, 330,2
Sleep, 100
MouseClick, left, 285, 330,2
Sleep, 100
}

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

And through Visual Basic:

Dim l As Long, s As String
l = FindWindowEx(FindWindow("Autohotkey", vbNullString), 0, vbNullString, vbNullString)

s = "some"

SendMessage l, WM_SETTEXT, 0, ByVal s

But it still not working.
Thanks all.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 29th, 2010, 3:06 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
You have the right idea with SendMessage, however you may want to take a look at the WM_COPYDATA message, rather than WM_SETTEXT.

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Reply
PostPosted: June 29th, 2010, 8:32 pm 
I get the same problem.

Any idea?

Thanks !!!


Report this post
Top
  
Reply with quote  
 Post subject: Reply
PostPosted: June 29th, 2010, 10:07 pm 
Here is the solution: (thanks to RaptorX in freenode chat irc)

ClipWait, 10


OnClipboardChange:
ClipSaved := Clipboard
msgbox % clipsaved

if ClipSaved contains keyword ; If it contains "keyword" string
{
CODE
}
return

A lot of thanks to RaptorX, a good person and with a lot of patience. xD.
Bye, and thanks to all.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher, Wicked and 11 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