PDA

View Full Version : Question about sendkeys



stapper
27-08-2011, 10:46
Hi,

If i use the keys ctrl+Shift+Left arrow in Rich Text controll then the previous word is selected.

When iam using SendKeys("^+{LEFT}") i expected the same result but instead it just go to the begin of the previous word.

I seems that the + is ignored in the sendkeys or what is more likely i do something wrong.

Can someone help me ?

Regards

Patrick

ErosOlmi
27-08-2011, 12:21
I'm checking ...

ErosOlmi
27-08-2011, 12:39
What operating system (type and version) are you working on?

ErosOlmi
27-08-2011, 13:31
No problem, I can replicate the problem and confirm SHIF seems not working when used with non character keys like arrows.
I'm working on that.

Later I will move this post into support area as a bug report

Eros

stapper
27-08-2011, 13:57
Ok Thanks Eros

Regards

patrick

ErosOlmi
27-08-2011, 20:28
thinBasic Sendkeys (http://www.thinbasic.com/public/products/thinBasic/help/html/index.html?sendkeys.htm) function is internally using Keybd_Event (http://msdn.microsoft.com/en-us/library/ms646304(v=vs.85).aspx) api now superseded by SendInput (http://msdn.microsoft.com/en-us/library/ms646310(v=vs.85).aspx)

I'm now developing a new thinBasic function called SendString that will use SendInput (http://msdn.microsoft.com/en-us/library/ms646310(v=vs.85).aspx) function as core engine.

First experiment seems working fine. It will have much more control over what is possible to do.
Example:

SendString "{SHIFT_DOWN}{CTRL_DOWN}{LEFT}{SHIFT_UP}{CTRL_UP}"

Another advantage over previous way is that SendString will also be able to simulate mouse events.

Stay tuned.

catventure
28-08-2011, 08:58
Hi Eros,

I too would find this tremendously useful! :)

Thanks,
catventure

ErosOlmi
28-08-2011, 09:08
It has been developed: http://www.thinbasic.com/community/project.php?issueid=309#note2026
New feature will be present in next release (almost ready)

stapper
28-08-2011, 10:38
Looks Good Eros,

Thanks alot

Patrick

ErosOlmi
28-08-2011, 11:01
If you want to test ...

attached to this post there is next version (1.8.9) of UI (User Interface) module: thinBasic_UI.dll
Download it and extract into \thinbasic\lib\ directory overwriting your current one.

Than run your script.
Here an example:


Uses "UI"
Uses "OS"


Dim hWnd As Long


hWnd = Win_FindByTitle("...Notepad")


'---If not found try to open Notepad
If hWnd =0 Then
OS_ShellExecute("open", "notepad.exe", "", "", %SW_NORMAL)
'Give enough time Notepad to load. On slow machines increase sleep value
Sleep 1000
hWnd = Win_FindByTitle("...Notepad")
End If


'---At this poit we shpuld have Notepad.exe running and visible
If hWnd Then
Sleep 1000
Win_SetForeground(hWnd)
Sleep 1000
SendString "aaaaaaaaa bbbbbbbbbbb cccccccccccc", 0, 1000
SendString "{SHIFT_DOWN}{CTRL_DOWN}{LEFT}{LEFT}{LEFT}{SHIFT_UP}{CTRL_UP}{DEL}", 500, 1000

SendString "---All done---", 0, 1000
Else
MsgBox 0, "Unable to find or load Notepad.exe"
End If


Beep