Posts: 1,006
Threads: 330
Joined: Mar 2007
Hi Gintaras, I used your multi-thread trigger ideas from this post
http://www.quickmacros.com/forum/showthr...p?tid=2085
to create this macro:
MultiThreadWait
int+ g_stopwait=0
int+ vm=0
int+ vk=0
mac "WaitForMouse"
mac "WaitForKey"
wait 3 V g_stopwait
err
,mes "timeout"
,ret
sel g_stopwait
,case 1
,,mes "mouse click"
,,sel vm
,,,case 1 mes "Left Click"
,,,case 2 mes "Right Click"
,,,case 4 mes "Middle Click"
,case 2
,,mes "keystroke"
,,out vk
Function WaitForKey
int+ vk=wait(0 K)
g_stopwait=2
Function WaitforMouse
int+ vk=wait(0 K)
g_stopwait=2
I would like to mes the actual key instead of the int vk
I have seen how to go the other way from this post:
http://www.quickmacros.com/forum/showthr...65#pid9065
But I couldn't figure out how to go from ascii to character. Something about Chr(..) or format fields. Couldn't get anything to work...
Any ideas?
Thanks,
Stuart
Posts: 1,058
Threads: 367
Joined: Oct 2007
I think that it solves your problem :
out "%c" 101
or
int i=101
_s.format("%c" i)
out _s
Posts: 1,006
Threads: 330
Joined: Mar 2007
Thanks so much. That did the trick.
A few quick questions:
What does _s mean as opposed to just a regular string named "s"?
Why didn't you have to identify it with a str in front of it?
AND
What is the difference between calling a function in these two ways:
mac "WaitForMouse"
mac "WaitForKey"
or
When I ran the previous macro the second way (function name only - highlighted in blue) it didn't work properly, but then I did it exactly as you had
and it did work....
Thanks!
Stuart
Posts: 576
Threads: 97
Joined: Aug 2007
_s is like a undefined variable...u dont have to declare it and can be used more then once in a function/macro...
using
FunctionName
and
mac "FunctionName"
is different the first one runs the function and waits till it is done then continues the normal function that it was called form....
the second one just calls the FunctionName and continues on while running the other one!
Posts: 1,006
Threads: 330
Joined: Mar 2007
The difference b/w the two ways of calling the function is so crucial to what I was doing - running simultaneous trigger tests.
Thanks for the explanation of the programming conventions.
Stuart
Posts: 473
Threads: 33
Joined: Aug 2007
A little bit more in depth for mac.
mac+ open macro in editor (don't run) ;
mac- end this item (item that executes mac) and start macro.
mac Default: continue executing this item and start macro. If both items are macros (not functions, etc), macro starts when this macro ends, else, if only macro is macro, is applied "If a macro is running" property.
Taking on Quick Macros one day at a time
Posts: 5
Threads: 1
Joined: Apr 2010
12-28-2018, 05:24 PM
(This post was last modified: 12-28-2018, 07:37 PM by Hsin-Ho Chen.)
I test to convert "keystrokes" into ASCII characters (32 space, 65 A, to 126 z) by this thread.
e.g. by inputs from my standard US keyboad, when CapLock is off.
I type 'A' key from keyboard, it usually displays 'a' character ( like a simple EditBox).
I type 'shift'+'A', it should displays 'A'.
I type '1' key from keyboard, it displays '1' character, in this editor box.
I type 'shift'+'2', it displays '@' ( character @ )
then I play the code ('shift'=10)
[code]
str s
int i
rep
int vk=wait(5 KF) ;; then I press keystroke 'S'+'2'
if( ifk(S) and ifk('2')) ;; then s='@'
......
QmKeyCodeFromVK(vk s)
out s ;;it should show '@'
(if I press 'shift'+'A', it display 'S' but not 'A')
How can I invent some coding to display 'A' after press 'shift'+'A'
, and it can display '@' after I press 'Shift'+'2' two keys at the same time.
repeating continous keystrokes, then displaying "words@..." into a Str variable
Please, teach me or introduce some learning material, thanks!
Posts: 12,071
Threads: 140
Joined: Dec 2002
Look in MSDN Library, function MapVirtualKeyEx, GetKeyboardLayout.