You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

KusaNoKaito

Beginner

  • "KusaNoKaito" is male
  • "KusaNoKaito" started this thread

Posts: 7

Date of registration: Sep 15th 2009

Location: Waxahachie TX USA

Occupation: Student

Hobbies: Computer Programming, Computer Hacking.

  • Send private message

1

Wednesday, September 16th 2009, 1:45pm

SendKeys Function?

Hello complete n00b here, ( love the VB6 like syntax ) sorry if this sounds stupid.

I am making trying to make an auto typer in jabaco, and was wondering how i can use the "SendKeys" function like in VB.

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Public Sub Command1_Click()
 	Timer1.Enabled = True
 	Timer1.Interval = Text2.Text 
	End Sub
Public Sub Command2_Click()
Close
End Sub
 	Public Sub Command3_Click()
 	Timer1.Enabled = False
 	End Sub
Public Sub Timer1_Timer()
SendKeys.Send(Text1.Text)
SendKeys.Send "{enter}"
End Sub


Your help would be appreciated.

This post has been edited 1 times, last edit by "KusaNoKaito" (Sep 17th 2009, 2:43pm)


A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

2

Wednesday, September 16th 2009, 3:02pm

Hi,
in Java there is a "Robot" class to tackle automation tasks like sendkeys.

The following sample code might inspire you to come up with a Jabaco version:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.awt.Robot;
import java.awt.event.KeyEvent;

/**
 * @author imran
 * Description : Used to toggle the multimonitor display in Win XP.
 */
public class MultiMon {
	public static void main(String[] args) {
		try {
			//Invoke the desktop setting applet, the 3rd tab should be selected
			Runtime.getRuntime().exec("control.exe desk.cpl,@0,3");

			//Pause for a second.... 
			try {
				Thread.sleep(1000);
			}catch (InterruptedException ex){
			}
			//Create a new robot that can do the system interaction for us...
			Robot robot = new Robot();
			//Activate the "Display" field...
			robot.keyPress(KeyEvent.VK_D + KeyEvent.ALT_MASK);
			//Choose the second monitor
			robot.keyPress(KeyEvent.VK_2);
			//goto the "Extend my windows desktop" checkbox...
			robot.keyPress(KeyEvent.VK_TAB);robot.keyPress(KeyEvent.VK_TAB);
			robot.keyPress(KeyEvent.VK_TAB);robot.keyPress(KeyEvent.VK_TAB);
			robot.keyPress(KeyEvent.ALT_MASK);
			robot.keyPress(KeyEvent.VK_E );
			//toggle the check box...
			robot.keyPress(KeyEvent.VK_ENTER);
			//clear references...
			robot = null;
			//exit the application
			System.exit(0);
		} catch (Exception e) {
			// Things did'nt work out....
			e.printStackTrace();
		}
	}
}


Greetings!

A1880

OlimilO

Intermediate

  • "OlimilO" is male

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

3

Wednesday, September 16th 2009, 3:29pm

Hi,

yes we could implement it in this way:

Source code

1
2
3
4
5
6
7
8
9
10
java.awt.Robot SendKeysRob;
public void SendKeys(String skey) {
   SendKeys(skey, 0);
}
public void SendKeys(String skey, int wait) {
   If (SendKeysRob = null) SendKeysRob = new Robot;
   int a = Asc(skey);
   SendKeysRob.keyPress(a);
   If (wait > 0) SendKeysRob.delay(wait);
}


Jabaco Source

1
2
3
4
5
6
7
Dim SendKeysRob As java#awt#Robot
Public Sub SendKeys(skey As String, Optional wait)
   If SendKeysRob Is Nothing Then SendKeysRob = New Robot
   Dim a As Integer = Asc(skey)
   SendKeysRob.keyPress(a)
   If wait > 0 Then SendKeysRob.delay(wait)   
End Sub


example:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Option Explicit
Dim keyInput() As String = ( _
                 " ", "W", "E", "L", "C", "O", "M", "E", " ", _
                 "T", "O", " ", "J", "A", "B", "A", "C", "O")
Public Sub Command1_Click()
   Call Shell("notepad.exe", vbNormalFocus)
End Sub
Public Sub Command2_Click()
   Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
   Static i As Integer
   If i <= UBound(keyInput) Then
      Call SendKeys(keyInput(i))
      i = i + 1
   Else
      Timer1.Enabled = False
      i = 0
   End If
End Sub


have a look at the attached Jabaco- and VB-project.



OlimilO
OlimilO has attached the following file:
  • SendKeys.zip (6.6 kB - 534 times downloaded - latest: Apr 15th 2024, 1:00am)

OlimilO

Intermediate

  • "OlimilO" is male

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

4

Wednesday, September 16th 2009, 3:50pm

it's in the framework now:
http://code.google.com/p/jabacoframework…nteraction.java
@KusaNoKaito :) thanks for the hint to the missing function

KusaNoKaito

Beginner

  • "KusaNoKaito" is male
  • "KusaNoKaito" started this thread

Posts: 7

Date of registration: Sep 15th 2009

Location: Waxahachie TX USA

Occupation: Student

Hobbies: Computer Programming, Computer Hacking.

  • Send private message

5

Wednesday, September 16th 2009, 4:07pm

Thanks allot for your help!
I have been looking for a way to port my bots to other OS and found it in jabaco!

Rate this thread
WoltLab Burning Board