Jump to content

Zuhair

Members
  • Posts

    9
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Zuhair's Achievements

  1. Dear donnyh13 Thank you for reply but your script did not work for me. May be I am missing something but I succeeded in creating a script. Here is the script HotKeySet('{F3}', 'copy_paste_word') Func copy_paste_word() Send("^c") Sleep(100) ; Wait for clipboard to be populated $text = ClipGet() ; Retrieve the copied text from the clipboard ; Check if the clipboard is empty or failed to copy If $text = "" Then MsgBox(0, "Error", "Clipboard is empty or copy failed.") Return EndIf $text = $text & " " ; Add three spaces after the text ClipPut($text) ; Set the modified text back to the clipboard ; Activate Document-2 and paste the text Local $hWnd2 = WinGetHandle('Document-2.docx') ; Change the document name for your use ; Check if the Document-2 window is present If $hWnd2 = "" Then MsgBox(0, "Error", "Document-2 window handle not found.") Return EndIf WinActivate($hWnd2) ; activate the document-2 window Sleep(300) ; delay to ensure the window is activated Send("^v") ; Paste the text Sleep(400) ; delay to view the paste process by yourself ; Go back to Document-2 by activating it Local $hWnd2 = WinGetHandle('Document-1.docx') ; Change the document name for your use If $hWnd1 <> "" Then WinActivate($hWnd1) EndIf EndFunc This script is working correctly. I select some text from Document-1 and then I press the Hotkey, it copies the selected text then activates document-2 and pastes the text along with three spaces and then goes back to the Document-1 by reactivating it. One important thing that I experienced, though I don't know its reason, is that while using the command WinGetHAndle() if I use a variable for the document name then the script don't work as required. For example if I assign the document name to a variable and then use the variable with this command as follows $Doc1 = 'Document-1.docx' $Doc2 = 'Document-2.docx' Local $hWnd2 = WinGetHandle($Doc2) Local $hWnd1 = WinGetHandle($Doc1) then the script do not work correctly.
  2. While working on two MS Word documents, I have to copy hundreds of randomly selected words from Document-1 to Document-2 one by one. I tried to do the job with AutoIt but the paste command is not working at all. I select the text in Document-1 and then I press the shortcut key so the script should copy that selected text to clipboard and then it should paste the text in the Document-2, and then it should insert three spaces after it and then the script should re-activate the Document-1. But it is not working as required. Func copy_paste_word() Local $hWnd1 = WinGetHandle($MSWord1) ; Retrieves the handle of the Document-1 window. Local $hWnd2 = WinGetHandle($MSWord2) ; Retrieves the handle of the Document-2 window. Send('^c') ; Copies the selected text (two or three words) to clipboard. WinActivate($hWnd2) ; activates MS Word Document-2 to paste text Send('^v') ; pastes the text from clipboard Send('{SPACE 3}') ; inserts three spaces after the pasted text WinActivate($hWnd1) ; Goes back ot MS Word Document-1 for next text selection EndFunc Is it possible with RegEx to copy the text and insert 3 spaces in the 2nd document without activating the document-2 window?
  3. Here is my code that is working fine. @Andreik code was of great help. Thank you. $i = InputBox("Starting Number", "Enter the starting number", "", "") $e = InputBox("Total lines", "How many lines?", "", "") $var = 0 Do ClipPut('') ; Clear the clipboard $Nmbr = StringRight("000" & $i, 4) MouseClick('', 450, $VP) Sleep(600) MouseClick('', 450, $VP) Sleep(600) Send('^c') Sleep(100) $sData = ClipGet() ; Get the copied text from the clipboard Sleep(50) $sData = StringRegExpReplace($sData, '(_+\d+(?:_+\d+)*)$', '______' & $Nmbr) ; Replace the pattern at the end of the string ClipPut($sData) ; Put the modified string back into the clipboard Sleep(50) Send('^v') Send('{ENTER}') $i += 1 $var += 1 $VP += 17 If $VP > 900 Then Send('{PGDN 2}') $VP = 130 EndIf Until $var >= $e
  4. I have already tried my best to understand StringRegExpReplace() but it is quite difficult.
  5. I have spend several hours searching the web and reading the AutoIt forum but have no idea how to find a way. I have a long list like GROUP_hmz.tmp___\hmz7______________0035 GROUP_hmz.tmp___\hmz7TT_______0035__10 AAAALLLL\ainm1___all_____falef__________0075 AAAALLLL\ainm31___all_____falef_______0075_22 ALL_1_\tem.Qm_________0102 ALL_1_\temQ1_________0111 NONE_2_All.t__\amm.rfw_______________0551_21 NONE_2_All.t__\fem.bb__back_________0554 I want to replace the last part of each string containing several consecutive underscores "_" along with the ending digits with this new string "-------"&$new_number where $new_number increments by 1. I don't want to replace other underscores in the string. For example I want to change AAAALLLL\ainm31___all_____falef_______0075_22 to AAAALLLL\ainm31___all_____falef-------0001 Is it possible with AutoIt?
  6. Dear careca, Thank you for your kind reply. At last I solved it after several hours by removing the [CLASS:Edit1] . Now it is working perfectly as given WinWaitActive ('[CLASS:#32770]') ControlSend ('', '', '', $vtp) ControlSend ('', '', '', '{ENTER}') Thanks
  7. I even tried ControlSetText. Instead of variable I also used the actual string WinWaitActive('[CLASS:#32770]') ControlSend('[CLASS:#32770]', '', '[CLASS:Edit1]', 'Light24.vtp') but still it types n in that file name field. To test the code, it will need software and all related files. If you are ready I will send it.
  8. Thank you careca. still it does not work. it types only n in the file name box as it was before
  9. I am trying a script to save a project file from a software (MS Volt) by pressing a hot key but it is not working. Plz help. Pressing the hot key open the << Save project window >> as in common software asking for the file name that I want to save. I want to paste a predefined variable in this file name box and then save it but it does not paste the variable. The variable is defined at the start of the script as $vtp = 'Light24.vtp' for use in several functions in the script. WinWaitActive ('[CLASS:#32770]') ControlSend ('', '', '[CLASS:Edit1]', $vtp) ControlSend ('', '', '', '{ENTER}') something wrong?
×
×
  • Create New...