dieterhatn Posted October 27, 2014 Share Posted October 27, 2014 Hey there! I'd like to add a simple Clipboard manager to my autoit script, but the problems start with the trigger. Is there a way to make autoit execute smth after I've hit Ctrl+C or Ctrl+X? I don't want to run a loop for this. Thanks in advance Link to comment Share on other sites More sharing options...
MikahS Posted October 27, 2014 Share Posted October 27, 2014 Yes, there is a way to do this, but many ways of doing so. Using _IsPressed and/or GUI Accelerator keys could do this for you. Have a look in the HelpFile for these and try scripting something. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
dieterhatn Posted October 27, 2014 Author Share Posted October 27, 2014 Yes, there is a way to do this, but many ways of doing so. Using _IsPressed and/or GUI Accelerator keys could do this for you. Have a look in the HelpFile for these and try scripting something. Well, in order to work with _IsPressed I need to run a loop. I haven't looked ad GUI accelerators tho, problem is my script does not have a GUI. What happens if I set an Acceleraotr hotkey to Ctrl + C? Will it block the windows default behavior? Link to comment Share on other sites More sharing options...
MikahS Posted October 27, 2014 Share Posted October 27, 2014 Well, in order to work with _IsPressed I need to run a loop. I haven't looked ad GUI accelerators tho, problem is my script does not have a GUI. What happens if I set an Acceleraotr hotkey to Ctrl + C? Will it block the windows default behavior? To use Accelerators you must have a GUI, so I'm thinking using _IsPressed is going to be the option you use. #include <Misc.au3> #include <MsgBoxConstants.au3> Local $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("11", $hDLL) And _IsPressed("43", $hDLL) Then MsgBox(0, "", "I run after CTRL + c !") ElseIf _IsPressed("1B", $hDLL) Then MsgBox($MB_SYSTEMMODAL, "_IsPressed", "The Esc Key was pressed, therefore we will close the application.") ExitLoop EndIf Sleep(250) WEnd DllClose($hDLL) Something like that? Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
dieterhatn Posted October 27, 2014 Author Share Posted October 27, 2014 Something like that? That's exactly what I did not want to use, I do not want any loops in my script. That's why I'm asking for something else. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 27, 2014 Moderators Share Posted October 27, 2014 dieterhatn,You will need at least one loop in your script to keep it running - so why the aversion to using a loop to poll for the key being pressed? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
dieterhatn Posted October 27, 2014 Author Share Posted October 27, 2014 (edited) dieterhatn, You will need at least one loop in your script to keep it running - so why the aversion to using a loop to poll for the key being pressed? M23 That's true, but I want it to be as lightweight as possible because its running permanently. Is there a way to make autoit hotkeys not prevent the default behaviour? that could be another way to get it work with hotkeyset //Edit: Or is there a way to imitate that default behaviour? Edited October 27, 2014 by dieterhatn Link to comment Share on other sites More sharing options...
MikahS Posted October 27, 2014 Share Posted October 27, 2014 That's exactly what I did not want to use, I do not want any loops in my script. That's why I'm asking for something else. As melba stated. You must use at least 1 loop. And what do you mean as lightweight as possible? Anything running permanently must use loop(s). Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
jguinch Posted October 27, 2014 Share Posted October 27, 2014 (edited) Another way could be to use _ClipBoard_SetViewer , even if you do not have a GUI (you can create an invisible one with just GUICreate() ) Edited October 27, 2014 by jguinch Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
BrewManNH Posted October 27, 2014 Share Posted October 27, 2014 Technically, every AutoIt script has a hidden window that is created when it is run. Whether or not you use a GUI for your own script. Which doesn't help in this instance because the OP doesn't need a GUI, they just need a way to keep the script running and to poll for the keys being pressed. 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...
jguinch Posted October 27, 2014 Share Posted October 27, 2014 @BrewManNH : I thought _ClipBoard_SetViewer was a good solution to track any clipboard changes (because CTRL + C/X generates a clipbloard event) For the hidden window, I know it, but I didn't manage to use GUIRegisterMsg without creating a GUI Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
dieterhatn Posted October 28, 2014 Author Share Posted October 28, 2014 (edited) @BrewManNH : I thought _ClipBoard_SetViewer was a good solution to track any clipboard changes (because CTRL + C/X generates a clipbloard event) For the hidden window, I know it, but I didn't manage to use GUIRegisterMsg without creating a GUI So I need a (hidden) GUI for _ClipBoard_SetViewer to work? And will it track any changes or just changes I did within the GUI? As melba stated. You must use at least 1 loop. And what do you mean as lightweight as possible? Anything running permanently must use loop(s). I am using a loop, containing one sleep command. I just don't want it to make any calls at all when it's in idle. My script is completely based on hotkeys. Edited October 28, 2014 by dieterhatn Link to comment Share on other sites More sharing options...
jguinch Posted October 28, 2014 Share Posted October 28, 2014 @dieterhatn : try the example for _ClipBoard_SetViewer() : remove (comment) the GUISetState(@SW_SHOW) line, then replace GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) by MsgBox(0, "", $sMessage) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
dieterhatn Posted October 28, 2014 Author Share Posted October 28, 2014 (edited) Rather than checking for a keypress, I could just get the clipboard in a loop and check for double entries. Which leads me to another question: Is there a way in autoit to get the clipboard? I don't mean ClipGet(), i have to get the content no matter what it is. From what I've read can ClipGet only get strings. Edited October 28, 2014 by dieterhatn Link to comment Share on other sites More sharing options...
jguinch Posted October 28, 2014 Share Posted October 28, 2014 Look at the helpfile : there are some Clipboard functions in the UDF section. Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF 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