Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / capitals and erasing

Author
Message
learner
17
Years of Service
User Offline
Joined: 7th Mar 2009
Location:
Posted: 20th Mar 2009 00:18
Is there a way of forcing caps lock?.
How can i erase a line of text so i can print something different in that position?.
Thanks
Caleb1994
17
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 20th Mar 2009 00:35
just one?

if so you can cls and print everything again


and idk about the caps lock

New Site! Check it out \/
That1Smart Guy
17
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 20th Mar 2009 00:36
im not sure wat ur asking but the code

upper$(string)

will turn the string into caps
Caleb1994
17
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 20th Mar 2009 00:43
i think he wants to make it so when the user types something it comes out as caps not change it to caps after they type it.

New Site! Check it out \/
learner
17
Years of Service
User Offline
Joined: 7th Mar 2009
Location:
Posted: 20th Mar 2009 02:24
Yes your right about the caps lock caleb1994.
I know about cls.I want to remove just 1 line in a screen of text.
That1Smart Guy
17
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 20th Mar 2009 02:28
then type



that will print it as theyre typing it, no way to get around that, but wen theyre done it erases it and prints it in caps
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 20th Mar 2009 02:30
@learner
There's no way to force the capslock on or off with standard DBC commands. However, you can use the win32 api to do it. The win api are commands that Windows uses to perform certain functions. Using some of these commnads, you can force keyboard input by programming it.

Though this may be a bit advanced, you access these commands by calling a DLL function. A DLL is a piece of machine executable code that has functions in it. You can call these functions through DBC. DLLs have the advantage of speed and extending the capabilities of DBC.

In the following example, I use the win api command keybd_event which is found in the user32.dll DLL. This function sets a key down (pressed)or up (released).

Now because the CAPSLOCK state can be toggled - every time it's pressed it's either on or off, I have to check whether or not the keyboard is in CAPS mode. I do that using a combination keybd_event and the DBC command inkey$(). Inkey$() will return either a capital letter or a lowercase letter depending on the capslock state. I'll check this letter so I know if I should or shouldn't force the capslock to be pressed. After I'm done typing capitals, I then force another capslock press to toggle the keyboard state to lowercase. Here is the example:



Enjoy your day.
That1Smart Guy
17
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 20th Mar 2009 02:37
nice latch, way to 1-up me and flat out make me a liar, lol
learner
17
Years of Service
User Offline
Joined: 7th Mar 2009
Location:
Posted: 20th Mar 2009 02:42
Thanks,very interesting.
I thought i may be able to just poke a value into the caps lock address.
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 20th Mar 2009 02:46
Quote: "nice latch, way to 1-up me and flat out make me a liar, lol "

Not my intention at all. In fact, I was typing at the same time you were and hadn't even seen your message.

Enjoy your day.
That1Smart Guy
17
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 20th Mar 2009 02:47
o lol, np just jkin around
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 20th Mar 2009 03:11
Actually, there's probably no need for all my complications! That's the way to get the capslock to work but not necessarily the way to get the user to type caps!

@That1Smart Guy
I think your method would probably do the trick with a slight change. Though this example is kinda lousy, it gets the idea across:



Enjoy your day.
That1Smart Guy
17
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 20th Mar 2009 03:21
interesting latch, thats still more complicated than i typically use but an interesting solution to the problem
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 20th Mar 2009 05:21
Caleb wrote something like "I think he wants to make it so the input is caps, not change it to caps afterwards"
that is the same thing, it depends when you show the user what is happening, if you wait till it has been through UPPER$() they'll be none the wiser. Remember there is no phyisical shift of the keys, they still give the same input to the computer so caps lock is doing the same as UPPER$() anyway.

The Universe has been erased by a mod because it was larger
than 240x80 pixels.
Caleb1994
17
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 20th Mar 2009 07:11 Edited at: 20th Mar 2009 07:14
i don't know why but i love the fact that when i run latches code it turns the light on my keyboard on hahaha i know its doing the same thing as the caps lock key but it still seems weird when i'm not pressing a button and it comes on.


nice though latch i might have to keep this one on my harddrive haha

New Site! Check it out \/
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 20th Mar 2009 07:16 Edited at: 20th Mar 2009 07:31
Can you tell I've got nothing to code? I'm thinking way to big these days! Simplify man! Simplify! Here's a nice clean working version that shows caps as it's being typed but stores whatever was typed as it is:



Quote: "Is there a way of forcing caps lock?."

Though, that was learners question, but maybe not the real goal?

Enjoy your day.
Caleb1994
17
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 20th Mar 2009 07:21
ya well in my oppinion it would be easier to do it the real way (using windows resources) then faking it. while faking it requires no research or anything and is good for quick stuff. for the end product i would say just force the caps lock.

New Site! Check it out \/
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 20th Mar 2009 07:39
@Caleb1994


@learner
The second part of your question:
Quote: "How can i erase a line of text so i can print something different in that position?"

There are a couple of different ways to do it. The way I'm demonstrating is to make a box that is the same color as the background over the text you want to remove. This example will blot out the text that you enter but not the text that is displayed as in the previous example - just to show how a single area on the screen can be "wiped"



Enjoy your day.
Caleb1994
17
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 20th Mar 2009 07:46
nice one latch. i don't know why no one else thought of that.

New Site! Check it out \/
That1Smart Guy
17
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 20th Mar 2009 18:49
i thought of it, i just couldt find a way to apply it to this problem.

neway if u wanna get rid of text cls will work, dont 4get the simple stuff, but latch's idea can erase only a section of text.

I suppose another alternative to latch's would be to make a bitmap, copy an area of text from the screen (bitmap 0) to the new bitmap, cls, then copy bitmap 1,0
Quirkyjim
17
Years of Service
User Offline
Joined: 18th Oct 2008
Location: At my computer
Posted: 20th Mar 2009 22:21
To just write over some text again, you could use:

SET TEXT OPAQUE

This will just, instead of just drawing the text, it will draw the background color around it too.

Let me write you up an example...



Keep in mind, though, that this only works with TEXT or CENTER TEXT, not PRINT.

~QJ
That's what they WANT you to think...
Caleb1994
17
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 20th Mar 2009 22:59
but only if the new text is the same or bigger size as the old one because other wise it will stick out of the new text

New Site! Check it out \/
learner
17
Years of Service
User Offline
Joined: 7th Mar 2009
Location:
Posted: 20th Mar 2009 23:08
Good ideas.
Thanks very much

Login to post a reply

Server time is: 2026-07-21 21:27:16
Your offset time is: 2026-07-21 21:27:16