BennyB Posted July 22, 2005 Share Posted July 22, 2005 I'd like to write a script which logs my actions include the window title and the window text. My idea was: start process while (process is running) do while (no key was hit) compare windowtitle.old with windowtitle if the title is different then write the title and the window text to a file else do nothing wend write the key, which was pressed to a file wend i can't find a function which is similar to "register if a key is pressed" i'm not very good in english, I hope you understand me Link to comment Share on other sites More sharing options...
w0uter Posted July 22, 2005 Share Posted July 22, 2005 _IsPressed() search the forums. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
BennyB Posted July 22, 2005 Author Share Posted July 22, 2005 OK, I testet but one problem still having. script shows like: $pid = run("calc.exe","","") $file = FileOpen("test.txt", 2) While (ProcessExists($pid) <> 0) If _IsPressed('2A') = 1 Then FileWriteLine($file, "DRUCK"); If _IsPressed('0D') = 1 Then $file = FileOpen("test.txt", 1) FileWriteLine($file, "ENTER") FileClose($file) ElseIf _IsPressed('09') = 1 Then $file = FileOpen("test.txt", 1) FileWriteLine($file, "TAB") FileClose($file) EndIf WEnd FileWriteLine($file, "Line1") FileClose($file) Func _IsPressed($hexKey) ; $hexKey must be the value of one of the keys. ; _IsPressed will return 0 if the key is not pressed, 1 if it is. Local $aR $hexKey = '0x' & $hexKey $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey) If Not @error And BitAND($aR[0],0x8000) = 0x8000 Then Return 1 Return 0 EndFunc;==>_IsPressed If I press ENTER or TAB the script write nearly 18 times TAB to the file, is that normal, can I fix this problem? Link to comment Share on other sites More sharing options...
h8no1 Posted July 22, 2005 Share Posted July 22, 2005 Looks like you could need a little Sleep in your while loop. As it is now in your code it will as long as the key you are looking for is pressed it will write to the file so thats why you get so many of the same. I am not sure what you are trying to do but I think you could get a better result from the HotKeySet () function. Link to comment Share on other sites More sharing options...
BennyB Posted July 22, 2005 Author Share Posted July 22, 2005 If I work with a sleep it can cause faults? isn't it? I'd like to make a macro-recorder for installation routine. Link to comment Share on other sites More sharing options...
herewasplato Posted July 22, 2005 Share Posted July 22, 2005 If I work with a sleep it can cause faults? isn't it?I'd like to make a macro-recorder for installation routine.<{POST_SNAPBACK}>see http://www.autoitscript.com/forum/index.ph...opic=5760&st=40partial quote from that post:It also implements a keyup keydown state so slow typers don't feed in IIII'''MMMM WRRITTINGGG SOMMEETHIINGGG... I was having problems with that last sleep(100) in the log func. I couldn't find a time that suited my fast typing and my slow typing without either skipping keys or adding too many to the log. later [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
w0uter Posted July 22, 2005 Share Posted July 22, 2005 i use If _ispressed ;do whatever While _isPressed sleep(10) Wend ;do whatever EndIf My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll 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