ineedh3lp Posted September 8, 2011 Posted September 8, 2011 (edited) Hello! I'm currently struggling to figure out how to make the Delete key do something in a file manager and something else outside it. #NoTrayIcon #AutoIt3Wrapper_icon=_resources\icon.ico #AutoIt3Wrapper_Compression=0 Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase HotKeySet("{DEL}", "FUNC_X2Delete") While 1 Sleep(100) WEnd Func FUNC_X2Delete() If WinGetState("xplorer") = 15 Then Send("{ALT down}9{ALT up}") Else Send("{DEL}") ;~ Send("{DEL down}{DEL up}") EndIf EndFunc ;==>FUNC_X2Delete I basically want to replace the Del shortcut in the file manager and have it do something else, while outside it the Delete key would be just the Delete key. Please tell me if it is even possible to do this and provide some guidelines. Thank you! EDIT: Ah, nevermind, this solves it: Func FUNC_X2Delete() If WinGetState("xplorer") = 15 Then Send("{ALT down}9{ALT up}") Else HotKeySet("{DEL}") Send("{DEL}") HotKeySet("{DEL}", "FUNC_X2Delete") ;~ Send("{DEL down}{DEL up}") EndIf EndFunc ;==>FUNC_X2Delete Edited September 8, 2011 by ineedh3lp
boogieoompa Posted September 8, 2011 Posted September 8, 2011 (edited) You need to make the hotkey function unregister and than send the hotkey when the window isnt active. Something like... HotKeySet("{del}", "FunDelete") While 1 Sleep(100) WEnd Func FunDelete() If WinActive("Untitled") Then HotKeySet("{del}") Send("{del}") HotKeySet("{del}", "FunDelete") Else MsgBox(4096,"","You clicked delete and your not in notepad.") EndIf EndFunc Edit: DOH just noticed the bottom of the post! Had this pulled up than I walked out of the room. Think thats what your looking for. Edited September 8, 2011 by boogieoompa
ineedh3lp Posted September 8, 2011 Author Posted September 8, 2011 Yeah, I figured out after I read the associated help file... I didn't realize it presented the solution already ; capture and pass along a keypress HotKeySet("{Esc}", "captureEsc") Func captureEsc() ; ... can do stuff here HotKeySet("{Esc}") Send("{Esc}") HotKeySet("{Esc}", "captureEsc") EndFunc Thanks for the reply! Now I'm having a different issue : D Let's say I want to rename a file and delete part of its name using Delete, but because that happens in the file manager, Delete isn't actually Delete, but the assigned function... now I'm wondering how to make Del work as Delete while renaming a file. (I know I can just use backspace, but I want to keep my old habit).
JohnOne Posted September 8, 2011 Posted September 8, 2011 To rename a file use FileMove() function , see remarks <- help file AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
ineedh3lp Posted September 8, 2011 Author Posted September 8, 2011 Thanks for the reference, but I'm not trying to rename a file using AutoIt, I'm renaming it manually. The issue is that I can't use the Delete key to delete part of the file's name (while in the renaming process) because Delete is already assigned to do something else while the file manager is focused and active. What I'd need here would be a way to find out (using AutoIt) if the cursors is in text edit mode (you know, the blinking cursor)- then I could unregister the Delete hotkey only while renaming the file. So, is there a way to find out through AutoIt if there's a blinking cursor active?
boogieoompa Posted September 8, 2011 Posted September 8, 2011 Thanks for the reference, but I'm not trying to rename a file using AutoIt, I'm renaming it manually. The issue is that I can't use the Delete key to delete part of the file's name (while in the renaming process) because Delete is already assigned to do something else while the file manager is focused and active. What I'd need here would be a way to find out (using AutoIt) if the cursors is in text edit mode (you know, the blinking cursor)- then I could unregister the Delete hotkey only while renaming the file. So, is there a way to find out through AutoIt if there's a blinking cursor active? As far as I know there is no logical statement you can make that checks for a blinking cursor (probably because there are several different types and places where this would qualify). You can however adjust your logicical clauses to be more specific so that instead of just becoming the delete key for 1 window it does it for multiple. From my previous example [font=monospace] HotKeySet("{del}", "FunDelete")[/font] [font=monospace] While 1 [/font] [font=monospace] Sleep(100)[/font] [font=monospace] WEnd[/font] [font=monospace] [/font] [font=monospace] Func FunDelete()[/font] [font=monospace] If WinActive("Untitled") OR WinActive("Filemanager") OR WinActive("Someother window")Then [/font] [font=monospace] HotKeySet("{del}") [/font] [font=monospace] Send("{del}") [/font] [font=monospace] HotKeySet("{del}", "FunDelete") [/font] [font=monospace] Else [/font] [font=monospace] MsgBox(4096,"","You clicked delete and your not in notepad.")[/font] [font=monospace] EndIf[/font] [font=monospace] EndFunc[/font]
ineedh3lp Posted September 8, 2011 Author Posted September 8, 2011 (edited) You can however adjust your logicical clauses to be more specific so that instead of just becoming the delete key for 1 window it does it for multipleIn my script, the Delete key is Delete for all windows except the file manager. That's because I do not want to use the file manager's way of deleting files and folders, so when I press Delete (only while the file manager window is active) I'm actually using my own file deletion application. I'm going to experiment with MouseGetCursor ( ) to see if I can achieve something acceptable. Edited September 8, 2011 by ineedh3lp
JohnOne Posted September 9, 2011 Posted September 9, 2011 Great if you can do it that way. But if you are doing thin manually then why not just select with mouse and either right click, delete, or simply use the backspace key? Just seems like much ado about nothing. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
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