Smiley357 Posted July 2, 2008 Share Posted July 2, 2008 (edited) ($hWnd[, $iElapse = 250[, $sTimerFunc = ""[, $iTimerID = -1]]]) I was wondering if someone could help me with this func. I have a few questions and the help file doesnt quite cover them. 1) $hWnd Can anyone explain what this variable would be? I know it says Handle to the window to be associated with the timer. This window must be owned by the calling thread _Timer_SetTimer But if im using the timer_settimer to call a func at $iElapse time. Im confused as to what window it is asking for. 2) Can you pass varibles in to the function or do I just have to use a global variable? i.e. $sTimerFunc = $_myfunc($varable) 3) Can someone give me a simple working example of the _Timer_SetTimer function. Thanks for any and all help. Edited July 8, 2008 by Smiley357 Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted July 2, 2008 Share Posted July 2, 2008 1. A window you created. If you don't want any visible gui then simply GUICreate() without GUISetState() 2. Dont know. 3. Is there something wrong with the one in the helpfile?? .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Smiley357 Posted July 2, 2008 Author Share Posted July 2, 2008 @AdmiralAlkex 3) yes I start to get cross-eyed looking at it LOL Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted July 2, 2008 Share Posted July 2, 2008 @AdmiralAlkex3) yes I start to get cross-eyed looking at it LOLIf you got problems with your eyes then maybe you should visit your doctor lol .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Smiley357 Posted July 2, 2008 Author Share Posted July 2, 2008 As of right now my script runs in the back round sending keystrokes at some time interval. It will send the keystroke to any window that is on top. If I use the _time_setTime () and use $hWnd = word. Will this send the keystrokes to the word document even if its minimized? Or, am I just going way off track? Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 2, 2008 Share Posted July 2, 2008 ($hWnd[, $iElapse = 250[, $sTimerFunc = ""[, $iTimerID = -1]]]) I was wondering if someone could help me with this func. I have a few questions and the help file doesnt quite cover them. 1) $hWnd Can anyone explain what this variable would be? I know it says Handle to the window to be associated with the timer. This window must be owned by the calling thread _Timer_SetTimer But if im using the timer_settimer to call a func at $iElapse time. Im confused as to what window it is asking for. 2) Can you pass varibles in to the function or do I just have to use a global variable? i.e. $sTimerFunc = $_myfunc($varable) 3) Can someone give me a simple working example of the _Timer_SetTimer function. Thanks for any and all help. _Timer_SetTimer() creates a count-down timer and triggers a specified function when it expires. What are you trying to do? Are you sure you want this function and not TimerInit()/TimerDiff()? 1) The $hWnd is a window handle, as returned by GuiCreate(). 2) Yes, you can and usually would pass a variable to this function for $hWnd, for example. 3) What's wrong with the example in the help file? If it's just too complicated, try this simplified one: #include <Timers.au3> Global $iCount = 0 Global $hGUI = GUICreate("Test", 400, 300) GUICtrlCreateLabel("Two steps forward, one step back...", 20, 20, 360, 20) Global $IdLabel = GUICtrlCreateLabel("00", 60, 60, 280, 320) GUICtrlSetFont(-1, 72, 600) GUISetState() Global $IdTimer1 = _Timer_SetTimer($hGUI, 1000, "_Increment"); 1sec Global $IdTimer2 = _Timer_SetTimer($hGUI, 2500, "_Decrement"); 2.5sec Global $IdTimer3 = _Timer_SetTimer($hGUI, 30000, "_Quit"); 30sec While 1 Sleep(20) WEnd Func _Increment($hWnd, $Msg, $iIDTimer, $dwTime) $iCount += 1 GUICtrlSetData($IdLabel, StringFormat("%03u", $iCount)) EndFunc Func _Decrement($hWnd, $Msg, $iIDTimer, $dwTime) $iCount -= 1 GUICtrlSetData($IdLabel, StringFormat("%03u", $iCount)) EndFunc Func _Quit($hWnd, $Msg, $iIDTimer, $dwTime) Exit EndFunc Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 2, 2008 Share Posted July 2, 2008 As of right now my script runs in the back round sending keystrokes at some time interval. It will send the keystroke to any window that is on top. That would be more easily accomplished with AdLibEnable().If I use the _time_setTime () and use $hWnd = word. It would be more like $hWnd = WinGetHandle("Word")Will this send the keystrokes to the word document even if its minimized? Or, am I just going way off track? Way off track.Use AdLibEnable() for your timer, and ControlSend() to send keystrokes to a minimized widow in your called function. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Smiley357 Posted July 3, 2008 Author Share Posted July 3, 2008 @PsaltyDS Thanks for all the help. I will give it a try and let you know how it goes. Link to comment Share on other sites More sharing options...
Smiley357 Posted July 3, 2008 Author Share Posted July 3, 2008 AdlibEnable() This seems to work if I only had one timed function. I have 8 different functions that I have set to execute at different timed intervals. This is just a little test script to try to understand _timer_setTimer and _controlSend. It will run but will seem to lock up or act as if its waiting for something and will not send any output to the word file. And the esc hotkey wont work to exit the program when after I hit F11 to start it. Im guessing it is looking/waiting for something that I have made a mistake on. I feel like the biggest noob right about now. LOL expandcollapse popup#include <Word.au3> #Include <Timers.au3> HotKeySet("{ESC}", "Terminate") HotKeySet("{F11}", "start") while 1 Sleep(300) WEnd Func start() $oWordApp = _WordCreate ("") $oDoc = _WordDocOpen ($oWordApp, @ScriptDir & "\Test.doc") Global $hGUI = WinGetHandle("Word") ;Timer_SetTimer($hGUI, 1000, "_UpdateStatusBarClock"); create timer _Timer_SetTimer($hGUI, 3000, "_time1") _Timer_SetTimer($hGUI, 5000, "_time2") EndFunc Func _time1() ControlSend ( $hGUI, "", "edit1", "Im in time1 {enter}") EndFunc Func _time2() ControlSend ( $hGUI, "", "edit2", "Im in time2 {enter}") EndFunc ;Terminate Func Terminate() Exit 0 EndFunc Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 3, 2008 Share Posted July 3, 2008 (edited) AdlibEnable() This seems to work if I only had one timed function. I have 8 different functions that I have set to execute at different timed intervals. You can only have one AdLibEnable() function, but there is no reason why it can't handle multiple timers: expandcollapse popupGlobal $iTimer_1 = TimerInit(), $iTimer_2 = TimerInit(), $iTimer_3 = TimerInit() Global $i_1 = 0, $i_2 = 0, $i_3 = 0 HotKeySet("{ESC}", "_Quit") AdlibEnable("_TimerDispatch", 500) TrayTip("Timers Test", "$i_1 = " & $i_1 & " $i_2 = " & $i_2 & " $i_3 = " & $i_3, 5) While 1 Sleep(20) WEnd Func _TimerDispatch() ; 1 sec If TimerDiff($iTimer_1) >= 1000 Then $iTimer_1 = TimerInit() $i_1 += 1 EndIf ; 2 sec If TimerDiff($iTimer_2) >= 2000 Then $iTimer_2 = TimerInit() $i_2 += 1 EndIf ; 3 sec If TimerDiff($iTimer_3) >= 3000 Then $iTimer_3 = TimerInit() $i_3 += 1 EndIf ; Refresh display TrayTip("Timers Test", "$i_1 = " & $i_1 & " $i_2 = " & $i_2 & " $i_3 = " & $i_3, 5) EndFunc ;==>_TimerDispatch Func _Quit() Exit EndFunc ;==>_Quit On your _Timer_SetTimer(), the window has to be owned by the same process. I think this means it has to be one created by the same script with GuiCreate(), not Word, for example. muttley Edited July 3, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Smiley357 Posted July 8, 2008 Author Share Posted July 8, 2008 Im still having issues trying to send a string to word with controlsend. Here is what I have. I have pulled everything out but a simple open word and send string to the word file opened. Can someone please help. This will open a word doc. but then nothing happens. #include <Word.au3> HotKeySet("{ESC}", "Terminate") HotKeySet("{F11}", "start") while 1 Sleep(300) WEnd Func start() ;Global $oWordApp = _WordCreate ("") Run("C:\Program Files\Microsoft Office\OFFICE11\winword.exe") $handle = ControlGetHandle("[CLASS:Microsoft word]", "", "Edit1") Sleep(1000) ControlSend ( $handle, "", "edit1", "Im in time2 {enter}") EndFunc ;Terminate Func Terminate() Exit 0 EndFunc Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 8, 2008 Moderators Share Posted July 8, 2008 Did you try the Word functions since you are dealing with .doc? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Smiley357 Posted July 8, 2008 Author Share Posted July 8, 2008 Yeah, I tried the word functions. And was unable to get that to work also. So, I was trying to get a very simple example of how to use it. If I could see a working example of how to do this I would understand where my mistake is and fix my code. Thanks for all the help. Keep the ideas and help coming please. Link to comment Share on other sites More sharing options...
Smiley357 Posted July 9, 2008 Author Share Posted July 9, 2008 bump.... anyone? Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 9, 2008 Share Posted July 9, 2008 Yeah, I tried the word functions. And was unable to get that to work also. So, I was trying to get a very simple example of how to use it. If I could see a working example of how to do this I would understand where my mistake is and fix my code. Thanks for all the help. Keep the ideas and help coming please. What made you think there was an "Edit1" control in Word? Use AU3Info.exe to check on the control IDs in your version, which you obviously didn't do before. Anyway, this works with my version: $hWord = WinGetHandle("Document1 - Microsoft Word") If Not IsHWnd($hWord) Then MsgBox(16, "Error", "Failed to get handle") ControlSend($hWord, "", "[CLASS:_WwG; INSTANCE:1]", "Test.") Use AU3Info.exe to check on the control IDs in your version. muttley Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Smiley357 Posted July 10, 2008 Author Share Posted July 10, 2008 What made you think there was an "Edit1" control in Word? In the Autoit help for controlsend() they used notepad as a example. So I took a wild stabe and tried edit1 for the controlID in word. Use AU3Info.exe to check on the control IDs in your version I did try the AU3info.exe to try to find the controlID. I had seen nothing that said controlID. But I just had a thought when I read your post. I looked for edit1 in the notepad with AU3info.exe and seen that ClassnameNN is what I was looking for. I tried this and it worked. ControlSend ( $hGUI, "", "_WwG1", "Im in time1 {enter}") Your code also worked for me. However, on both of our code when I try to have 2 controlsends the first one stops whenever the 2nd one starts because the first one is sent to the backround. I thought you use controlsend to send text to a minimized window? Is there a better way to send text to a minimized window? One more question now. What is the best way to send a mouse click to a minimized window? I feel like I get one question answered but have 10 more that come from the answer. LOL Link to comment Share on other sites More sharing options...
Smiley357 Posted July 14, 2008 Author Share Posted July 14, 2008 Anyone have any thoughts or comments on how to send text and mouse clicks to a minimized window or window in the background? Everything I have found so far is to use controlsend() for this. Link to comment Share on other sites More sharing options...
BrewManNH Posted November 16, 2011 Share Posted November 16, 2011 FSoft, you should open a new thread in regards to whatever your issue is. Replying to a 3 year old thread is never a good idea at all. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Floppy Posted November 17, 2011 Share Posted November 17, 2011 FSoft, you should open a new thread in regards to whatever your issue is. Replying to a 3 year old thread is never a good idea at all.LOLSorry, I replied in the wrong topic!! 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