• Become a Power user Intro to AutoHotkey Intermediate AutoHotkey Intermediate Objects GUIs are Easy w/AutoHotkey Painlessly switch from V1 to V2

Naked Clipboard: Paste plain text

Use the Naked Clipboard to paste plain text in any program.  Now you can select the hotkey you wish to use as the trigger

the Naked Clipboard: Adding a GUI to Paste Plain Text AutoHotkey script

the Naked Clipboard: Adding a GUI to Paste Plain Text AutoHotkey script

The key idea of the video is to demonstrate how to add a GUI to an AutoHotkey script, allowing users to select hotkeys and send plain text from their clipboard, while also discussing code organization, dynamic hotkeys, and preferences.

  • 00:00 The speaker discusses a script that allows users to copy and paste plain text, demonstrating how to add a GUI to the script for users to choose and save their preferences.
    • The speaker discusses a script that allows users to copy and paste plain text, which is useful when certain programs lack this functionality.
    • The script allows you to paste plain text without formatting by selecting a hotkey, removing all formatting before pasting, and still having the option to paste with formatting using the normal control v.
    • The script demonstrates how to add a GUI to a plain text AutoHotkey script, including the challenges of creating a GUI and saving preferences for later use.
    • The video demonstrates how to add a GUI to a script, allowing users to choose and save their preferences.
  • 04:08 The video explains how to add a GUI to a script that allows users to select a hotkey and send plain text from their clipboard, demonstrating code organization, dynamic hotkeys, and a standard menu for text expansion.
    • The video discusses adding a GUI to a script that allows users to select a hotkey and send plain text from their clipboard without any images or other content.
    • The script allows for a hotkey preference menu to be added, enabling the conversion of the script into a GUI.
    • The speaker demonstrates how to separate and organize code, create dynamic hotkeys for pasting plain text from the clipboard, and use a standard menu for text expansion.
  • 07:26 The speaker explains how to add a GUI to a plain text AutoHotkey script, including creating a menu, adding preferences, and making variables global when using a function in a GUI.
    • The speaker discusses adding a feature to their scripts that removes unnecessary elements and checks for updates, and they also mention removing an icon.
    • The speaker discusses adding a GUI to a script, including creating a menu and adding preferences, and mentions the need to make variables global when using a function in a GUI.
    • The speaker discusses setting a global solution for adding a GUI to a plain text AutoHotkey script, including adding a hotkey control and a checkbox for the window key.
  • 11:38 Add a button to capture the chosen windows key, discuss the need to make a hotkey function global, set the hotkey to call the function “paste naked”, and create a program that saves information into a file and sets hotkeys.
    • Add ten points to the control size and adjust the positioning of the checkbox to align it with the text control, then add a button to capture the chosen windows key.
    • The speaker discusses the need to make a hotkey function global in order to access variables and save files in a program.
    • Name the window reference “default” and set the hotkey to “current hotkey” to call the function “paste naked”, also check if the window key is set.
    • Add a modifier if it is not set, save the information, write the value, and set the file name as desired.
    • Create a program that saves information into a file and sets hotkeys, but remember to set the hotkeys after reading them.
  • 18:12 The speaker discusses testing a script and setting up hotkeys, accessing a list of keys, and testing functionality with breakpoints, as well as preferences for a window and the advantage of not needing to reload code in a GUI.
    • The speaker discusses testing a script and predicting the outcome, specifically focusing on setting up hotkeys and accessing a list of keys that have been set up.
    • The speaker tests the functionality of a script by setting up a breakpoint and confirming that pressing a certain key combination triggers the desired action, and then proceeds to discuss preferences for a window.
    • When modifying code in a GUI, there is no need to reload it because the GUI is always calling the function.
  • 21:36 The speaker demonstrates how to add a GUI to an AutoHotkey script, including setting new hotkeys and fixing and updating them.
    • Using hotkeys dynamically can cause problems with old hotkeys not being unset, so it is important to test and make adjustments accordingly.
    • The speaker demonstrates how to add a GUI to a script in AutoHotkey, including setting a new hotkey and saving the current hotkey.
    • The program loses the old value of the current key when a guitar is done, so it is recommended to use a different name for the current hockey variable to avoid this issue.
    • The speaker discusses fixing and updating hotkeys in an AutoHotkey script, including setting a new hotkey and making it the default action when clicking the icon.
  • 27:20 The speaker discusses issues with the hotkey text, variable values, missing parenthesis, and unexpected behavior, but ultimately fixes them in the script.
    • The speaker discusses using regular expression to remove the window key from the current hotkey text and ensuring that the variable for the window key is set to false.
    • The speaker discusses the issue of using different values for the variable “check” and suggests fixing it by checking the values.
    • There was an issue with a missing parenthesis and a variable not being displayed in the preferences window, but after making some changes and saving them, the issue was fixed.
    • The speaker discusses the issue of the current hotkey not being properly replaced when turned off and on again, causing unexpected behavior in the program.
    • The regular expression in the script can either count how many times it replaced a string or grab the new string, but not both.
  • 34:07 The speaker explains how to add a default preference to the AutoHotkey script, allowing the window to open with one click and adding a tray icon for users to choose whether or not to display it.
    • The speaker discusses how to add a default preference to a menu in the AutoHotkey script.
    • You can make it so that the window opens with just one click instead of double-clicking.
    • Add a tray icon to the script and allow users to choose whether or not to display it, as well as adding more functions gradually.
    • The speaker has completed the grip and added an icon for the clipboard, suggesting that it is a good starting point.

hey it’s a joke lines from the-Automator with Isaias’s here also from the honor andi was i was mentioning to him i had this script that i had worked on years ago about how to copy play copy anything you know and then paste in plain text and we’re going to show you a really quick example here of why you’d care and and but like at ti like the this was one of the most popular scripts that i shared with people because they they were like oh my god i i copy all the time paste in the notepad and
the-Automator.com paste plain text and this little script is very good because for example let’s say you are on a website and you want to copy some things in there right so let’s go ahead and just copy this part and for any reason you go to word or any program that does this kind of thing
and you paste that and what is gonna happen is that you’re gonna the text is gonna come up with all the formatting now right now word allows you to go ahead and change it to the normalformat so paste it without formatting but not all programs allow you to do this and by the time this was written word didn’t have that capability either right so it was a very good solution at the time word picks that but there are many programs out there that haven’t fixed that so the script what it does is that it’s
gonna sit on yAuto tray right andwe decided to make it so that you can select a Hotkey for it you can select whatever Hotkey you want and when you press thatHotkey you’re gonna get the normal text like you’re gonna be plain text it doesn’t matter if it has formatting or not because the script removes all formatting before pasting and the good thing about it is that you still have the control v the normal control v would paste the text with its formatting so you have both you have to control without formatting
so basically you have both things if you want them right yeah that was the beautiful you it temporarily replaces the clipboard paste the plain text and then restores the clipboard back with the original stuff in case you wanted it exactly so we’re going to show you is how we could go ahead and how we updated that script a little bit right yeah because the script is working perfectly fine we didn’t do any changes to the clip to this part in here what we did changes to is the fact that we actually created a gui for it and
we demonstrate more or less the problems that come with creating a gui things that you have to keep in mind it looks like a simple gui something very simple but there’s two things adding a gui andsaving yAuto preferences like the Hotkey that you created saving it for later use when the script starts those things introduce a little concept and a little problem that we should keep in mind right yeah and and just fyi so we have of course intro to dewey’s with aHotkey right actually i think it’s called gooeys are easy
yeah and the-Automator and we’re we were working through i was talking to him about adaptingthis one of my favorite simple it’s one of the things that people love the most
actually Isaias’s came up with a new name for it the naked what’d you call it make it make it squared the nakedright we’re gonna get banned on youtube now anywayand and we i said let’s convert it where we can because i have it with ctrl g but let’s convert it to where we could easily let people choose their Hotkey for itand make a couple tweaks so and then i thought you know what we’re adding the gui let’s let’s show the process and talk through the process of adding a gui because it’s just a
great you know gooeys are amazing and it helps it helps yAuto script be more viral right and then so yeah let’s go ahead and see what you’re doing first of all the the first thing that we’re going to talk about is what kind of gui i want so basically it’s just a very simple gui that will allow you to selecttheHotkey that you want so and how would i show how would i use that in a script that usually doesn’t need that gui so the the concept of the script is that you have something on your clipboard
and when you press a key a keyboard Hotkey right going to send the clipboard without any images and stuff because the clipboard can contain several stuff right so you want just the text the plain text that’s what the script does so i don’t need a gui for that i just prefer Hotkey and that’s it so what how can i convert that into having a gui the easiest way let me go ahead and share my screen is to add kind of like a probably a preferences menu so i would put it on the script icon i would add a new menu item that says
like change the-Automator.com like this i will do some things that are my preference by the way so we can just go ahead and select all theguys here and just move them right so that we could at least have them separated from the other code so that it is a little bit easier to read right so there we go and
the Auto thing is if you want aHotkey to be kind of like dynamics so you could change it for other things then what you want here is either a label or a function that’s what you want so let’s change that to labelpaste make it i will name it so the the idea is that you’re gonna be pasting the plain text from the clipboard so we’re removing anything that is not needed so we’re ready yeah yeah we’re just go ahead and which is crazy because line five that’s what it does and it’s so simple
right it doesn’t like if you were to read this you’re like what the hell are we is he doing the big song like the one right yeah so line six is the one that grabs the clipboard and pasted it in itself and just by doing that you basically strip every formatting and you’re just gonna get the the empty text also sorry the text right without formatting anything so the other thing that we’re gonna do so let’s go ahead and grab thea minion so i havea standard menu here and this is text i have it kind of like a like a hot
string that expanded right this is something that i usually add to most of my scripts for that reason i just created this littleyeah so we have the no standard that removes everything check for updates about reload and exit that’s what i need and in our case let’s go ahead and remove this icon we’re gonna use it for later so let’s try to remove thati don’t need about checking for updates probably be about i’m gonna do it later but for now i’m gonna keep the remote so these guy’s
i don’t need this function for now so i just need to reload connected and let’s go ahead and add the menu gray and add i’m gonna put here say for examplethe preferences right and let’s go ahead and add that one to agree that we’re going to create i think if you you don’t put anything you can use it as your own let’s go ahead and return here because i don’t need anything and use the preferences [Music] you have ctrl g as the mainHotkey that you want and let’s have your
variable and there we go so let’s go ahead and see how that looks and if i run this grip save it first when we run it we don’t get anything at the momenthere at the bottom we have our so let me go ahead and verify come on yeah so that’s our script there it’s interesting that it didn’t change the name so here we have our our icon we have a right click now we have only the menu items that we are interested in which are the one of the three that i left there and the preferences should go ahead and try to create a gui
but i forgot if you use a function you have to actually make it global because all variables that are that belong to a gui must be global variables so usually the solution for that is just to go ahead and set it to global now we have it here now what i’m looking right now is i just look like that go ahead and take a look at what is going on there because yes it’s not adding the top key oh what is that i just typed something in there that didn’t belong there other way so there was an option in there that i
typed by mistake i don’t know why i did that but yeah so now Auto gui is already there we have aHotkey right now so let’s go ahead and add a checkbox and we’re going gonna make it
uh we’re gonna make it windows key right and here as i’m just adding a checkbox let’s go ahead and add ten points to this one so that right nowi have it now usually i get really annoyed by this but the the size of this control is you know they do not line up as you want yeah usually you just yeah so you the only thing that you have to do is usually for the next control right next to a text control or a check box is why previous minus three pixels the difference between them is three pixels actually
using the the default sizes so as soon as you do that when you go ahead and do thatit’s kind of like going to line up in a way that is kind of like centered the checkbox is going to be centered relative to the other thing and let’s just add a few more pixels there at the top so that we have our little kind of like leeway over there so that’s what we’re looking for okay so now we have kind of like a very basicuh way for me to choose either if you have the windows and whatever letter you want and
the only thing that we need now is a way to capture that so let’s go ahead and setwindows key turn my key here and let’s add this button here usually i made it make it 75 same now usually that’s the end of it like you don’t need to do much stuff but i i would like to keep that Hotkey every time that i start the program that makes the program a little bit more complicated right so the save command is going to go ahead and save an any file or whatever you want right you can do like that let me go ahead and use the
real definition function that’s the real definition of functions that are going to be called by a button like this and usually i like to explicitly say what function is going to be called just in case so what are we going to do first of all we need this function to be global as well because we want to access the Hotkeys that the the variables that are here right so i want to access those i want to name my window references default and let’s make it new here let’s drop that and make it here people that make sure that i have the correct
window selected always and now that i have that let’s go ahead and resubmit and that is going to do a few things so Auto first thing is to go ahead and set the Hotkey that we want so the Hotkey that we want is gonna be current Hotkey Hotkey we’re gonna use current and the label or function that we’re going to be calling all the time is the paste naked so that’s what is going to happen and that’s it you just have yourself a way to change theHotkeydynamically the next part that we want is just to save that information oh
by the way on the window key we have to actually check whether the window key is there or not in that case we just add that for length and what i’m doing right there is if the window key is set i’m gonna add the the modifier if not if it is not set i’m just going to leave it blank and that way if you selected that during the selection then you’re good to go right so after you have that let’s go ahead and save that information so what we’re going to do is write and the value that we’re going to
bewriting is the this all of this because i want to make sure that i grab the whole thing the file name is going to be whatever we want so let’s say [Music] settings nothing i don’t care this section is going to be the east section let’s make it like that and the key is going to be main Hotkey right i don’t care it doesn’t matter because in the end that’s the only thing that i’m saying but now the information is saved return again as i mentioned as you want to kind of like have it
so that when you start the program it goes ahead and reads it then now yAuto program when you start after adding the menu for example now you need and we read right the output variable is going to be the current rp just for consistency so wherever i refer to the current copy i know what i’m talking about the file name is going to be settings but i know the section is going to be Hotkeys and the default value if there is noHotkey is going to be control g right that’s it we just we just created
a program that not only does whatever you said now we save the information into a file so let’s go ahead now let’s go and test itthis is the part where i just go ahead and break my script right away so that i know what is going on now after this this is the reason why i right away test because i forgot to do something if i read the Hotkey what do i do with it well i said it i’d go ahead and set it right have to go ahead and set the view if you read it so let’s go ahead and Hotkeys set that that happens very often you
know like you forget about yeah when you’re doing stuff very very right but you forget about the verybasic stuff that’s the reason why even though you think you did a correct job you just go ahead and do it again just in case right so let’s go ahead and take a look at it we’ve run those scripts and as you can see my script broke here that’s exactly what i want now when i’m testing what i do is predictions i predict what is going to happen if my prediction is wrong something in my code is wrong so
my prediction here is my file doesn’t exist right so i should get the control g Hotkey so right now current Hotkey is empty when i press on this current Hotkey should have control g cool everything is good i set the Hotkey to use test paste naked and now if i go here right so if i go [Music] i remove the option to feed the the the variables here but in any casethe Hotkeys whatever is set up at the moment i just wanted to take a list of whatever is set up let me show you what i mean right now so at least bars
that’s the thing that i was using so what i want to do is if i go ahead and do that it should be ctrl g if i do a list vars what is going to happen is thatlet me just finish it and now i have access to view what part keys have been set up and i see that the control v is set up and i assume that whenever i press ctrl g i should fall into thisuh label here so let me make a breakpoint here let me copy something to the to the clipboard i’ll copy it and now if i press ctrl g i did get everything but my program
didn’t break let’s go ahead and do this one come on my program didn’t break let’s go ahead and make this break let’s go ahead and do that i want to break right about here so whenever i hold ctrl g oh there it is now it broke so now i know that if i press ctrl g it is going to my label so that tells me that it is performing the actions that it should perform anyways right so if i just go ahead and remove the breaks and hit ok it should paste and i know that if i pay if i copy from excel or something what i’m going to get
when i press the ctrl d so that is working fine i know that that is working fine now let’s go ahead and take a look at Auto preferences windows so i have my preferences window i have to fix this a little bit later onlet’s make it easy a windows that tests both things at the same time i just want to know if the window gets taken so myHotkey should be windows 8.
when i hit save i want to go ahead and take a look at what happens here so whenever you modify code the things even your list virus would have shown you right wouldn’t you no because i am not i will never go back to this part of the program again this card no no no no you would never because as you are in a gui that gui is always calling this function that’s the only part of the program that you will be able to access you will never go back right but i thought you had to reload it oh yeah yeah no no no you don’t have to
reload it that’s the beauty of Hotkey is not being on set and you should so right you see that’s the reason why you test because i was not thinking about that i just test the new Hotkey yeah right at some point you’re gonna have like many Hotkeys right and everything does right so so that’s the reason why i test
now i have my strip running again now let’s go to the preferences now i have my windows a i save and now you can see that i’m breaking inside the save so now my current key should be a windows key should be one so i set the windows Hotkey i set the current Hotkey and that should now make windows a my new Hotkey and now this is the part that i wanted to test what happens when i go ahead and write so now that i enrolled that i should get kind of like a new file and where is that that is in the desktop so
let’s go ahead andgo to the desktop and yeah there it is so i have an ini file and that midi file that has a thing it has remaining right so everything is saved now my next test is when i go ahead rerun the script now i want to make sure that it is being read right so we rerun the script and if i go to my Hotkeys it should be windows 8.
so it is doing everything correctly now it is reading instead of having control g now he’s having the one that is on the seat in the telling spot so everything is working fine right now cool now one thing that we need to do is just disable the old Hotkey hasthe old value right but when i do a guitar here i lose that old value and we can test that but let’s i by experience i know that that’s what
what is going on so i’m going to have whole or well i can so that’s it and that i want to do it before i do the gui submit so because degree submit actually overwrites that variable that’s the reason why you don’t not it’s veryannoying to use global variables because one thread can modify the same right so that’s the reason why you don’t like working with global things this command modifies that global variable so basically the best way for you to do it is this current hockey should be something a little bit
differently named probably old hockey or something like that just for you to not have this problem but anywayslet’s go ahead and break herethis do this part here in which if i hit save that’s when a i don’t know why that was different than thatbut now my current key should have windows 8 right windows athat’s the old Hotkey i disable that one and now when i do we submit now current Hotkeys could have something else in this case i just selected windows a again so that doesn’t make any sense
let’s go ahead and redo itpaste preferences and there’s a little box here which is that i’m not setting up this to what it currently has start reading it yeah right yeah so i will fix that as well i have windows a is the old one and the new one is control g with the windows key as well so that’s what it is windows control g so this is working fine i know that that is working fine now let’s fix the other part that is recreate yeah so this part here should be also kind of likevariable that has the
current key again as i am using a global variable i know that at the beginning of my script i save this term Hotkey that’s what happens so let’s go ahead and pick that up let’s let’s do one other tweak that’ll i
think it’s a smart one and it’ll also just make your troubleshooting easier let’s let’s make thethe default action if you click the icon that’ll pull up the preferences all right yes of course yeah we’re gonna do that so that’s by making the try onthe defaults so we’re gonna create one of them to be the default and as soon as we do that it would beso what i’m gonna do to fix this issue is that i’m going to regular expression replace the reason why i’m going to do that is
because i want to do two things at the same time the haystack is going to be my current Hotkey if you set it once is
always gonna have the same value so i want to make sure that it has the value false sometimes i’m gonna do that sometimes i’m gonna say true even though it isn’t so this should fix the issuei would check this with check or check that usually happens right so if you go ahead and have yeah check three or check if you use a number so zero one or two oh no here it is check so that’s the thing you say check is one thing if you say check is another so that’s the thing i know that you could do it but
they mean different things right so nowlet’s run it again we are missing a parenthesis here where we’re and now if i go preferences i do get the window but i’m not getting the variable here so let’s go ahead and break here and see what’s going on because this current Hotkey has window 8 oh because after i do the replacement i have to save it so after you do the replacement just go ahead and save it so that it doesn’t have it so that this doesn’t break so we are doing that let’s go ahead and preferences now we
have the window a which is the Hotkey that i had before so let’s go ahead and click ctrl g as we had at the beginning save it what is going on yeah as i am replacing the current Hotkey that’s the reason why you don’t use global variables because now this is gonna actually use whatever you had so let’s make this the old heartbeat all part of me is the one that i’m gonna put here and it’s the one that i’m going to save here that should fix the issue oh hold on let’s shoot fix it that’s the old part
that’s my current and the old Hotkey let’s grab it completely so i want to grab whatever it was that i have completely before i do any changes now right now the one that i want to put in the control is the current Hotkey which is going to remove the windows which is the one that is issues but when i go ahead and turn off the Hotkey it should be the old one the whole thing that it was before right right right so now if i go ahead and do it again i have windows a let’s go ahead and put control g here not with that
that should turn off the old one and create the new one so now if i hit list bars i should see the Hotkeys this one that is off and the new Hotkey that is ctrl g right and if i restart the program and i go to the preferences i should get the control g but i don’t know why i’m getting the windows there that shouldn’t happen because i didn’t have windows at that point so for some reason this one decided to be true even though it isn’t now if i re run the program and i go to preferences my current Hotkey says control g right
no that shouldn’t be true at any moment but for some reason it’s getting in there that is true right so you see that oh hold on you know what happens i think hold on maybe oh if it’s true it just it if it does a replacement right but i i understand that this it didn’t do any replacements right because at the at the moment it is going to stay exactly the same as it was before because there was no replacement but i think the regular expression replacedreturns the return of that of that thingreturn
[Music] a v1 put this outside of the state each statement and here let’s go ahead and make it blank and now count if there was a replacement then do that i think string replace would work good in this situation right
because string replacebut yeah and we’re doing something so simple that it’s not overly complex where you don’t necessarily need the rejects but anyway right but the problem with the problem is that i’m doing two things with this regular expression that that’s the issue i have done two things so i’m counting how many times i replaced it to see if it was replaced and i also grabbed the new string with string replace i can only do one of them that’s what happens so in any case i just go ahead and just
go into this preferences now it should be zero right so now it should be false right and now i should i should get my correct thing so everything is working as attendant let’s go ahead and add the thing that you were talking about which is that we have press f preferences should be default and if i remember correctly[Music]let me go ahead and double check on that one because i haven’t done a long timemany default i think it is not trade it’s difficult like this so let’s go ahead and double check on that
so we havedefault that’s exactly it so oh the menu name goes first that’s the problem with those commands that it is exactly as they thought but it’s the other way aroundso yeah it’s many preferences is that while we’re in there looking yeah i’m sorry it is strong no no no that’s not wrong it is menu tray default preferences that’s how it goes so the first one refers to the menu that you’re talking about what you’re going to do with it and what’s the thing you’re talking about so
that’s it it is sometimes a little bit confusing but yeah that’s what it is nowif i go flickr nowsee i get mine so let me go ahead and close it and if i double click on this i get the window but i want to make it that it is just one click isn’t it with one click or double click either way yeah i think you’re right like one click would be why not right so so basically with a default let me see there was a way that you could pass uponthere is one i forgot about how you can make it so that it is
one click but in any case yeah you can do that you can actually go ahead and make it so that only with one clickyeah we’ll figure it out yeah no the other one i put it in telegram i put a a tray icon using the imageres.dll which should be on almost everyone’s computer i think it’s like a clipboard icon which will be a little more useful and what what i was thinking was because i think like me most people will love this script and never not want it running why don’t we add the preferences to say
display icon or not okay this is the one that i should use in this case i’m sorry right so you you’re talking about what i’m sorry well i’m just saying this for me this script is something i always want running and i wouldn’t necessarily want a separate system tray icon for it so we should let people choose if they can add something their preferences says do you want to you know have it to save the trade icon right so yeahso the menu which of cAutose means we need aHotkey to kill it also um
yeah but that’s how now you see how strips kind of like start getting bigger and bigger yeah but it’s not that somebody goes ahead and write the whole thing you just go ahead and start adding you think it’s little by little let’s not worry about the yeah let’s not worry about the no no tray icon because they want to get to preferences so let’s let’s i think in reality it’s it’s fine it’s okay for now right so but later on if we need to do more stuff like we would go ahead and start adding now
we did havethis other object that adds the about and right date we just have to include that we’re not going to do that right now but all those things all those functions that are down here depend on that otherum script object but for now this grip is already done you just have something there is the icon down here that now has a clipboard thingso that you could go ahead and use the reload you could just fix this to look a little bit more prettier or whatever but i think that’s okay for now that’s a very good starting
point right yeah awesome so you’re welcome we’re going to be talking each other later cheers

Comments are closed.