Orcc Posted April 7, 2009 Share Posted April 7, 2009 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 $PausedHotKeySet("{End}", "ExitProg") ;;To exit the progamHotKeySet("{Home}", "StartProg") ;;To start the programHotKeySet("{Insert}", "TogglePause") ;; Key to pause and unpauseWhile 1 Sleep(100) ;;;Waits for function call WendFunc StartProg() MouseClick("left", 0, 500, 0)send("{F1}")send("{e}")EndIfEndFunc$Paused = FalseFunc TogglePause() $Paused = Not $Paused while $paused sleep(100) wendEndFuncFunc ExitProg() Exit 0 ;;;Exits the programEndFunc Link to comment Share on other sites More sharing options...
Authenticity Posted April 7, 2009 Share Posted April 7, 2009 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? Link to comment Share on other sites More sharing options...
TerarinK Posted April 7, 2009 Share Posted April 7, 2009 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 Link to comment Share on other sites More sharing options...
Orcc Posted April 8, 2009 Author Share Posted April 8, 2009 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 Link to comment Share on other sites More sharing options...
Authenticity Posted April 8, 2009 Share Posted April 8, 2009 (edited) $ 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 April 8, 2009 by Authenticity Link to comment Share on other sites More sharing options...
Orcc Posted April 9, 2009 Author Share Posted April 9, 2009 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 $PausedHotKeySet("{End}", "ExitProg") ;;To exit the progamHotKeySet("{Home}", "StartProg") ;;To start the programHotKeySet("{Insert}", "TogglePause") ;; Key to pause and unpauseWhile 1 Sleep(100) ;;;Waits for function call WendDim $hNotepad = WinGetHandle('[CLASS:Notepad]')Func StartProg() ControlSend("$hNotepad","","", "13413")EndFunc$Paused = FalseFunc TogglePause() $Paused = Not $Paused while $paused sleep(100) wendEndFuncFunc ExitProg() Exit 0 ;;;Exits the programEndFunc Link to comment Share on other sites More sharing options...
Authenticity Posted April 9, 2009 Share Posted April 9, 2009 It's because the Dim $hNotepad = WinGetHandle('[CLASS:Notepad]') line has to be before the while loop. Link to comment Share on other sites More sharing options...
Orcc Posted April 10, 2009 Author Share Posted April 10, 2009 It's still not showing errors but its not doing anything.Global $PausedHotKeySet("{End}", "ExitProg") ;;To exit the progamHotKeySet("{Home}", "StartProg") ;;To start the programHotKeySet("{Insert}", "TogglePause") ;; Key to pause and unpauseDim $hNotepad = WinGetHandle('[CLASS:Notepad]')While 1Sleep(100) ;;;Waits for function callWendFunc StartProg()ControlSend("$hNotepad","","", "13413") <--13413 is being send to notepad? is this correct? keys 13413EndFunc$Paused = FalseFunc TogglePause()$Paused = Not $Pausedwhile $pausedsleep(100)wendEndFuncFunc ExitProg()Exit 0 ;;;Exits the programEndFunc Link to comment Share on other sites More sharing options...
Authenticity Posted April 10, 2009 Share Posted April 10, 2009 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now