Xtraeme

Todoist-tags.au3

Nov 11th, 2020 (edited)
924
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.57 KB | None | 0 0
  1. #include <MsgBoxConstants.au3>
  2.  
  3. Func _WinWaitActivate($title,$text,$timeout=200)
  4.     WinWait($title,$text,$timeout)
  5.     If Not WinActive($title,$text) Then WinActivate($title,$text)
  6.     WinWaitActive($title,$text,$timeout)
  7. EndFunc
  8.  
  9. if($CmdLine[0] == 0) Then
  10.    MsgBox(262144, "ERROR", "Needs one tag parameter to remove")
  11.    Exit
  12. EndIf
  13.  
  14. ;_WinWaitActivate("Todoist","")
  15. Send("{ALTDOWN}")
  16. MouseClick("left")
  17. Send("{ALTUP}")
  18. sleep(175) ;150
  19. MouseClick("left")
  20. sleep(150)
  21. Send('^a')
  22. sleep(100)
  23. Send('^c')
  24. sleep(200)
  25. Send('^c')
  26. sleep(200)
  27.  
  28.  
  29. Local $TAG = $CmdLine[1]
  30. Local $LEN_TAG = StringLen($TAG)
  31. Local $STR_to_look_for_tags = ClipGet()
  32. Local $LEN_str_to_look_for_tags = StringLen($STR_to_look_for_tags)
  33. Local $pos = StringInStr($STR_to_look_for_tags, $TAG)
  34.  
  35. If($pos <> 0) Then
  36.    ;$final = StringRegExpReplace($STR_to_look_for_tags, "\@" & $TAG, "")   ;old method
  37.    ;MsgBox(262144, "DEBUG", $final)
  38.    ;Send($final)
  39.    ;Send('^c')
  40.    Local $padding = 0
  41.    if($LEN_str_to_look_for_tags/2 < $pos) Then
  42.       Send('^{END}')
  43.       sleep(50)
  44.       $pos = $LEN_str_to_look_for_tags - $pos
  45.       $DIRECTION = '{LEFT}'
  46.    Else
  47.       Send('^{HOME}')
  48.       sleep(50)
  49.       $DIRECTION = '{RIGHT}'
  50.       $padding = 2
  51.    EndIf
  52.    For $i = 1 To ($pos-$padding)
  53.       Send($DIRECTION)
  54.       sleep(10) ;old (25)
  55.    Next
  56.    For $i = 0 To $LEN_TAG
  57.          ;Send('X')       ;If the positioning is off, use this to send Xs to find out where the cursor is
  58.          Send('{DELETE}')
  59.          sleep(10)  ;old(25)
  60.    Next
  61.  
  62. Else
  63.    Send('{END}')
  64.    Send(' @'& $TAG & ' ')
  65. EndIf
  66. sleep(100+66*$LEN_TAG)
  67. Send('{ENTER}{ENTER}')
  68. Exit
Add Comment
Please, Sign In to add comment