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
Pass parameters to AutoHotkey script
Started by
Mithondriel
, Jun 28 2010 08:29 PM
10 replies to this topic
#1
-
Posted 28 June 2010 - 08:29 PM
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
Lookup OnMessage() in autohotkey help files.
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
PostMessage, 0x8888, , %MouseCoords%, , ahk_id %CurWinHwnd%And in the ahk script you would do
OnMessage(0x8888, "UnPause") UnPause(wParam, lParam, msg, hwnd) { MsgBox % "hi" }
Lookup OnMessage() in autohotkey help files.
#2
-
Posted 28 June 2010 - 08:36 PM
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...
This will pull your first command line param into the variable named "var" that you specified...
var=%1% If var = "E-Mail" { code }
#3
-
Posted 28 June 2010 - 08:48 PM
Aren't you glad that I didn't put an annoying gif here?
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 !!!
And if this way is posible i don't know how is the command ms-dos console.
Thanks a lot !!!
#4
-
Posted 28 June 2010 - 09:11 PM
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.
---------------------------------------------------------------------------------
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.
#5
-
Posted 29 June 2010 - 12:09 AM
You have the right idea with SendMessage, however you may want to take a look at the WM_COPYDATA message, rather than WM_SETTEXT.
#6
-
Posted 29 June 2010 - 02:06 AM
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.
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.
#8
-
Posted 29 June 2010 - 09:07 PM
I don't like using the clipboard so I have used files to transfer information
Loop { if FileExist("c:\temp\1654842454545.txt") { FileRead, varCom, c:\temp\1654842454545.txt FileDelete, c:\temp\1654842454545.txt msgbox % varCom } Sleep 2000 }
Not sure if that is best way, but that is what I have done in the past. Could probably use setTimer as well here.
#9
-
Posted 30 July 2013 - 05:12 AM
how do you use SetTimer with this?:
I don't like using the clipboard so I have used files to transfer information
Loop { if FileExist("c:\temp\1654842454545.txt") { FileRead, varCom, c:\temp\1654842454545.txt FileDelete, c:\temp\1654842454545.txt msgbox % varCom } Sleep 2000 }Not sure if that is best way, but that is what I have done in the past. Could probably use setTimer as well here.
#10
-
Posted 31 July 2013 - 11:24 AM
#persistent #singleinstance force setTimer, CheckMsgs, 1000 ;Check for new messages once per second. CheckMsgs: if FileExist("C:\temp\kiwijunglist.message") { FileRead, Str, C:\temp\kiwijunglist.message FileDelete, C:\temp\kiwijunglist.message msgbox % "You have a message: " Str } Return
#11
-
Posted 31 July 2013 - 01:35 PM