• Support
  • Articles
  • Resources
  • Products

automatic setdlgpos

Moderator: boris

1 postPage 1 of 1

IshmaelCallMe
Guru

Posts:
676
Joined: Thu Jan 26, 2006 2:28 am
by IshmaelCallMe » Thu Jun 26, 2008 7:09 pm
The combination of these two scripts will automatically set the dialog position for pop up boxes to be the center of the Teraterm window, wherever it happens to be at the moment.

In setdlgpos.ttl:

Code: Select all

  1.  
  2. ;This script sets dialog position to be center of TT window
  3. ;for a given window title
  4.  
  5. gettitle titletext      ;save current window title
  6. gettitle ntitletxt
  7. strconcat ntitletxt ' setdlgpos'
  8. settitle ntitletxt
  9.  
  10. getenv 'TEMP' comfile
  11. strconcat comfile '\setdlgpos_'
  12. strconcat comfile ntitletxt
  13. strconcat comfile '.txt'
  14. filedelete comfile
  15.  
  16. getdir dir
  17. command='"C:\Program Files\AutoIt3\AutoIt3.exe" "'
  18. strconcat command dir
  19. strconcat command '\setdlgpos.au3" "'
  20. strconcat command ntitletxt
  21. strconcat command '" "'
  22. strconcat command comfile
  23. strconcat command '"'
  24. exec command
  25.  
  26. filesearch comfile
  27. while result=0
  28.     filesearch comfile
  29.     mpause 10
  30. endwhile
  31. fileopen hcomfile comfile 0
  32. filereadln hcomfile inputstr
  33. fileclose hcomfile
  34. filedelete comfile
  35.  
  36. strcompare titletext ''
  37. if result=0 then
  38.     settitle ''
  39. else
  40.     settitle titletext      ;set title back to saved value
  41. endif
  42.  
  43. str2int itmp inputstr           ;dont do anything if window is minimized
  44. if itmp>0 then              ;and therefor giving back negative values
  45.     command='setdlgpos '
  46.     strconcat command inputstr
  47.     execcmnd command
  48.     flushrecv
  49. endif
  50.  


In setdlgpos.au3:

Code: Select all

  1.  
  2. ;This script calculates dialog position to be center of TT window
  3. ;for a given window title process
  4. opt("WinTitleMatchMode", 1)     ;1=start, 2=subStr, 3=exact, 4=advanced
  5. ;WinWait($CMDLINE[1], "",10)
  6. $basepos = WinGetPos($CMDLINE[1], "")
  7. $x = Int($basepos[0]+ ($basepos[2] / 3))
  8. $y = Int($basepos[1]+ ($basepos[3] / 3))
  9. FileWriteLine($CMDLINE[2] & '.txt', $x & " " & $y)  ;make sure file is complete by writing then moving it
  10. FileMove($CMDLINE[2] & '.txt',$CMDLINE[2])
  11.  

1 postPage 1 of 1

Users browsing this forum: No registered users
cron