Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Converting ASCII codes to actual characters
#1
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

Code:
Copy      Help
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
Code:
Copy      Help
int+ vk=wait(0 K)
g_stopwait=2

Function WaitforMouse
Code:
Copy      Help
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
#2
I think that it solves your problem :

out "%c" 101

or

int i=101
_s.format("%c" i)
out _s
#3
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:

Code:
Copy      Help
mac "WaitForMouse"
mac "WaitForKey"

or

Code:
Copy      Help
WaitForKey
WaitForMouse


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

Code:
Copy      Help
mac "Function Name"

and it did work....

Thanks!
Stuart
#4
_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!
#5
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
#6

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
#7
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!
#8
Look in MSDN Library, function MapVirtualKeyEx, GetKeyboardLayout.


Forum Jump:


Users browsing this thread: 1 Guest(s)