plankton Posted July 2, 2019 Posted July 2, 2019 (edited) So I have 2 functions running in this script, one is CTRL which runs continuously without any conditions. Other is ESC function which wait for color pixels to appear on the screen. Here is the problem, whenever ESC function is activated, it doesnt send ESC command to a computer but it sends CTRL+ESC which results in windows 10 shortcut commands Windows 10 - Open Start Menu So I decide to declare variable inside my script which is $noctrl so whenever ESC function sees a pixel on a screen it will set $noctrl to 1 which will deactivate CTRL function automatically. But I dont know why my script isn't working, It seems that everything is correct. Here is my script expandcollapse popupHotKeySet("{END}", "End") HotKeySet("{HOME}", "Start") Global $noctrl = 0 ;<<<<<<<<<<<Set $noctrl to zero While 1 Sleep(100) WEnd Func Start() While 1 CTRL() ESC() WEnd EndFunc ;==>Start Func ESC() If PixelSearch(712, 137, 906, 244, 0xF70000) & $noctrl = 0 Then ;<<<<<<<<<<<If $noctrl is set to zero and pixel is spotted on the screen then execute the function $noctrl = 1 ;<<<<<<<<<<<Set $noctrl to one to deactivate CTRL function Sleep(1000) Send("{LCTRL UP}") ;<<<<<<<<<<<To avoid LCTRL that is still pressed down. Sleep(1000) Send("{ESC DOWN}") Sleep(100) Send("{ESC UP}") Sleep(3000) $noctrl = 0 ;<<<<<<<<<<<Set $noctrl to zero to activate the CTRL function again EndIf EndFunc ;==>ESC Func CTRL() If $noctrl = 0 Then ;<<<<<<<<<<< This function WILL NOT execute when function ESC is running. Because while it's running $noctrl is set to 1. Send("{LCTRL DOWN}") Sleep(Random(10, 100, 1)) Send("{LCTRL UP}") EndIf EndFunc ;==>CTRL Func End() Exit 0 EndFunc ;==>End I dont know which part of this I got wrong because it seems like function ESC is dead and no longer detecting color. Edited July 2, 2019 by Melba23 Added code tags
Moderators Melba23 Posted July 2, 2019 Moderators Posted July 2, 2019 plankton, When you post code in future please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. Thanks in advance for your cooperation. As to your code you do not need the $noctrl flag - AutoIt functions run consecutively and CTRL will not start before ESC ends - so there must be another problem. I suspect that you have a "sticky" CTRL key and this Wiki page might be helpful. 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
plankton Posted July 2, 2019 Author Posted July 2, 2019 20 minutes ago, Melba23 said: plankton, When you post code in future please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. Thanks in advance for your cooperation. As to your code you do not need the $noctrl flag - AutoIt functions run consecutively and CTRL will not start before ESC ends - so there must be another problem. I suspect that you have a "sticky" CTRL key and this Wiki page might be helpful. M23 Hi, Melba23, I think you just nailed it. I didnt think of this "sticky" key before and I have wasted my time re-writing my code for several hours. I think I will change my keyboard layout and avoid using shift, ctrl and alt keys from now on. Thank you.
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