Notification that part of script is running? Topic is solved
Notification that part of script is running?
Hello
I have a fairly long script that runs different work shortcuts. Part of the script I only want to use when in a specific program, so I am using a toggle that way I can turn those shortcuts on and off when I am using that program. SO far it is working great. However, I keep forgetting to toggle the specific shortcuts on and off sometimes. I tried using a tooltip but it only stays when I hit the toggle key and also shows up whether I am toggling the specific section on and off (not just when it's on or off).
Any suggestions?
Here is the part of the script I am referring to:
I have a fairly long script that runs different work shortcuts. Part of the script I only want to use when in a specific program, so I am using a toggle that way I can turn those shortcuts on and off when I am using that program. SO far it is working great. However, I keep forgetting to toggle the specific shortcuts on and off sometimes. I tried using a tooltip but it only stays when I hit the toggle key and also shows up whether I am toggling the specific section on and off (not just when it's on or off).
Any suggestions?
Here is the part of the script I am referring to:
Re: Notification that part of script is running?
Sorry, here is the code:
[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]
Code: Select all
ScrollLock::
mode := !mode ; Set mode either to 1 or 0 - toggle
ToolTip, "Relativity Toggle"
setTimer, tooltipoff, 2000 ; run tooltipoff after 2 second
return
tooltipoff:
ToolTip ; remove tooltip
return
;Use , (or <) to copy last entry
#if mode = 1
,::send ^+Z
Return
;Use / (or ?) to Open Native Mode
#if mode = 1
/::SendInput !v
Return
;Use ' to Open Image Mode
#if mode = 1
'::SendInput !i
Return
;Use . (or >) to save and move to next document
#if mode = 1
.::SendInput !{enter}
Return
[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]
Re: Notification that part of script is running?
Welcome to this AutoHotkey forum!
AutoHotkey can do the "toggling" for you. https://www.autohotkey.com/docs/commands/_IfWinActive.htm
AutoHotkey can do the "toggling" for you. https://www.autohotkey.com/docs/commands/_IfWinActive.htm
Re: Notification that part of script is running?
If you use the #IfWinActive directive to make your shortcuts/hotkeys automatically active only when a certain application's window is active, you don't have to bother with toggling anything on or off, and you don't have to remember or display the state it's in.
Edit: What mikeyww said.
Edit: What mikeyww said.
Re: Notification that part of script is running?
Right, but the problem is that this is a specific tab (and specific website) in Chrome. So I don't think AHK can tell when it's that tab open... Also I would need to toggle it if I need to type normally in that tab, which happens often.
Re: Notification that part of script is running?
Thanks, but this is for a specific website that I have to use often. I need other parts of chrome and when I switch back and forth between other tabs to have a normal keyboard. I don't mind toggling, I just often forget to press the toggle hotkey (ScrlLck) and it causes issues in other programs/tabs. That's why I just need the code above to include some sort of trigger that when I activate the toggle with ScrlLck it also makes either a message box or tool tip, or something else that will let me know the mode is on, and the shortcuts are activated. Thanks!!!boiler wrote: ↑28 Nov 2022, 19:16If you use the #IfWinActive directive to make your shortcuts/hotkeys automatically active only when a certain application's window is active, you don't have to bother with toggling anything on or off, and you don't have to remember or display the state it's in.
Edit: What mikeyww said.
Re: Notification that part of script is running?
Yes it can. Use the Window Spy tool that comes with AHK to see what the title is when a particular website is the active tab in Chrome.
You could have a combination of a toggle and a certain website being active using #If and multiple conditions including WinActive().
Re: Notification that part of script is running?
But the tab's URL changes all the time. Not sure how a windows spy would determine what that tab is for the given URL... The script already works perfectly for my needs, it's just not working as far as letting me know when the code is active or not. Is there really no other way to create an indicator?boiler wrote: ↑29 Nov 2022, 10:07Yes it can. Use the Window Spy tool that comes with AHK to see what the title is when a particular website is the active tab in Chrome.
You could have a combination of a toggle and a certain website being active using #If and multiple conditions including WinActive().
Re: Notification that part of script is running?
I already have the toolip show up whenever the hotkey is pressed maybe there's a way to just keep the tooltip persistenly on whille the toggle is pressed and turn off the tooltip when I toggle off this part of the code?
Re: Notification that part of script is running?
If your only issue is that the ToolTip you already have stays on temporarily, then just remove the part where you set a SetTimer to turn it off.
In general, there are countless ways to display an indicator of the toggle status. What do you want it to do and look like? Where do you want it to be located on the screen? Will a ToolTip that doesn't disappear meet your needs?
In general, there are countless ways to display an indicator of the toggle status. What do you want it to do and look like? Where do you want it to be located on the screen? Will a ToolTip that doesn't disappear meet your needs?
Re: Notification that part of script is running?
If I can have the tooltip stay on as long as the toggle is activated (I think the setting is mode=1 to activate the specific part of the script) that would be PERFECT!boiler wrote: ↑29 Nov 2022, 11:13If your only issue is that the ToolTip you already have stays on temporarily, then just remove the part where you set a SetTimer to turn it off.
In general, there are countless ways to display an indicator of the toggle status. What do you want it to do and look like? Where do you want it to be located on the screen? Will a ToolTip that doesn't disappear meet your needs?
Re: Notification that part of script is running?
Try this:
The ToolTip will appear in the upper-left corner of the screen. Some extraneous things removed as well: = 1 in the condition expression, Return after a single-line hotkey, redundant #If directives.
Code: Select all
CoordMode, ToolTip, Screen
ScrollLock::ToolTip, % (mode := !mode) ? "Hotkeys active" : "", 0, 0
#If mode
,::send ^+Z ;Use , (or <) to copy last entry
/::SendInput !v ;Use / (or ?) to Open Native Mode
'::SendInput !i ; ;Use ' to Open Image Mode
.::SendInput !{enter} ;Use . (or >) to save and move to next document
The ToolTip will appear in the upper-left corner of the screen. Some extraneous things removed as well: = 1 in the condition expression, Return after a single-line hotkey, redundant #If directives.
Re: Notification that part of script is running?
Thank you! Where would I put this in relation to the code I posted above? And will this affect anything else in my whole script?boiler wrote: ↑29 Nov 2022, 13:06Try this:Code: Select all
CoordMode, ToolTip, Screen ScrollLock::ToolTip, % (mode := !mode) ? "Hotkeys active" : "", 0, 0 #If mode ,::send ^+Z ;Use , (or <) to copy last entry /::SendInput !v ;Use / (or ?) to Open Native Mode '::SendInput !i ; ;Use ' to Open Image Mode .::SendInput !{enter} ;Use . (or >) to save and move to next document
The ToolTip will appear in the upper-left corner of the screen. Some extraneous things removed as well: = 1 in the condition expression, Return after a single-line hotkey, redundant #If directives.
Re: Notification that part of script is running?
In place of all of it. Delete what you posted. Paste this in its place.
If your script worked with it before, it would affect nothing. This is a direct functional replacement. Just put the first line at the top of your script to make sure it's in the auto-execute section. The rest can go where you had it.
Re: Notification that part of script is running?
I put it at the bottom of the script where it was originally, it's working BEAUTIFULLY! Thank you very much. I don't know how I can repay you for your time and help!!boiler wrote: ↑29 Nov 2022, 13:23In place of all of it. Delete what you posted. Paste this in its place.
If your script worked with it before, it would affect nothing. This is a direct functional replacement. Just put the first line at the top of your script to make sure it's in the auto-execute section. The rest can go where you had it.
Re: Notification that part of script is running?
You're welcome. The best thing you can do is study the things we showed you and try to learn the concepts.
Re: Notification that part of script is running?
Sorry one follow up question that I cannot seem to figure out,
In this part of my script:
Code: Select all
CoordMode, ToolTip, Screen
ScrollLock::ToolTip, % (mode := !mode) ? "Mode Active!" : "", 0, 0
#If mode
,::send ^+z ;Use , (or <) to copy last entry
/::SendInput !v ;Use / (or ?) to Open Mode
'::SendInput !i ; ;Use ' to Open Mode
.::SendInput !{enter} ;Use . (or >) to save and move to next
;*::SendInput {^+Z} {!{enter}} ;Use 0 to copy last and then move to next .
Thank you!
[Mod edit: Added [code][/code] tags. Please use them yourself when posting code ]
Re: Notification that part of script is running?
Why not just make a hotkey out of 0 that sends what you want it to?
Also, please put [code][/code] tags around the code in your posts.
Code: Select all
0::Send ^+z!{Enter}
Also, please put [code][/code] tags around the code in your posts.
Re: Notification that part of script is running?
Thank you but that doesnt work. I need there to be a delay between the two hotkeys (at least one second) otherwise the program doesnt pick up the fact that I'm entering two separate hotkeys.