Jump to content
Developer Wiki and Function Reference Links ×

KeyStroke recorders?


ionw

Recommended Posts

Good Day,

I am trying to script a command that will cycle through the class list, much like the Cmd-up/dn Arrowdoes with layers.

I have seen that Conrad has found Key down to be broken, and according to Matthew G of Nemetschek may not be fixed until Version 10. What about AutoKey or GetKeyDown? I haven't tried AutoKey. But GetKeydown seems to return the proper value, but I don't get any repeatability in the script below. The message appears so I know I get to line #15, but then I am locked in to the command and I am forced to force quit VW to get out of it. I thought I had a faulty Loop, but I stacked three GetKeyDown/Message blocks one after the other and I again only got to the first one, so it doesn't seem to be a loop issue.

I am a reasonably new coder so any help would be greatly appreciated.

Thank you

Ion Webster

Procedure CycleClasses;VAR NumClasses,CurClass,Index,KeyPress,i:LONGINT; NextClass : STRING; Test : BOOLEAN;BEGIN

NumClasses := ClassNum; i := 0; KeyPress := 1;

WHILE (KeyPress <> 27) DO BEGIN

GetKeyDown(KeyPress); Message('The key pressed was ',KeyPress);

IF KeyPress = 29 THEN i := i + 1; IF i = NumClasses + 1 THEN i := 1; IF KeyPress = 28 THEN i := i - 1; IF i = -1 THEN i := NumClasses;

NextClass := ClassList(i); NameClass(NextClass);

Message('The New Class is ',NextClass); END;END;Run(CycleClasses);

Link to comment

Thanks Dave,

Unfortunately the script you proposed didn't do what I wanted, which is not to cycle through to another class and set it active, I want to cycle through the classes. I do this to see what is what on a Civil Drawing, Set Classes to Active only and then work my way through the list. I have something that seems to be working now, I will share it. If it could be better anyone, I would love the help/tips. Thanks to the Nemetschek Example for 'Bump' for some of the structure.

Procedure CycleClasses;VAR NextClass : STRING; X1,Y1,MouseX,MouseY : REAL; ObHd1: HANDLE; KCod,i : INTEGER; BEGIN WHILE (KCod <>13) DO BEGIN { - until return is pressed - } IF MouseDown(MouseX,MouseY) THEN SysBeep; { -handles mouse downs- } IF KeyDown(KCod) THEN BEGIN CASE KCod OF 28: BEGIN { - '<-' key - } i := i - 1; IF i < 0 THEN i := ClassNum; NextClass := ClassList(i); NameClass(NextClass); Redraw; END; 29: BEGIN { - '->' key - } i := i + 1; IF i = ClassNum + 1 THEN i := 1; NextClass := ClassList(i); NameClass(NextClass); Redraw; END; END; { - CASE end - } END; END; { - WHILE end - } KCod:=0; SysBeep;END;Run(CycleClasses);

thanks again

Ion Webster

Link to comment

Try this for scrolling through the class list and setting the active class.Dave wink.gif" border="0 -----------------Procedure CycleClasses;VARkeypressed:LONGINT;ClassName:STRING;i: INTEGER;

BEGINi:=1;RepeatClassName:= ClassList(i);Message('Class Name: ',ClassName,', Hit the Return key to make this the active class.');GetKeyDown(keypressed);

If KeyPressed = 29 THENBEGIN If i = ClassNum then BEGIN ClassName:= ClassList(i); Message('Class Name: ',ClassName,', Hit the Return key to make this the active class.'); i:=1; END ELSEBEGINClassName:= ClassList(i);Message('Class Name:',ClassName,', Hit the Return key to make this the active class.');i:=i+1;End;End;

If KeyPressed = 28 THENBEGIN If i = 1 then BEGIN ClassName:= ClassList(i); Message('Class Name: ',ClassName,', Hit the Return key to make this the active class.'); i:= ClassNum; END ELSEBEGINClassName:= ClassList(i);Message('Class Name: ',ClassName,', Hit the Return key to make this the active class.');i:=i-1;End;End;

UNTIL KeyPressed = 13;NameClass(ClassName);ClrMessage;END;Run (CycleClasses);

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...