ã¯ããã«
ä¹ ã ã® perlãçªã£è¾¼ã¾ããã®ãæå¾ ãã¤ã¤ãã£ã¦ã¿ã¾ãã
æºå
- Strawberry Perl for Windows ãã¤ã³ã¹ãã¼ã«
PATH ãéãã¦ãã³ãã³ãããã³ãããèµ·åãã¦ã
> cpan -i Win32::GuiTest
ã§ãï½ã
ä½ããå§ããã
IE8 ãã©ãã¾ã§æä½ã§ããããã£ã¦ã¿ãã
IE8 ãèµ·å
use strict; use warnings; use utf8; system('explorer http://www.google.co.jp/');
IE8 ã®ã¦ã£ã³ãã¦ãã³ãã«ãåå¾
use strict; use warnings; use utf8; use Data::Dumper; use Win32::GuiTest qw(:ALL); # ããããã£ã¦ãããªãã¨ä¸ã§ shift-jis åæã§æ±ãããã¿ãã UnicodeSemantics(1); system('explorer http://www.google.co.jp/'); # IE8 ãç«ã¡ä¸ããã¾ã§å¾ 㤠# FindWindowLike ã®ç¬¬ä¸å¼æ°ã 0 ã ã¨ããã¹ã¯ãããä¸ã®å ¨ã¦ã£ã³ãã¦ã«å¯¾ãã¦æ¤ç´¢ãã¦ããã sleep(0.2) while (!scalar(FindWindowLike(0, 'Windows Internet Explorer$'))); # IE8 ã®ã¦ã£ã³ãã¦ãã³ãã«ã表示 print Dumper([FindWindowLike(0, 'Windows Internet Explorer$')]);
WindowText 㨠ClassName ãåå¾ãã¦ã¿ãã
use strict; use warnings; use utf8; use Data::Dumper; use Win32::GuiTest qw(:ALL); # ããããã£ã¦ãããªãã¨ä¸ã§ shift-jis åæã§æ±ãããã¿ãã UnicodeSemantics(1); system('explorer http://www.google.co.jp/'); # IE8 ãç«ã¡ä¸ããã¾ã§å¾ 㤠# FindWindowLike ã®ç¬¬ä¸å¼æ°ã 0 ã ã¨ããã¹ã¯ãããä¸ã®å ¨ã¦ã£ã³ãã¦ã«å¯¾ãã¦æ¤ç´¢ãã¦ããã sleep(0.2) while (!scalar(FindWindowLike(0, 'Windows Internet Explorer$'))); # IE8 ã®ã¦ã£ã³ãã¦ãã³ãã«ã表示 print Dumper([map { [ GetWindowText($_), GetClassName($_) ] } FindWindowLike(0, 'Windows Internet Explorer$')]);
ããããã¿ã¤ãã«ã¨ WindowText ãéããªã¼ã
åå ã¯ï¼
- Googe ãèªã¿è¾¼ã¾ããåã ã£ãããã
ãã£ãã¼ãããããã° HTML ã®å 容㧠WindowText ã¯å¤åããããã ClassName ããã¦ã£ã³ãã¦ãã³ãã«ãåå¾ããã»ãããããããªã¼ã
ã¡ãã£ã¨ä¿®æ£
use strict; use warnings; use utf8; use Data::Dumper; use Win32::GuiTest qw(:ALL); # ããããã£ã¦ãããªãã¨ä¸ã§ shift-jis åæã§æ±ãããã¿ãã UnicodeSemantics(1); system('explorer http://www.google.co.jp/'); my $win = do { my @wins; # ClassName ããã¦ã£ã³ãã¦ãã³ãã«ãåå¾ sleep(0.2) while (!scalar(@wins = FindWindowLike(0, undef, '^IEFrame$'))); # 1 ç»é¢ã ãéãã¦ããåæ㧠die 'There should be one IE8 Window.' if (scalar(@wins) != 1); shift @wins; }; print Dumper({ title => GetWindowText($win), class => GetClassName($win) });
IE8 ã®ã¡ã¤ã³ã¦ã£ã³ãã¦ãæã£ã¦ããåã¦ã£ã³ãã¦ã®æ å ±ãåºã
use strict; use warnings; use utf8; use Data::Dumper; use Win32::GuiTest qw(:ALL); # ããããã£ã¦ãããªãã¨ä¸ã§ shift-jis åæã§æ±ãããã¿ãã UnicodeSemantics(1); system('explorer http://www.google.co.jp/'); my $win = do { my @wins; # ClassName ããã¦ã£ã³ãã¦ãã³ãã«ãåå¾ sleep(0.2) while (!scalar(@wins = FindWindowLike(0, undef, '^IEFrame$'))); # 1 ç»é¢ã ãéãã¦ããåæ㧠die 'There should be one IE8 Window.' if (scalar(@wins) != 1); shift @wins; }; print Dumper([ map { # ãã㧠$win ããã®æ·±ããåããã¿ãã '--' x GetChildDepth($win, $_) . ' ' . GetWindowText($_) . ' (' . GetClassName($_) . ')' } GetChildWindows($win) ]);
UTF8 ãªã®ã§è¡¨ç¤ºã§ãã¦ãªãå ´æããããï¼å©ãã¦ãã³ã³ã¼ã¬ã¤ï¼
Encode 使ã
use strict; use warnings; use utf8; use Data::Dumper; use Win32::GuiTest qw(:ALL); use Encode; # cp932 (Windows ã§ä½¿ããã¦ã Shift-jis çãªä½ã my $cp932 = find_encoding('cp932'); # ããããã£ã¦ãããªãã¨ä¸ã§ shift-jis åæã§æ±ãããã¿ãã UnicodeSemantics(1); system('explorer http://www.google.co.jp/'); my $win = do { my @wins; # ClassName ããã¦ã£ã³ãã¦ãã³ãã«ãåå¾ sleep(0.2) while (!scalar(@wins = FindWindowLike(0, undef, '^IEFrame$'))); # 1 ç»é¢ã ãéãã¦ããåæ㧠die 'There should be one IE8 Window.' if (scalar(@wins) != 1); shift @wins; }; # åå«ã¦ã£ã³ã㦠for (GetChildWindows($win)) { # åºå㯠cp932 㧠print $cp932->encode( # $win ããã®æ·±ã '--' x GetChildDepth($win, $_) . ' ' . GetWindowText($_) . ' (' . GetClassName($_) . ")\n" ); }
ãã±ã¼ã·ã§ã³ãã¼ã« WM_GETTEXT ãéã£ã¦ URL ãåã
Win32::GuiTest ã§ã¯ WMGetText ã¨ããé¢æ°ã使ãã° WM_GETTEXT ãé ããã¿ããã
use strict; use warnings; use utf8; use Data::Dumper; use Win32::GuiTest qw(:ALL); use Encode; # cp932 (Windows ã§ä½¿ããã¦ã Shift-jis çãªä½ã my $cp932 = find_encoding('cp932'); # ããããã£ã¦ãããªãã¨ä¸ã§ shift-jis åæã§æ±ãããã¿ãã UnicodeSemantics(1); system('explorer http://www.google.co.jp/'); my ($win, $address_band_root, $address_edit, $url) = do { my (@wins, $win, @address_band_roots, $address_band_root, @address_edits, $address_edit, $url); # IEFrame ã®ã¦ã£ã³ãã¦ãã³ãã«ãåå¾ sleep(0.2) while (!scalar(@wins = FindWindowLike(0, undef, '^IEFrame$'))); die 'There should be one IE8 Window.' if (scalar(@wins) != 1); $win = shift @wins; # Address Band Root ã®ã¦ã£ã³ãã¦ãã³ãã«ãåå¾ sleep(0.2) while (!scalar(@address_band_roots = FindWindowLike($win, undef, 'Address Band Root'))); die 'There should be one IE8 Address Band Root.' if (scalar(@address_band_roots) != 1); $address_band_root = shift @address_band_roots; # Address Band Root ã®åå«ã® Edit ãæ¢ã sleep(0.2) while (!scalar(@address_edits = FindWindowLike($address_band_root, undef, 'Edit'))); die 'There should be one IE8 Address Edit.' if (scalar(@address_edits) != 1); $address_edit = shift @address_edits; # Edit ã®å 容ãå ¥ãã¾ã§å¾ 㤠sleep(0.2) while(($url = WMGetText($address_edit)) eq ''); # IEFrame, Address Band Root, Edit ã¦ã£ã³ãã¦ã¯ã©ã¹ã¨ WMGetText ã®çµæãè¿ã ($win, $address_band_root, $address_edit, $url); }; print $cp932->encode($url . "\n");
ãã±ã¼ã·ã§ã³ãã¼ã«ãã¼ãã¼ãã¤ãã³ããéã£ã¦ãã¼ã¸é·ç§»
use strict; use warnings; use utf8; use Data::Dumper; use Win32::GuiTest qw(:ALL); use Encode; # cp932 (Windows ã§ä½¿ããã¦ã Shift-jis çãªä½ã my $cp932 = find_encoding('cp932'); # ããããã£ã¦ãããªãã¨ä¸ã§ shift-jis åæã§æ±ãããã¿ãã UnicodeSemantics(1); system('explorer http://www.google.co.jp/'); my ($win, $address_band_root, $address_edit, $url) = do { my (@wins, $win, @address_band_roots, $address_band_root, @address_edits, $address_edit, $url); # IEFrame ã®ã¦ã£ã³ãã¦ãã³ãã«ãåå¾ sleep(0.2) while (!scalar(@wins = FindWindowLike(0, undef, '^IEFrame$'))); die 'There should be one IE8 Window.' if (scalar(@wins) != 1); $win = shift @wins; # Address Band Root ã®ã¦ã£ã³ãã¦ãã³ãã«ãåå¾ sleep(0.2) while (!scalar(@address_band_roots = FindWindowLike($win, undef, 'Address Band Root'))); die 'There should be one IE8 Address Band Root.' if (scalar(@address_band_roots) != 1); $address_band_root = shift @address_band_roots; # Address Band Root ã®åå«ã® Edit ãæ¢ã sleep(0.2) while (!scalar(@address_edits = FindWindowLike($address_band_root, undef, 'Edit'))); die 'There should be one IE8 Address Edit.' if (scalar(@address_edits) != 1); $address_edit = shift @address_edits; # Edit ã®å 容ãå ¥ãã¾ã§å¾ 㤠sleep(0.2) while(($url = WMGetText($address_edit)) eq ''); # IEFrame, Address Band Root, Edit ã¦ã£ã³ãã¦ã¯ã©ã¹ã¨ WMGetText ã®çµæãè¿ã ($win, $address_band_root, $address_edit, $url); }; # ãã±ã¼ã·ã§ã³ãã¼ã«ãã©ã¼ã«ã¹ãã㦠SetFocus($address_edit); # key ãéãï¼"~" ã¯ã¨ã³ã¿ã¼ãã¼ã®æå³ï¼ SendKeys('http://www.yahoo.co.jp/~');
ãã¼ããã¡ã ãGoogle ã®ããããã¼ã¸ã® window.onload ã§ãæ¤ç´¢ããã¯ã¹ã«ãã©ã¼ã«ã¹åããã¡ãããªã¼ã
çµæã¨ãã¦ãæ¤ç´¢ããã¡ãã£ã
ãã±ã¼ã·ã§ã³ãã¼ã®å¤ãç´æ¥æ¸ãæãã¦ã移åãã¿ã³ãæ¼ãããã«ãããã
移åãã¿ã³ãæ¼ãã«ã¯ã Toolbar ã« SendMessage ãã¦æ§é ä½ãåå¾ããªãããã¡ã¿ããã
SendMessage èªä½ã¯ Win32::GuiTest ã§åºæ¥ãã®ã ãã©ãæ§é ä½ã®é åã確ä¿ãã¦ããã®ãã¤ã³ã¿ã渡ãããªãã¦ãã¨ã¯ã§ããã®ããªã¼ã
ãªããã AllocateVirtualBuffer ã使ãã°å
±æã¡ã¢ãªãã¢ãã±ã¼ãã§ãããã ãã§ãã TBBUTTON ã® sizeof ã perl ããåããªãï¼ï¼
ãã£ã±ã XS ããªããã ããªã®ããªï¼
ä¸éå端ã ãã©
ããé
ãã®ã§å¯ã¾ãã
æ¥é±æ«ãããã«ããä¸åº¦èª¿ã¹ããã