Advertisement
Guest User

Untitled

a guest
Feb 14th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #SingleInstance Force
  2. SetTitleMatchMode, 2
  3. SetWorkingDir, A_ScriptDir
  4. SetBatchLines -1
  5. ListLines Off
  6. SendMode Input
  7.  
  8. Insta_Translator:
  9. ;Gui +Resize
  10. Gui Add, Text, x5 h19, ###  [Enter] で翻訳開始 ###
  11. Gui Add, Text, x5 y+1 h19, -----------------------------------------------------------------
  12. Gui Add, Text, x5 y50 h19, 日本語に変換する→                        ←英語に変換する
  13. Gui Add, Edit, x5 y75 w200 h150 vENGLISH gConvert_1st_Action
  14. Gui Add, Edit, x215 y75 w200 h150 vJAPANESE gConvert_1st_Action
  15. Gui, Show,, 翻訳機
  16. return
  17.  
  18. Convert_1st_Action:
  19. ControlActual := GuiGetFocus()
  20. ;gosub, Convert_2nd_Action
  21. return
  22.  
  23. #IfWinActive, 翻訳機
  24. ~Enter::
  25. Convert_2nd_Action:
  26. Gui, Submit, NoHide
  27. If ControlActual = ENGLISH
  28. {
  29. ;TrayTip, Convert Status, Waiting...
  30. GuiControl,, JAPANESE, [Analizando...]
  31. GuiControl,, JAPANESE, % AHK_Traducir(ENGLISH, "ja")
  32. }
  33.  
  34.  
  35. If ControlActual = JAPANESE
  36. {
  37. Sleep, 100
  38. ;TrayTip, Convert Status, Waiting...
  39. GuiControl,, ENGLISH, [分析中...]
  40. GuiControl,, ENGLISH, % AHK_Traducir(JAPANESE " ", "en")
  41. ;TrayTip, Convert Status, Ready!
  42. }
  43. return
  44.  
  45.  
  46.  
  47.  
  48.  
  49. AHK_Traducir(Texto,Hacia) {
  50. Loop {
  51. IfWinExist, ahk_exe iexplorer.exe
  52. Process, Close, iexplorer.exe
  53. else
  54. break
  55. } pwb := ComObjCreate("InternetExplorer.Application")
  56. pwb.Visible := False
  57. pwb.Navigate("https://translate.google.com/#auto/" Hacia "/" Texto)
  58. While pwb.readyState != 4 || pwb.document.readyState != "complete" || pwb.busy
  59. Sleep, 500
  60. Translation := pwb.document.all.result_box.InnerText
  61. Sleep, 100
  62. pwb.Quit
  63. return , Translation
  64. }
  65.  
  66. GuiGetFocus()
  67. {
  68. GuiControlGet out, FocusV
  69. return out
  70. }
  71.  
  72. GuiClose:
  73. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement