Sign in to follow this  
Followers 0
qwer85

"ControlClick" issue :(

10 posts in this topic

Hello, I need to click the controls in "Windows On Screen Keyboard" (OSK).

But when I execute my script it does nothing <_<

ControlClick("On Screen Keyboard", "", "N191")

Can somebody help me?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hello, I need to click the controls in "Windows On Screen Keyboard" (OSK).

But when I execute my script it does nothing :)

ControlClick("On Screen Keyboard", "", "N191")

Can somebody help me?

Add WinActivate () then WinWaitActive () before you click... <_< Edited by Bert

Share this post


Link to post
Share on other sites

But if I do this, OSK won't send that key into the window I wish...

Share this post


Link to post
Share on other sites

But if I do this, OSK won't send that key into the window I wish...

Can you explain? It won't send the key into the window you wish? What are you trying to achive?

Share this post


Link to post
Share on other sites

Ok

1. I have a window named for example "My prog", where I want to send a key, for example: "A"

2. But I want to send this key using ONLY "OSK", not the AutoIt.

3. When I try to execute my script, it doesn't work, MAYBE because OSK need selection before clicking the control of button "A".

4. If I select the window of "OSK" it can't sent the "A" letter to "My prog", because "My prog" need selection for "OSK" to work.

It's complex, but I need this...

Share this post


Link to post
Share on other sites

By the way, with WinActivate, it's not working either.

Share this post


Link to post
Share on other sites

Nobody knows how to simulate click's on "Microsoft On Screen Keyboard"?

Share this post


Link to post
Share on other sites

Nobody knows how to simulate click's on "Microsoft On Screen Keyboard"?

This problem intrigued me so I had a look at what is possible.

The little demo script below shows that it is possible if you are prepared to put in a bit of effort to map the position of all the keys.

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",1)

WinWait("Untitled","")
If Not WinActive("Untitled","") Then WinActivate("Untitled","")
WinWaitActive("Untitled","")

Ons_Click("Q")
Ons_Click("{SPACE}")
Ons_Click("U")
Ons_Click("{SPACE}")
Ons_Click("E")
Ons_Click("{SPACE}")
Ons_Click("R")
Ons_Click("{SPACE}")
Ons_Click("T")
Ons_Click("{SPACE}")
Ons_Click("Y")
Ons_Click("{RETURN}")

Func Ons_Click($sKey)
Local $Pos = WinGetPos("On-Screen Keyboard","") 
    Select
        Case $sKey = "{Return}"
            MouseMove($Pos[0] + 385,$Pos[1] + 135)
            MouseClick("left")
        Case $sKey = "Q"
            MouseMove($Pos[0] + 60,$Pos[1] + 110)
            MouseClick("left")
        Case $sKey = "W"
            MouseMove($Pos[0] + 87,$Pos[1] + 110)
            MouseClick("left")
        Case $sKey = "E"
            MouseMove($Pos[0] + 114,$Pos[1] + 110)
            MouseClick("left")
        Case $sKey = "R"
            MouseMove($Pos[0] + 141,$Pos[1] + 110)
            MouseClick("left")
        Case $sKey = "T"
            MouseMove($Pos[0] + 168,$Pos[1] + 110)
            MouseClick("left")
        Case $sKey = "Y"
            MouseMove($Pos[0] + 195,$Pos[1] + 110)
            MouseClick("left")
        Case $sKey = "{SPACE}"
            MouseMove($Pos[0] + 190,$Pos[1] + 180)
            MouseClick("left")
    EndSelect
EndFunc

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites

This problem intrigued me so I had a look at what is possible.

The little demo script below shows that it is possible if you are prepared to put in a bit of effort to map the position of all the keys.

This problem intrigued me as well. Without seeing your response, I made up a similar program and mapped all the keys. It wasn't hard, I made a spreadsheet and a macro that pasted the mouse coordinates into the spreadsheet, so all I had to do was point at a key and hit a hotkey.

Once I had the list I used another macro to take the three columns (name, x, y) and generate all the code needed for all the cases. I have not tested all the keys, and my home PC doesn't have osk installed, so I can't test it further. As an FYI I have classic theme, not Luna.

;initialize onscreen keyboard
run("osk")
WinWait("On-Screen","")
WinMove("On-Screen","",(@DesktopWidth-612)/2,@desktopheight-220)

WinMenuSelectItem("On-Screen","","&Keyboard", "&Enhanced Keyboard")
WinMenuSelectItem("On-Screen","","&Keyboard", "10&1 keys")
WinMenuSelectItem("On-Screen","","&Keyboard", "&Regular Layout")

;launch notepad
run("notepad")
WinWait("[Class:Notepad]")
WinActivate("[Class:Notepad]")
WinWaitActive("[Class:Notepad]")

;type text in notepad
osk("t")
osk("h")
osk("i")
osk("s")
osk("space")
osk("i")
osk("s")
osk("space")
osk("a")
osk("space")
osk("t")
osk("e")
osk("s")
osk("t")
osk(".")

Func osk ($keypress)
    $oskpos=WinGetPos("On-Screen")
        
        Switch $keypress
        Case "esc"
            MouseClick("left",$oskpos[0]+18,$oskpos[1]+55,1,0)

        Case "f1"
            MouseClick("left",$oskpos[0]+68,$oskpos[1]+55,1,0)

        Case "f2"
            MouseClick("left",$oskpos[0]+92,$oskpos[1]+55,1,0)

        Case "f3"
            MouseClick("left",$oskpos[0]+125,$oskpos[1]+55,1,0)

        Case "f4"
            MouseClick("left",$oskpos[0]+150,$oskpos[1]+55,1,0)

        Case "f5"
            MouseClick("left",$oskpos[0]+194,$oskpos[1]+55,1,0)

        Case "f6"
            MouseClick("left",$oskpos[0]+221,$oskpos[1]+55,1,0)

        Case "f7"
            MouseClick("left",$oskpos[0]+248,$oskpos[1]+55,1,0)

        Case "f8"
            MouseClick("left",$oskpos[0]+277,$oskpos[1]+55,1,0)

        Case "f9"
            MouseClick("left",$oskpos[0]+317,$oskpos[1]+55,1,0)

        Case "f10"
            MouseClick("left",$oskpos[0]+346,$oskpos[1]+55,1,0)

        Case "f11"
            MouseClick("left",$oskpos[0]+374,$oskpos[1]+55,1,0)

        Case "f12"
            MouseClick("left",$oskpos[0]+401,$oskpos[1]+55,1,0)

        Case "psc"
            MouseClick("left",$oskpos[0]+429,$oskpos[1]+55,1,0)

        Case "slk"
            MouseClick("left",$oskpos[0]+457,$oskpos[1]+55,1,0)

        Case "brk"
            MouseClick("left",$oskpos[0]+480,$oskpos[1]+55,1,0)

        Case "`"
            MouseClick("left",$oskpos[0]+18,$oskpos[1]+80,1,0)

        Case "1"
            MouseClick("left",$oskpos[0]+46,$oskpos[1]+80,1,0)

        Case "2"
            MouseClick("left",$oskpos[0]+71,$oskpos[1]+80,1,0)

        Case "3"
            MouseClick("left",$oskpos[0]+96,$oskpos[1]+80,1,0)

        Case "4"
            MouseClick("left",$oskpos[0]+126,$oskpos[1]+80,1,0)

        Case "5"
            MouseClick("left",$oskpos[0]+153,$oskpos[1]+80,1,0)

        Case "6"
            MouseClick("left",$oskpos[0]+179,$oskpos[1]+80,1,0)

        Case "7"
            MouseClick("left",$oskpos[0]+210,$oskpos[1]+80,1,0)

        Case "8"
            MouseClick("left",$oskpos[0]+232,$oskpos[1]+80,1,0)

        Case "9"
            MouseClick("left",$oskpos[0]+259,$oskpos[1]+80,1,0)

        Case "0"
            MouseClick("left",$oskpos[0]+290,$oskpos[1]+80,1,0)

        Case "-"
            MouseClick("left",$oskpos[0]+313,$oskpos[1]+80,1,0)

        Case "="
            MouseClick("left",$oskpos[0]+344,$oskpos[1]+80,1,0)

        Case "bksp"
            MouseClick("left",$oskpos[0]+389,$oskpos[1]+80,1,0)

        Case "ins"
            MouseClick("left",$oskpos[0]+428,$oskpos[1]+80,1,0)

        Case "hm"
            MouseClick("left",$oskpos[0]+455,$oskpos[1]+80,1,0)

        Case "pup"
            MouseClick("left",$oskpos[0]+482,$oskpos[1]+80,1,0)

        Case "nlk"
            MouseClick("left",$oskpos[0]+510,$oskpos[1]+80,1,0)

        Case "k/"
            MouseClick("left",$oskpos[0]+538,$oskpos[1]+80,1,0)

        Case "k*"
            MouseClick("left",$oskpos[0]+566,$oskpos[1]+80,1,0)

        Case "k-"
            MouseClick("left",$oskpos[0]+592,$oskpos[1]+80,1,0)

        Case "tab"
            MouseClick("left",$oskpos[0]+24,$oskpos[1]+100,1,0)

        Case "q"
            MouseClick("left",$oskpos[0]+60,$oskpos[1]+100,1,0)

        Case "w"
            MouseClick("left",$oskpos[0]+87,$oskpos[1]+100,1,0)

        Case "e"
            MouseClick("left",$oskpos[0]+114,$oskpos[1]+100,1,0)

        Case "r"
            MouseClick("left",$oskpos[0]+141,$oskpos[1]+100,1,0)

        Case "t"
            MouseClick("left",$oskpos[0]+168,$oskpos[1]+100,1,0)

        Case "y"
            MouseClick("left",$oskpos[0]+195,$oskpos[1]+100,1,0)

        Case "u"
            MouseClick("left",$oskpos[0]+222,$oskpos[1]+100,1,0)

        Case "i"
            MouseClick("left",$oskpos[0]+249,$oskpos[1]+100,1,0)

        Case "o"
            MouseClick("left",$oskpos[0]+276,$oskpos[1]+100,1,0)

        Case "p"
            MouseClick("left",$oskpos[0]+303,$oskpos[1]+100,1,0)

        Case "["
            MouseClick("left",$oskpos[0]+330,$oskpos[1]+100,1,0)

        Case "]"
            MouseClick("left",$oskpos[0]+358,$oskpos[1]+100,1,0)

        Case "\"
            MouseClick("left",$oskpos[0]+390,$oskpos[1]+100,1,0)

        Case "del"
            MouseClick("left",$oskpos[0]+429,$oskpos[1]+100,1,0)

        Case "end"
            MouseClick("left",$oskpos[0]+454,$oskpos[1]+100,1,0)

        Case "pdn"
            MouseClick("left",$oskpos[0]+482,$oskpos[1]+100,1,0)

        Case "k7"
            MouseClick("left",$oskpos[0]+514,$oskpos[1]+100,1,0)

        Case "k8"
            MouseClick("left",$oskpos[0]+543,$oskpos[1]+100,1,0)

        Case "k9"
            MouseClick("left",$oskpos[0]+567,$oskpos[1]+100,1,0)

        Case "k+"
            MouseClick("left",$oskpos[0]+593,$oskpos[1]+110,1,0)

        Case "clk"
            MouseClick("left",$oskpos[0]+34,$oskpos[1]+123,1,0)

        Case "a"
            MouseClick("left",$oskpos[0]+72,$oskpos[1]+123,1,0)

        Case "s"
            MouseClick("left",$oskpos[0]+99,$oskpos[1]+123,1,0)

        Case "d"
            MouseClick("left",$oskpos[0]+126,$oskpos[1]+123,1,0)

        Case "f"
            MouseClick("left",$oskpos[0]+153,$oskpos[1]+123,1,0)

        Case "g"
            MouseClick("left",$oskpos[0]+180,$oskpos[1]+123,1,0)

        Case "h"
            MouseClick("left",$oskpos[0]+207,$oskpos[1]+123,1,0)

        Case "j"
            MouseClick("left",$oskpos[0]+234,$oskpos[1]+123,1,0)

        Case "k"
            MouseClick("left",$oskpos[0]+261,$oskpos[1]+123,1,0)

        Case "l"
            MouseClick("left",$oskpos[0]+288,$oskpos[1]+123,1,0)

        Case ";"
            MouseClick("left",$oskpos[0]+315,$oskpos[1]+123,1,0)

        Case "'"
            MouseClick("left",$oskpos[0]+341,$oskpos[1]+123,1,0)

        Case "enter"
            MouseClick("left",$oskpos[0]+382,$oskpos[1]+123,1,0)

        Case "k4"
            MouseClick("left",$oskpos[0]+513,$oskpos[1]+123,1,0)

        Case "k5"
            MouseClick("left",$oskpos[0]+540,$oskpos[1]+123,1,0)

        Case "k6"
            MouseClick("left",$oskpos[0]+568,$oskpos[1]+123,1,0)

        Case "lshift"
            MouseClick("left",$oskpos[0]+34,$oskpos[1]+145,1,0)

        Case "z"
            MouseClick("left",$oskpos[0]+84,$oskpos[1]+145,1,0)

        Case "x"
            MouseClick("left",$oskpos[0]+111,$oskpos[1]+145,1,0)

        Case "c"
            MouseClick("left",$oskpos[0]+138,$oskpos[1]+145,1,0)

        Case "v"
            MouseClick("left",$oskpos[0]+165,$oskpos[1]+145,1,0)

        Case "b"
            MouseClick("left",$oskpos[0]+192,$oskpos[1]+145,1,0)

        Case "n"
            MouseClick("left",$oskpos[0]+219,$oskpos[1]+145,1,0)

        Case "m"
            MouseClick("left",$oskpos[0]+246,$oskpos[1]+145,1,0)

        Case ","
            MouseClick("left",$oskpos[0]+273,$oskpos[1]+145,1,0)

        Case "."
            MouseClick("left",$oskpos[0]+300,$oskpos[1]+145,1,0)

        Case "/"
            MouseClick("left",$oskpos[0]+327,$oskpos[1]+145,1,0)

        Case "rshift"
            MouseClick("left",$oskpos[0]+373,$oskpos[1]+145,1,0)

        Case "up"
            MouseClick("left",$oskpos[0]+457,$oskpos[1]+145,1,0)

        Case "k1"
            MouseClick("left",$oskpos[0]+514,$oskpos[1]+145,1,0)

        Case "k2"
            MouseClick("left",$oskpos[0]+540,$oskpos[1]+145,1,0)

        Case "k3"
            MouseClick("left",$oskpos[0]+567,$oskpos[1]+145,1,0)

        Case "kent"
            MouseClick("left",$oskpos[0]+595,$oskpos[1]+155,1,0)

        Case "lctrl"
            MouseClick("left",$oskpos[0]+25,$oskpos[1]+165,1,0)

        Case "lwin"
            MouseClick("left",$oskpos[0]+62,$oskpos[1]+165,1,0)

        Case "lalt"
            MouseClick("left",$oskpos[0]+93,$oskpos[1]+165,1,0)

        Case "space"
            MouseClick("left",$oskpos[0]+186,$oskpos[1]+165,1,0)

        Case "ralt"
            MouseClick("left",$oskpos[0]+295,$oskpos[1]+165,1,0)

        Case "rwin"
            MouseClick("left",$oskpos[0]+330,$oskpos[1]+165,1,0)

        Case "rcont"
            MouseClick("left",$oskpos[0]+359,$oskpos[1]+165,1,0)

        Case "rctrl"
            MouseClick("left",$oskpos[0]+390,$oskpos[1]+165,1,0)

        Case "left"
            MouseClick("left",$oskpos[0]+431,$oskpos[1]+165,1,0)

        Case "dn"
            MouseClick("left",$oskpos[0]+455,$oskpos[1]+165,1,0)

        Case "right"
            MouseClick("left",$oskpos[0]+483,$oskpos[1]+165,1,0)

        Case "k0"
            MouseClick("left",$oskpos[0]+527,$oskpos[1]+165,1,0)

        Case "k."
            MouseClick("left",$oskpos[0]+568,$oskpos[1]+165,1,0)


    EndSwitch
EndFunc

Share this post


Link to post
Share on other sites

Thks Bowmore and TurionAltec for help, but I need to click those controls without moving mouse... Something like ControlClick, but this function does not seem to work with "OSK".

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0