Docfxit Posted April 16, 2023 Posted April 16, 2023 I have a script to move text over 4 spaces. I would like it to work no matter what the title is. The title changes depending on what you are doing. The only thing that is the same in all of the pages is "Mozilla Firefox". Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("Edit - Stack Overflow — Mozilla Firefox","") If Not WinActive("Edit - Stack Overflow — Mozilla Firefox","") Then WinActivate("Edit - Stack Overflow — Mozilla Firefox","") WinWaitActive("Edit - Stack Overflow — Mozilla Firefox","") Send("{SPACE}{SPACE}{SPACE}{SPACE}{HOME}{DOWN}{SPACE}{SPACE}{SPACE}{SPACE}{HOME}{DOWN}{SPACE}{SPACE}{SPACE}{SPACE}{HOME}{DOWN}")
ioa747 Posted April 16, 2023 Posted April 16, 2023 (edited) you can make a hotkey for Firefox when this page is active e.g when you press shift + alt + space to send 4 * space (or whatever else you want) Edited April 16, 2023 by ioa747 I know that I know nothing
Docfxit Posted April 16, 2023 Author Posted April 16, 2023 (edited) Do you have a link that shows how to make a hotkey? Or an explanation on how to do it? I can't find it. Maybe you have an addon like Shortkeys? Edited April 16, 2023 by Docfxit
ioa747 Posted April 16, 2023 Posted April 16, 2023 HotKeySet ( "key" [, "function"] ) https://www.autoitscript.com/autoit3/docs/functions/HotKeySet.htm or in scite write hotkeyset and press f1 (first save) I know that I know nothing
ioa747 Posted April 16, 2023 Posted April 16, 2023 (edited) simple example While 1 If WinActive("Stack Overflow") Then HotKeySet("+!{SPACE}", "SpecialSpace") ; Shift-Alt-SPACE Else HotKeySet("+!{SPACE}") ; unregister EndIf Sleep(100) WEnd Func SpecialSpace() Send("{SPACE 4}") EndFunc ;==>SpecialSpace edit: if the page does not have a fixed title, replace theIf WinActive("Stack Overflow") Then with If WinActive("CLASS:MozillaWindowClass") Then Edited April 16, 2023 by ioa747 I know that I know nothing
Docfxit Posted April 16, 2023 Author Posted April 16, 2023 I have tried many different iterations of your code. I can't get it to work in Firefox. Have you actually tried it in Firefox? This is my latest test: Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) HotKeySet('{ESC}', '_Terminate') While 1 If WinActive("CLASS:MozillaWindowClass") Then HotKeySet("!M", "SpecialSpace") ; Alt+Shift+m Else HotKeySet("!M") ; unregister EndIf Sleep(100) WEnd Func SpecialSpace() Send("{SPACE 4}") EndFunc ;==>SpecialSpace Func _Terminate() Exit EndFunc ;==>Terminate
ioa747 Posted April 16, 2023 Posted April 16, 2023 (edited) yes on this site https://www.autoitscript.com/forum/topic/210095-stack-overflow-move-4-spaces/#comment-1516843 so the active window starts with Stack Overflow This is the title of your post edit: not working with "CLASS:MozillaWindowClass" Edited April 16, 2023 by ioa747 I know that I know nothing
Solution Docfxit Posted April 16, 2023 Author Solution Posted April 16, 2023 (edited) I was able to get it to work with this code: Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) HotKeySet('{ESC}', '_Terminate') While 1 If WinActive('[CLASS:MozillaWindowClass]') Then HotKeySet("!M", "SpecialSpace") ; Alt+Shift+m Else HotKeySet("!M") ; unregister EndIf Sleep(100) WEnd Func SpecialSpace() Send("{SPACE 4}{HOME}{DOWN}") EndFunc ;==>SpecialSpace Func _Terminate() Exit EndFunc ;==>Terminate Thank you, Edited April 16, 2023 by Docfxit
ioa747 Posted April 16, 2023 Posted April 16, 2023 (edited) try this Opt("WinTitleMatchMode",2) While 1 If WinActive("— Mozilla Firefox") Then HotKeySet("+{SPACE}", "SpecialSpace") ; Shift-SPACE Else HotKeySet("+{SPACE}") ; unregister EndIf Sleep(100) WEnd Func SpecialSpace() Send("{SPACE 4}") Sleep(100) Send("{HOME}") Sleep(100) Send("{DOWN}") Sleep(100) Send("{ENTER}") Sleep(100) Send("is working!!") EndFunc ;==>SpecialSpace shift+space Edited April 16, 2023 by ioa747 I know that I know nothing
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