Jump to content
Sign in to follow this  
Orcc

Sending to One window

Recommended Posts

Orcc

Hello i have this code where I need it to be Sent ONLY to this window. the code below. Please Fill in where it's wrong and edit for me thanks.

ControlSend ( "Notepad", "",)

Global $Paused

HotKeySet("{End}", "ExitProg") ;;To exit the progam

HotKeySet("{Home}", "StartProg") ;;To start the program

HotKeySet("{Insert}", "TogglePause") ;; Key to pause and unpause

While 1

Sleep(100) ;;;Waits for function call

Wend

Func StartProg()

MouseClick("left", 0, 500, 0)

send("{F1}")

send("{e}")

EndIf

EndFunc

$Paused = False

Func TogglePause()

$Paused = Not $Paused

while $paused

sleep(100)

wend

EndFunc

Func ExitProg()

Exit 0 ;;;Exits the program

EndFunc

Share this post


Link to post
Share on other sites
Authenticity

HotKeySet("{End}", "ExitProg") ;;To exit the progam
HotKeySet("{Home}", "StartProg") ;;To start the program
HotKeySet("{Insert}", "TogglePause") ;; Key to pause and unpause

Global $Paused = False
Global $hNotpad = WinGetHandle('[CLASS:Notepad]')

;ControlSend($hNotpad, "", "", ) ; =?

While 1
    Sleep(100) ;;;Waits for function call
WEnd

Func StartProg()
    MouseClick("left", 0, 500, 0)
    ControlSend($hNotpad, "", "", "{F1}")
    Sleep(500)
    ControlSend($hNotpad, "", "", "e")

EndFunc

Func TogglePause()
    $Paused = Not $Paused
    
    While $Paused
        Sleep(100)
    WEnd
EndFunc   ;==>TogglePause       Tidy asks: "what is the purpose?"

Func ExitProg()
    Exit 0 ;;;Exits the program
EndFunc   ;==>ExitProg

Can you explain?

Share this post


Link to post
Share on other sites
TerarinK

Can you explain what exactally {F1} then pause for half a second then pressing "e" will do in Notepad? All that does for me is opens up the Windows Help and Support then press "e" in the window. One other thing with you MouseClick your not doing anything because you set it to not click. First why run a program to do that why not just make it run then close, or why have the TogglePause in there those 2 button would take lets time then 1 second to complete on the slowest machine

HotKeySet("{End}", "ExitProg") ;;To exit the progam
HotKeySet("{Insert}", "TogglePause") ;; Key to pause and unpause

Global $bPaused = False
Global $hNotepad = WinGetHandle('[CLASS:Notepad]')

;ControlSend($hNotpad, "", "", ) ; =?

While 1
    If $bPaused Then
        ControlSend($hNotepad, "", "", "{F1}")
        ControlSend($hNotepad, "", "[CLASS:Edit]", "Can you explain the single 'e' here")
        $bPaused = Not $bPaused
    EndIf
    Sleep(100) ;;;Waits for function call
WEnd

Func TogglePause()
    $bPaused = Not $bPaused
EndFunc   ;==>TogglePause

Func ExitProg()
    Exit 0
EndFunc   ;==>ExitProg

0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Share this post


Link to post
Share on other sites
Orcc

OK so I implement pause into the script, because when I want to let it rest while I do something else while it's paused.

The reason I have it in there it's because when I try to run other things, like internet explorer it mess's with internet. So I pause it. But if I can figure out how to send to Notepad then I won't have to have the need for a pause, For it will go directly to that program.

Also for every command I send to notepad. I will have to type control send( " " " " "E") like that?

I don't understand what the $ mark does in the script? Can you explain? why is there also a h before the notepad and a B before pause?

ControlSend($hNotepad, "", "", "{F1}")

ControlSend($hNotepad, "", "[CLASS:Edit]", "Can you explain the single 'e' here")

$bPaused = Not $bPaused

Share this post


Link to post
Share on other sites
Authenticity

$ is so the wrapper know that what following it (digits, letters and _) is a variable name. All the prefixes of variables are there to clarify what is their meaning or more precisely, what type of data they contain. h = handle, b or f = boolean, i = integer, etc...

If you want to send directly to the notepad window without having to refocus and defocus it you can use this piece of code:

Dim $hNotepad = WinGetHandle('[CLASS:Notepad]')
.
.
.

; Then send directly to it:
ControlSend($hNotepad, '', '', '1234')
Edited by Authenticity

Share this post


Link to post
Share on other sites
Orcc

So I have Try a new code there was no error's But there was no progress?

The new code I tried is listed below. Why doesn't it send? I have note pad open and blank.

Global $Paused

HotKeySet("{End}", "ExitProg") ;;To exit the progam

HotKeySet("{Home}", "StartProg") ;;To start the program

HotKeySet("{Insert}", "TogglePause") ;; Key to pause and unpause

While 1

Sleep(100) ;;;Waits for function call

Wend

Dim $hNotepad = WinGetHandle('[CLASS:Notepad]')

Func StartProg()

ControlSend("$hNotepad","","", "13413")

EndFunc

$Paused = False

Func TogglePause()

$Paused = Not $Paused

while $paused

sleep(100)

wend

EndFunc

Func ExitProg()

Exit 0 ;;;Exits the program

EndFunc

Share this post


Link to post
Share on other sites
Authenticity

It's because the

Dim $hNotepad = WinGetHandle('[CLASS:Notepad]')

line has to be before the while loop.

Share this post


Link to post
Share on other sites
Orcc

It's still not showing errors but its not doing anything.

Global $Paused

HotKeySet("{End}", "ExitProg") ;;To exit the progam

HotKeySet("{Home}", "StartProg") ;;To start the program

HotKeySet("{Insert}", "TogglePause") ;; Key to pause and unpause

Dim $hNotepad = WinGetHandle('[CLASS:Notepad]')

While 1

Sleep(100) ;;;Waits for function call

Wend

Func StartProg()

ControlSend("$hNotepad","","", "13413") <--13413 is being send to notepad? is this correct? keys 13413

EndFunc

$Paused = False

Func TogglePause()

$Paused = Not $Paused

while $paused

sleep(100)

wend

EndFunc

Func ExitProg()

Exit 0 ;;;Exits the program

EndFunc

Share this post


Link to post
Share on other sites
Authenticity

Nope, if you take a look in the example of the COntrolSend function at the help file you'll see it's not correct but anyway:

ControlSend("$hNotepad","","", "13413") ;<--13413 is being send to notepad? is this correct? keys 13413oÝ÷ Ú+'¢×(®·µ»­¶¬jëh×6ControlSend($hNotepad,"","", "13413") ; Without the quotes enclosing the variable name.

is correct.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.