CARLO
15-12-2009, 17:40
Hello,
I just started programming in ThinBasic (this morning).
I need to send some keys to an active window; specifically, select a menu item to simulate a user clicking or choosing "Save" and then "Text File", before specifying a Path+filename in the opening dialog (and confirming with Enter).
This is what I currently do using autoHotkey, with its own problems though and that's why I am recoding in ThinBasic. Coding last ThinBasic version, running from ThinAir 1.7.7.0.
Two questions:
1. {AppActivate WindowName} and Win_SetForeground: how do they differ?
I would expect a window in the foreground 'active' and able to receive sendkeys?
2. Offending portion of the code: Sendkeys(%V, 200)
ERROR: "Missing Close Parens ')'. Expected a ')' but found something else"
Sendkeys(%V) OR SENDKEYS({ALT}V) OR : SENDKEYS({%V})
ERROR: Missing Close Parens ')'. Expected a ')' but found something else.
What is the correct syntax?
3. I am saving into an array the window handles of the several instances of a program I launch. However, even if I do not get errors, the attempt to display the handles fails, even if it seems it is possible to reference them with the array:
FOR k=1 to Ntimes
OS_ShellExecute("open", "DSO2300.exe", "", "C:\Program Files\EMBEST\software\", 4)
Sendkeys(sleep(2000)) ' for now: we give time to press enter when in demo mode
NEXT
if (Win_Get(WArray, %WIN_GET_HWND, TitleExpr , %TRUE))=0 then ' save the number and names of DSO wins opened
{
MsgBox (0, "No elem?)"
}
end if
FOR k=1 to Ntimes
MsgBox (0, "element: ", WArray(k)) ' show them
NEXT
hWind=Win_FindByTitle("Embest",%WIN_FindTitleStart)
'Win_SetForeground(hWind) ' this works
Win_SetForeground(WArray(2)) ' it also works
So several questions!
I assume this is the right place to post, if not, apologies, I registered today.
Many thanks for your replies.
I just started programming in ThinBasic (this morning).
I need to send some keys to an active window; specifically, select a menu item to simulate a user clicking or choosing "Save" and then "Text File", before specifying a Path+filename in the opening dialog (and confirming with Enter).
This is what I currently do using autoHotkey, with its own problems though and that's why I am recoding in ThinBasic. Coding last ThinBasic version, running from ThinAir 1.7.7.0.
Two questions:
1. {AppActivate WindowName} and Win_SetForeground: how do they differ?
I would expect a window in the foreground 'active' and able to receive sendkeys?
2. Offending portion of the code: Sendkeys(%V, 200)
ERROR: "Missing Close Parens ')'. Expected a ')' but found something else"
Sendkeys(%V) OR SENDKEYS({ALT}V) OR : SENDKEYS({%V})
ERROR: Missing Close Parens ')'. Expected a ')' but found something else.
What is the correct syntax?
3. I am saving into an array the window handles of the several instances of a program I launch. However, even if I do not get errors, the attempt to display the handles fails, even if it seems it is possible to reference them with the array:
FOR k=1 to Ntimes
OS_ShellExecute("open", "DSO2300.exe", "", "C:\Program Files\EMBEST\software\", 4)
Sendkeys(sleep(2000)) ' for now: we give time to press enter when in demo mode
NEXT
if (Win_Get(WArray, %WIN_GET_HWND, TitleExpr , %TRUE))=0 then ' save the number and names of DSO wins opened
{
MsgBox (0, "No elem?)"
}
end if
FOR k=1 to Ntimes
MsgBox (0, "element: ", WArray(k)) ' show them
NEXT
hWind=Win_FindByTitle("Embest",%WIN_FindTitleStart)
'Win_SetForeground(hWind) ' this works
Win_SetForeground(WArray(2)) ' it also works
So several questions!
I assume this is the right place to post, if not, apologies, I registered today.
Many thanks for your replies.