Jump to content

bobbyab9987

Active Members
  • Posts

    20
  • Joined

Everything posted by bobbyab9987

  1. Hi guys, thank you very much for your suggestions. Melba23's solution is good and is similar to my initial idea when I first thought about this problem, but I think it might affect performance when the array grows. I don't understand faustf's and MrCreatoR's solutions. I think the solution offered by Bilgus is very good since it's succinct and it's like an O(1) algorithm (i.e. no matter how many more hotkeysets I add, this solution's execution time does not escalate). Based on this solution, I have written another one (same idea as Bilgus, but easier to understand). #include <GUIConstantsEx.au3> #include <Misc.au3> #include <MsgBoxConstants.au3> #include <AutoItConstants.au3> ; ^ = Ctrl ; ! = Alt ; + = Shift Global $task1hk = "1" HotKeySet($task1hk, "doTask1") Global $task2hk = "2" HotKeySet($task2hk, "doTask2") Global $isBusyFlag = False While 1 Sleep(100) WEnd Func doTask1() If ($isBusyFlag = True) Then sendStrayHotkey($task1hk, "doTask1") Return EndIf $isBusyFlag = True ; Unset the HotKey HotKeySet($task1hk) ; prevent hotkey recursion _SendEx("Task 1 is executing..." & @CRLF) _SendEx($task2hk) ; And now reset the HotKey HotKeySet($task1hk, "doTask1") $isBusyFlag = False EndFunc Func doTask2() If ($isBusyFlag = True) Then sendStrayHotkey($task2hk, "doTask2") Return EndIf $isBusyFlag = True ; Unset the HotKey HotKeySet($task2hk) ; prevent hotkey recursion _SendEx("Task 2 is executing..." & @CRLF) ; And now reset the HotKey HotKeySet($task2hk, "doTask2") $isBusyFlag = False EndFunc Func sendStrayHotkey($hk, $task) HotKeySet($hk) _SendEx($hk) HotKeySet($hk, $task) EndFunc Func _SendEx($ss, $warn = "") Local $iT = TimerInit() While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12") If $warn <> "" And TimerDiff($iT) > 1000 Then MsgBox(262144, "Warning", $warn) EndIf Sleep(50) WEnd Send($ss) EndFunc;==>_SendEx I ran the test script above and it worked as expected: Command _SendEx($task2hk), which is issued inside doTask1()'s body, does not activate doTask2(), it just sends out the hotkey of doTask2() (which is what I actually want).
  2. After a long time using AutoIt to automate tasks on my PC, my work performance has increased noticeably. However, now that my script has grown quite big, I have a new problem: Each time I add a new hotkeyset, I have to search the whole script for possible conflicting hotkeys and temporarily disable those hotkeys. Let's look at the example below: Say I have function do_task_1() like this: Func do_task_1() ; Unset the HotKey to prevent hotkey recursion HotKeySet($task_1_hotkey) ; do task 1 here (call a bunch of send() functions) ; And now reset the HotKey HotKeySet($task_1_hotkey, "do_task_1") EndFunc Now if I add another function, let's say do_task_2(), like this: Func do_task_2() ; Unset the HotKey HotKeySet($task_2_hotkey) ; prevent hotkey recursion ; do task 2 here ; And now reset the HotKey HotKeySet($task_2_hotkey, "do_task_2") EndFunc And if, for some random reasons, $task_2_hotkey is used inside do_task_1()'s body, then inside do_task_1() body, I have to temporarily disable do_task_2() like this: Func do_task_1() ; Unset the HotKeys to prevent hotkey recursion HotKeySet($task_1_hotkey) HotKeySet($task_2_hotkey) ; do task 1 here (call a bunch of send() functions) ; one of them is: send($task_2_hotkey) ; And now reset the HotKeys HotKeySet($task_1_hotkey, "do_task_1") HotKeySet($task_2_hotkey, "do_task_2") EndFunc Over time, the more HotKeySets I add, the more frequent I have to check and temporarily disable conflicting hotkeys like above. In fact I already had hotkeysets inside whose bodies I have to temporarily disable 3-4 other hotkeysets. This is both inelegant and time consuming. So I think it would be very nice if there is some way to disable / enable all other hotkeys in just one command like this: Func do_task_1() disableAllHotkeys() ; do task 1 here enableAllHotkeys() EndFunc Does such a built-in method exist in AutoIt? If not, then is there any concise method to tackle this problem (other than manually checking and disabling like I did above)? Thank you.
  3. @Nine: Thank you very much, I am testing your solution, it's working great! It can perform both clicking and dragging flawlessly in various applications. @MrCreatoR: Thank you for your solution. I will try yours if Nine's solution fails (it is working great but in some edge cases something might be broken I don't know...). As for your question, well, my ultimate goal is to replace the 2 mouse buttons totally, and hence the solution must be able to replace not only mouse clicking but also mouse dragging.
  4. Hi guys, I would like to replace totally the 2 mouse buttons with 2 arbitrary keys on keyboard. By "totally" I mean not just replace "mouse click" but also replace "mouse down" as well. So far I succeeded in replacing "mouse click" like this: HotKeySet("`", "_left_mouse_click") Func _left_mouse_click() ; Unset the HotKey HotKeySet("`") ; prevent hotkey recursion MouseClick($MOUSE_CLICK_LEFT) ; And now reset the HotKey HotKeySet("`", "_left_mouse_click") EndFunc However I couldn't do the same with "mouse down", I tried the following but it didn't work: HotKeySet("{` down}", "_left_mouse_down") Func _left_mouse_down() ; Unset the HotKey HotKeySet("{` down}") ; prevent hotkey recursion MouseDown($MOUSE_CLICK_LEFT) ; And now reset the HotKey HotKeySet("{` down}", "_left_mouse_down") EndFunc In the function _left_mouse_down() above, I also tried removing the unset / reset statements, but it didn't work neither. Is it even possible to replace "mouse down" with an arbitrary "key down" using AutoIt? Thank you.
  5. Hi all. I have spent a whole night to debug and the problem is not related to AutoIt. It came from the fact that I forgot to set a hotkey in the target app (the app which I paste the html content into). So if you are still interested, here is the details: When I upgraded my system to Windows 10, I have to reinstall the above mentioned target app. There is a keyboard hotkey of the app that masks the hotkey I use in the AutoIt script, therefore in order for the autoit script to work, this hotkey must be reassigned. Obviously I had done this reassignment before, but just one time, and then I have not touched it again for years, that’s why I totally forgot about it. Even at times I upgraded this app to newer versions, because the app still reused this setting from the old versions, my autoit script still worked. It is when I installed a new version of Windows yesterday, this problem appeared again... and the rest of the story is like what I have described in this thread. Thank you for your helps anyway. I love AutoIt and its active community!
  6. Thank you for your help. But I don't see any difference between the two lines, and when I copy-paste the second line into _ClipPutHTML.au3 and rebuild my script, I got an error because in the line you provided, there is a space between $ and sHTMLData, and another space between $ and sPlainText.
  7. Thank you for your answer, but I don't understand your solution.
  8. Hi everyone, _ClipPutHyperlink() is a function which allows it's user to convert a http link from a plain string (for example: https://www.autoitscript.com) into the html format and then put it to the clipboard so that the user can paste the link to some other programs like Microsoft Word... I have been using this function in my autoit scripts for a few years and it works fine in Windows 7. Recently I have upgraded my system to Windows 10, and this function does not work anymore. I have checked the author's website (link) but he hasn't updated the script since 2010. Please help me to make this function work in Windows 10, or find another way to achieve the same functionality. Thank you very much.
  9. Hi Kylomas, pls see MilesAhead's post to understand my question more clearly. Thank you. Hi MilesAhead, thank you for your answer. This seems to be complicated if we use just AutoIT to accomplish this task. I decided to combine AutoIT and a Windows batch file to achieve the same task, but with a simpler programming skill required.
  10. Hi friends, Suppose MyProgram is a tabbed program, meaning that it allows for opening multiple files in the same instance. I want to open File1, File2 and File3 in one instance of MyProgram from an AutoIT script. How can I do this? I have read the AutoIT Help File about "ShellExecute" and "Run", but I have found nothing helpful. Thanks for reading my question. Any answer would be very appreciated.
  11. Hi Karlkar, thanks for your answer. I already found the solution to my problem at this article.
  12. Hi I3ill, thanks for your answer but from the AutoIt help file we can see that this function does not support the HTML format. Hi karlkar, thanks for your answer but from the AutoIt help file we can see that this function only puts text into the clipboard without any format option.
  13. Hi everyone, I would like to build an AutoIt script allowing me to convert a hyperlink from the plain text format into the HTML format. Right now I have to use a 2-step workaround like this: - Copy the hyperlink to clipboard (I just send Ctrl+C to capture the hyperlink in plain text format) - Call a C# program to get the hyperlink from clipboard, convert it into the HTML format, and put it back to clipboard - Inside the C# program I manually add some HTML segments like <!--StartFragment-->, <html><body><p>, ... - After adding these segments I use function Clipboard.SetData(DataFormats.Html, myHTMLText) to convert myHTMLText from plain text to HTML text and put it back to clipboard. This method works, but it is not beautiful. I would like to do the whole thing in AutoIt. Is there any function in AutoIt which can give the same result as the above C# function Clipboard.SetData()? Thank you.
  14. Hi guys, My job requires me to use several programming IDEs like Visual Studio, Texas Instruments CCS, Keil, IAR,... One problem is that each IDE has its own keyboard shortcut. For example, to debug in Visual Studio, I have to press F5, but to debug in IAR, I have to press 'Ctrl + D'. I think one solution to this problem is to write a program to remap a keyboard combination to a different one, depending on which IDE is currently used. For example, I would like to use F5 for the debug action of all IDEs. Therefore if Visual Studio is currently active, then F5 will not be remapped. But if IAR is active, then F5 will be remapped to 'Ctrl + D'. Can I do this using AutoIt? Thanks.
  15. Unfortunately this does not work. I have tried your method with a hyperlink on a google search-result page but nothing is highlighted. Thank you for your answer anyway
  16. The functionality you described is exactly what I intend to do. However, if we are handling a hyperlink, we cannot send a double click to it, because if we do so, we would be navigated to the address pointed to by the hyperlink, and the text would not be highlighted in this case. Do you have any idea for special cases like that?
  17. Hi czardas, Thank you for your response. However I would like my program to highlight text in any situation, no matter what I am doing. Several examples are reading pdf files, surfing the web, composing email and docs, etc. So in your opinion this task cannot be done with AutoIt?
  18. Hi friends, I have searched this forum thoroughly but I couldn't find my answer yet. Basically I would like to write an AutoIt script to highlight any text (which could be a word, a character, ...) which is under the current position of the mouse cursor. Is this possible? If Yes, please suggest me a way to do it. Thank you very much.
  19. Thank you very much for your answer. It is really a good news to me.
  20. Hi friends, I know AutoIt works fine in Windows XP and Windows Vista. But does AutoIt fully support Windows 7? Is there any restriction on AutoIt's functionality when we use it under Windows 7 environment? Thanks for reading my question. Regards, Bobby.
×
×
  • Create New...