Jump to content
Sign in to follow this  
misioooo

How to send keystroke to notepad

Recommended Posts

misioooo

I hope this is not violating any rules ;)

Here is my sample code:

HotKeySet("{F5}","f_start")
HotKeySet("{F9}","f_stop")
HotKeySet("{ESC}","f_exit")

;Variables
Global $mouse_pos[2]
Global $log_x = 660, $log_y = 820, $run = 0


Run("notepad.exe")
Global $notepad = WinWait("[CLASS:Notepad]", "", 10)

Func f_start()
    $run = 1
EndFunc

Func f_stop()
    $run = 0
EndFunc

Func f_exit()
    WinClose($notepad, "")
    exit 0
EndFunc

WinSetState($notepad, "", @SW_MINIMIZE)
Local $hHandle = ControlGetHandle($notepad, "", "Edit1")

While 1
    While $run = 1
        $mouse_pos = MouseGetPos()
        MouseClick("left",$log_x,$log_y,1,0)
        Send("^a")
        Send("^c")
        MouseMove($mouse_pos[0], $mouse_pos[1],0)
        $debug = ControlSend($notepad,"","Edit1","^v")
        MsgBox(0,"Debug","Successfuly sent ctrl + v to notepad: "&$debug)

        $run = 0
    WEnd
WEnd

In general:

Copy works (i have copied text in clipboard).

But i cant get it to paste into notepad window.

I tried using $hHandle, "Edit1", "Edit 1" etc. Notepad window stays empty...

What i am doing wrong?

Btw $debug = 1, so it SHOULD work?

Share this post


Link to post
Share on other sites
Kidney

is there a reason why you want to do it this way as opposed to using FileWrite??

Share this post


Link to post
Share on other sites
misioooo

How stupid of me ;)

There is no particular reason. I did previously file writes and it worked fine. But how to writo to file from clipboard? And i cant do FileRead, i must use Copy (CTRL+c) or other means to get all data.

Edited:

ClipGet should do the trick i suppose...

Edited by misioooo

Share this post


Link to post
Share on other sites
Kidney

ClipGet and ClipPut will work.

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  

×