SevenScript Posted January 23, 2023 Share Posted January 23, 2023 Hey, doing small stuff in AutoIt just for training and feeling nice with it. Have already script builded for my needes, but asking you guys for help with Turn ON/OFF Func. #include <misc.au3> HotKeySet("1", "start") HotKeySet("2", "stop") Func start(); MouseDown("middle") EndFunc Func stop(); MouseUp("middle") EndFunc Looking for solution to switch Mouse down/up with 1 key Link to comment Share on other sites More sharing options...
SOLVE-SMART Posted January 23, 2023 Share Posted January 23, 2023 Hi @SevenScript, I guess you are looking for a toggle function. Please search the forum for toggle and you will get examples that are similar to your question. I don't have enough time at the moment to script a quick script as an example, because I am in rush. Maybe later today. Best regards Sven SevenScript 1 Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to comment Share on other sites More sharing options...
ioa747 Posted January 23, 2023 Share Posted January 23, 2023 maybe help SevenScript 1 I know that I know nothing Link to comment Share on other sites More sharing options...
ioa747 Posted January 23, 2023 Share Posted January 23, 2023 (edited) and when tray no needed this just with HotKey #include <misc.au3> Local $Enabled, $SleepTime Enabled() While 1 Sleep($SleepTime) WEnd Func start(); ;MouseDown("middle") MouseWheel("down") EndFunc Func stop(); ;MouseUp("middle") MouseWheel("up") EndFunc Func Enabled() if $Enabled = True Then $Enabled = False $SleepTime = 1000 HotKeySet("1") HotKeySet("2") Else $Enabled = True $SleepTime = 10 HotKeySet("{ESC}", "Enabled") HotKeySet("1", "start") HotKeySet("2", "stop") EndIf ConsoleWrite("$Enabled=" & $Enabled & @CRLF) EndFunc Edited January 23, 2023 by ioa747 SevenScript 1 I know that I know nothing Link to comment Share on other sites More sharing options...
Solution SOLVE-SMART Posted January 23, 2023 Solution Share Posted January 23, 2023 (edited) To be honest @ioa747, I was actually thinking about such toggle function: HotKeySet('{ESC}', '_Exit') HotKeySet('1', '_ToggleMouse') Global $bIsDown = False Func _Exit() Exit EndFunc Func _ToggleMouse() $bIsDown = Not $bIsDown If $bIsDown Then MouseDown('middle') Return EndIf MouseUp('middle') EndFunc While True Sleep(200) WEnd Simply press "1" to do the mouse down ("middle" key) action and press "1" again for the mouse up action (and again and again 😅). I think this is exactly what @SevenScript wanted to know, am I right? Best regards Sven Edited January 23, 2023 by SOLVE-SMART ioa747 1 Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to comment Share on other sites More sharing options...
SevenScript Posted January 23, 2023 Author Share Posted January 23, 2023 Yes @SOLVE-SMART, That's exactly what i was missing, Thank you so much, @ioa747 Your post are also helpfull.. Gives materials to study :D, Thanks guys ioa747 1 Link to comment Share on other sites More sharing options...
ioa747 Posted January 24, 2023 Share Posted January 24, 2023 @SOLVE-SMART You have right ! my eye stayed to On 1/23/2023 at 6:10 AM, SevenScript said: but asking you guys for help with Turn ON/OFF Func than in On 1/23/2023 at 6:10 AM, SevenScript said: Looking for solution to switch Mouse down/up with 1 key Thanks for suggestions. I know that I know nothing Link to comment Share on other sites More sharing options...
SOLVE-SMART Posted January 24, 2023 Share Posted January 24, 2023 You're welcome @ioa747 🤝 . Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to comment Share on other sites More sharing options...
SevenScript Posted February 6, 2023 Author Share Posted February 6, 2023 On 1/23/2023 at 9:55 AM, ioa747 said: and when tray no needed this just with HotKey #include <misc.au3> Local $Enabled, $SleepTime Enabled() While 1 Sleep($SleepTime) WEnd Func start(); ;MouseDown("middle") MouseWheel("down") EndFunc Func stop(); ;MouseUp("middle") MouseWheel("up") EndFunc Func Enabled() if $Enabled = True Then $Enabled = False $SleepTime = 1000 HotKeySet("1") HotKeySet("2") Else $Enabled = True $SleepTime = 10 HotKeySet("{ESC}", "Enabled") HotKeySet("1", "start") HotKeySet("2", "stop") EndIf ConsoleWrite("$Enabled=" & $Enabled & @CRLF) EndFunc Hello @ioa747 I wonder how could i use your "Enabled" option with IsPressed function expandcollapse popup#include <misc.au3> Local $Enabled, $SleepTime Enabled() While 1 Sleep($SleepTime) WEnd Func start(); While 1 Sleep(10) If _IsPressed("90") Then sleep(50) Send("Its") sleep(200) Send("a simply") sleep(200) Send("text") sleep(150) EndIf WEnd EndFunc Func Enabled() if $Enabled = True Then $Enabled = False $SleepTime = 1000 HotKeySet("1") Else $Enabled = True $SleepTime = 10 HotKeySet("{ESC}", "Enabled") HotKeySet("1", "start") EndIf EndFunc After running that script IsPressed is no active untill i press "1" But it doesn't deactivate after use "1" or "ESC" Could you please explain me how it works? Link to comment Share on other sites More sharing options...
ioa747 Posted February 6, 2023 Share Posted February 6, 2023 While 1 Sleep(10) If $Enabled = True Then If _IsPressed("90") Then ; 90 NUM LOCK key Sleep(50) Send("Its") Sleep(200) Send("a simply") Sleep(200) Send("text") Sleep(150) EndIf EndIf WEnd SevenScript 1 I know that I know nothing Link to comment Share on other sites More sharing options...
ioa747 Posted February 6, 2023 Share Posted February 6, 2023 with a second review, as long as it is in the HotKeySet function Func start() ; While $Enabled Sleep(10) If _IsPressed("90") Then ; 90 NUM LOCK key Sleep(50) Send("Its") Sleep(200) Send("a simply") Sleep(200) Send("text") Sleep(150) EndIf WEnd EndFunc ;==>start SevenScript 1 I know that I know nothing Link to comment Share on other sites More sharing options...
ioa747 Posted February 6, 2023 Share Posted February 6, 2023 and this make pause status more visible Func Enabled() If $Enabled = True Then TraySetIcon(StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", $STR_NOCASESENSEBASIC, -1) - 1) & "\Icons\MyAutoIt3_Red.ico") $Enabled = False $SleepTime = 1000 HotKeySet("1") Else TraySetIcon(StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", $STR_NOCASESENSEBASIC, -1) - 1) & "\Icons\MyAutoIt3_Blue.ico") $Enabled = True $SleepTime = 10 HotKeySet("{ESC}", "Enabled") HotKeySet("1", "start") EndIf EndFunc ;==>Enabled SevenScript 1 I know that I know nothing Link to comment Share on other sites More sharing options...
SevenScript Posted February 6, 2023 Author Share Posted February 6, 2023 Thank you so much Mr. Gandalf :3 Link to comment Share on other sites More sharing options...
ioa747 Posted February 6, 2023 Share Posted February 6, 2023 (edited) Glad to help Edited February 6, 2023 by ioa747 I know that I know nothing Link to comment Share on other sites More sharing options...
SevenScript Posted February 24, 2023 Author Share Posted February 24, 2023 On 2/6/2023 at 11:11 AM, ioa747 said: While 1 Sleep(10) If $Enabled = True Then If _IsPressed("90") Then ; 90 NUM LOCK key Sleep(50) Send("Its") Sleep(200) Send("a simply") Sleep(200) Send("text") Sleep(150) EndIf EndIf WEnd Hello \o About that option, How could i start script with $Enable = False So it's no active until i press Hotkey ESC Enable Link to comment Share on other sites More sharing options...
ioa747 Posted February 24, 2023 Share Posted February 24, 2023 On 2/6/2023 at 11:57 AM, SevenScript said: But it doesn't deactivate after use "1" or "ESC" That was the point of stopping with Esc, that's what i understood try this version with one switch If it works for you ESC = on/off Func Enabled() If $Enabled = True Then TraySetIcon(StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", $STR_NOCASESENSEBASIC, -1) - 1) & "\Icons\MyAutoIt3_Red.ico") $Enabled = False $SleepTime = 1000 ;~ HotKeySet("1") Else TraySetIcon(StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", $STR_NOCASESENSEBASIC, -1) - 1) & "\Icons\MyAutoIt3_Blue.ico") $Enabled = True $SleepTime = 10 HotKeySet("{ESC}", "Enabled") ;~ HotKeySet("1", "start") start() EndIf EndFunc ;==>Enabled SevenScript 1 I know that I know nothing Link to comment Share on other sites More sharing options...
SevenScript Posted February 24, 2023 Author Share Posted February 24, 2023 (edited) 16 minutes ago, ioa747 said: That was the point of stopping with Esc, that's what i understood try this version with one switch If it works for you ESC = on/off Func Enabled() If $Enabled = True Then TraySetIcon(StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", $STR_NOCASESENSEBASIC, -1) - 1) & "\Icons\MyAutoIt3_Red.ico") $Enabled = False $SleepTime = 1000 ;~ HotKeySet("1") Else TraySetIcon(StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", $STR_NOCASESENSEBASIC, -1) - 1) & "\Icons\MyAutoIt3_Blue.ico") $Enabled = True $SleepTime = 10 HotKeySet("{ESC}", "Enabled") ;~ HotKeySet("1", "start") start() EndIf EndFunc ;==>Enabled Hello, Thank you for answer. Your idea works properly and you gave me code which improved my au3 understanding Local $Enabled, $SleepTime Enabled() Func Enabled() If $Enabled = True Then $Enabled = False $SleepTime = 1000 Else $Enabled = True $SleepTime = 10 HotKeySet("{ESC}", "Enabled") EndIf EndFunc ;==>Enabled While 1 Sleep(10) If $Enabled = True Then If _IsPressed("90") Then ; 90 NUM LOCK key Sleep(50) Send("Its") Sleep(200) Send("a simply") Sleep(200) Send("text") Sleep(150) EndIf EndIf WEnd That option works great but wonder how could i start script with Enable = False, I mean after script start i can press NumLock from beggining and it results "Its a simply text". What have to do to get that option working after first ESC Edited February 24, 2023 by SevenScript Link to comment Share on other sites More sharing options...
ioa747 Posted February 24, 2023 Share Posted February 24, 2023 (edited) try it This is the correct order, the functions go down expandcollapse popup#include <misc.au3> Local $Enabled, $SleepTime Enabled() ;************************************************ While 1 Sleep($SleepTime) WEnd ;************************************************ Exit ;---------------------------------------------------------------------------------------- Func start() ; While $Enabled Sleep(10) If _IsPressed("90") Then ; 90 NUM LOCK key ;~ ConsoleWrite(":") Sleep(50) Send("Its") Sleep(200) Send("a simply") Sleep(200) Send("text") Sleep(150) EndIf WEnd EndFunc ;==>start ;---------------------------------------------------------------------------------------- Func Enabled() If $Enabled = True Then TraySetIcon(StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", $STR_NOCASESENSEBASIC, -1) - 1) & "\Icons\MyAutoIt3_Red.ico") $Enabled = False $SleepTime = 1000 Else TraySetIcon(StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", $STR_NOCASESENSEBASIC, -1) - 1) & "\Icons\MyAutoIt3_Blue.ico") $Enabled = True $SleepTime = 10 HotKeySet("{ESC}", "Enabled") start() EndIf EndFunc ;==>Enabled Edited February 24, 2023 by ioa747 SevenScript 1 I know that I know nothing Link to comment Share on other sites More sharing options...
ioa747 Posted February 24, 2023 Share Posted February 24, 2023 You tried it? what do not you understand? I know that I know nothing Link to comment Share on other sites More sharing options...
SevenScript Posted February 24, 2023 Author Share Posted February 24, 2023 Local $Enabled, $SleepTime Enabled() Func Enabled() If $Enabled = True Then $Enabled = False $SleepTime = 1000 Else $Enabled = True $SleepTime = 10 HotKeySet("{ESC}", "Enabled") EndIf EndFunc ;==>Enabled While 1 Sleep(10) If $Enabled = True Then If _IsPressed("90") Then ; 90 NUM LOCK key Sleep(50) Send("Its") Sleep(200) Send("a simply") Sleep(200) Send("text") Sleep(150) EndIf EndIf WEnd That's my favourite option There is no Start function, just Enabled. And when $Enabled = True then IsPressed is active. -------------------------------------------------------------------------------- So double click on script and press NumLock = It's a simply text. --------------------------------------------------------------------------------- What i try to achive: Double click on script ESC to make $Enable = True and then NumLock = It's a simply qestion 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