###################################################################### ########################## Infinite_Screen ########################### ###################################################################### # Infinite_Screen is a free tool to move or scroll your desktop. # # Much knows about the function of some graphic cards which allow # # to set a virtual desktop resolution, bigger as the screen # # resolution. Result is a moving desktop when mouse moves out # # screen edges. This tool have no maximum virtual screen resolution. # # It can move, drag or scroll your windows so wide you want. # # This is very useful if you have a small 10' notebook screen to # # scroll down to the ok button at a too big application window. # # There are 5 modes to scroll or move windows. # # 1: Mouse (Scrolling on screen edges) # # 2: Mouse (Moving on screen edges) # # 3: Mouse (Dragging on mouse move) # # 4: Keyboard (Scrolling on Keypress) # # 5: Keyboard (Oneclick desktop moving) # # ------------------------------------------------------------------ # # OS: Windows # # Written by: Robert Xell (xenolux@gmail.com) # # More info about this tool: http://ynea.futureware.at # # ------------------------------------------------------------------ # # If you want to use this code partially or change something # # ask me before and write your motivation. # # ------------------------------------------------------------------ # # Todo: Assistance for multiple Desktops at all modes. # ###################################################################### #!/usr/bin/perl #---------------- API Use's use Win32::API; my $SetSystemCursor = Win32::API->new('User32.dll', 'SetSystemCursor', 'II', 'I',); my $LoadCursor = Win32::API->new('User32.dll', 'LoadCursor', 'II', 'I',); my $CopyImage = Win32::API->new('User32.dll', 'CopyImage', 'IIIII', 'I',); my $LoadCursorFromFile = Win32::API->new('User32.dll', 'LoadCursorFromFile', 'P', 'I',); #---------------- my Use's use std; use Tk; #use Tk::JPEG; use Tk::NoteBook; use Tk::StatusBar; use Tk::LabFrame; use Tk::Balloon; use Tk::BrowseEntry; #use Tk::DynaTabFrame; #use Tk::Pane; use Win32::GUI; use Win32::GuiTest; use Time::HiRes; use Win32::Registry; use Cwd; use threads; use threads::shared; #=========================== mycwd my $mycwd = Cwd::getcwd; $mycwd =~ s/\//\\/g; ################################# run registry open my $regruns; $::HKEY_CURRENT_USER->Open('Software\Microsoft\Windows\CurrentVersion\Run', $regruns); $regruns->SetValueEx('Infinite_Screen',1,1,$mycwd.'\perl\bin\infinite_screen.exe -x'.$mycwd.' '.$mycwd.'\screen') if ((split(',',std::readfile('conf/startupconf.dat')))[0] ne 'noautostart'); ################################# get winconf my @windows_excluded = split("\n",std::readfile('conf/windowconf.dat')); share(@windows_excluded); ############################################################## ############################################# SCROLLTHREAD ### my $configsender :shared; my $thr = threads->create('scrollthread'); sub scrollthread() { my %cursortypes = (OCR_APPSTARTING => 32650,# Standard arrow and small hourglass OCR_NORMAL => 32512,# Standard arrow OCR_CROSS => 32515,# Crosshair OCR_HAND => 32649,# Hand OCR_HELP => 32651,# Arrow and question mark OCR_IBEAM => 32513,# I-beam OCR_NO => 32648,# Slashed circle OCR_SIZEALL => 32646,# Four-pointed arrow pointing north, south, east, and west OCR_SIZENESW => 32643,# Double-pointed arrow pointing northeast and southwest OCR_SIZENS => 32645,# Double-pointed arrow pointing north and south OCR_SIZENWSE => 32642,# Double-pointed arrow pointing northwest and southeast OCR_SIZEWE => 32644,# Double-pointed arrow pointing west and east OCR_UP => 32516,# Vertical arrow OCR_WAIT => 32514);# Hourglass #---- save old cursor's & transcursor load my %prev_cursorhandles; $prev_cursorhandles{$_} = $CopyImage->Call($LoadCursor->Call(0,$cursortypes{$_}),2,0,0,0) foreach (keys %cursortypes); my $hcursor = $LoadCursorFromFile->Call('images\transparent.cur'); #---- globs my @movetype; my @keychoose; my @keylock; my @pixsteps; my $scroll_edges; my $scroll_corners; my $key_left; my $key_right; my $key_up; my $key_down; my (@cursorpos_x, @cursorpos_y); while(1) { if ($configsender ne '') { my ($stdconfig,$advconfig) = split("\n---\n",$configsender); my $confcount = 0; foreach my $confline (grep(m/^[12345678]~/,split("\n",$stdconfig))) { ($movetype[$confcount],$keychoose[$confcount],$keylock[$confcount],$pixsteps[$confcount]) = split('~',$confline); $confcount++; } ($scroll_edges,$scroll_corners,$key_left,$key_right,$key_up,$key_down) = split(',',$advconfig); $configsender = ''; } foreach my $confnr (0 .. $#keychoose) { my $is_true = 1; if ($keylock[$confnr]) {#keylock $is_true = 0 if (!(Win32::GUI::GetKeyState($keychoose[$confnr]))[1]); } else {#keypress foreach (split(',',$keychoose[$confnr])) { $is_true = 0 if (!Win32::GUI::GetKeyState($_)); } } if (!$is_true) #not locked or pressed { ($cursorpos_x[$confnr], $cursorpos_y[$confnr]) = Win32::GUI::GetCursorPos if ($movetype[$confnr] == 2); } else #when activation keylock or keypress { if ($movetype[$confnr] == 5)#--------------------------Mouse (Moving on screen edges) { my $desk = Win32::GUI::GetDesktopWindow(); my $desk_w = Win32::GUI::Width($desk); my $desk_h = Win32::GUI::Height($desk); my $edges_minx = $desk_w/2-$desk_w/2/100*$scroll_edges; my $edges_maxx = $desk_w/2+$desk_w/2/100*$scroll_edges; my $edges_miny = $desk_h/2-$desk_h/2/100*$scroll_edges; my $edges_maxy = $desk_h/2+$desk_h/2/100*$scroll_edges; my $corners_minx = $desk_w/2/100*$scroll_corners; my $corners_maxx = $desk_w-$desk_w/2/100*$scroll_corners; my $corners_miny = $desk_h/2/100*$scroll_corners; my $corners_maxy = $desk_h-$desk_h/2/100*$scroll_corners; my ($curpos_x, $curpos_y) = Win32::GUI::GetCursorPos; #---- top if (($curpos_y == 0 && $curpos_x > $edges_minx && $curpos_x < $edges_maxx) || ($curpos_y == 0 && $curpos_x > $corners_maxx) || ($curpos_y == 0 && $curpos_x < $corners_minx)) { $SetSystemCursor->Call($CopyImage->Call($hcursor,2,0,0,0),$cursortypes{$_}) foreach (keys %cursortypes); my ($savedcurpos_x, $savedcurpos_y) = Win32::GUI::GetCursorPos; my ($centeredcurpos_x, $centeredcurpos_y) = ($desk_w/2,$desk_h/2); Win32::GUI::SetCursorPos($centeredcurpos_x, $centeredcurpos_y); my @tomove_windows = movable_windows(); while (1) { my ($newcurpos_x, $newcurpos_y) = Win32::GUI::GetCursorPos; Win32::GUI::SetCursorPos($centeredcurpos_x, $centeredcurpos_y); last if (($centeredcurpos_y-$newcurpos_y) < 0); Win32::GUI::Move($_,Win32::GUI::AbsLeft($_)+($centeredcurpos_x-$newcurpos_x),Win32::GUI::AbsTop($_)+($centeredcurpos_y-$newcurpos_y)) foreach (@tomove_windows); } $SetSystemCursor->Call($CopyImage->Call($prev_cursorhandles{$_},2,0,0,0),$cursortypes{$_}) foreach (keys %cursortypes); Win32::GUI::SetCursorPos($savedcurpos_x, $savedcurpos_y+1); } #---- bottom if (($curpos_y == $desk_h-1 && $curpos_x > $edges_minx && $curpos_x < $edges_maxx) || ($curpos_y == $desk_h-1 && $curpos_x > $corners_maxx) || ($curpos_y == $desk_h-1 && $curpos_x < $corners_minx)) { $SetSystemCursor->Call($CopyImage->Call($hcursor,2,0,0,0),$cursortypes{$_}) foreach (keys %cursortypes); my ($savedcurpos_x, $savedcurpos_y) = Win32::GUI::GetCursorPos; my ($centeredcurpos_x, $centeredcurpos_y) = ($desk_w/2,$desk_h/2); Win32::GUI::SetCursorPos($centeredcurpos_x, $centeredcurpos_y); my @tomove_windows = movable_windows(); while (1) { my ($newcurpos_x, $newcurpos_y) = Win32::GUI::GetCursorPos; Win32::GUI::SetCursorPos($centeredcurpos_x, $centeredcurpos_y); last if (($centeredcurpos_y-$newcurpos_y) > 0); Win32::GUI::Move($_,Win32::GUI::AbsLeft($_)+($centeredcurpos_x-$newcurpos_x),Win32::GUI::AbsTop($_)+($centeredcurpos_y-$newcurpos_y)) foreach (@tomove_windows); } $SetSystemCursor->Call($CopyImage->Call($prev_cursorhandles{$_},2,0,0,0),$cursortypes{$_}) foreach (keys %cursortypes); Win32::GUI::SetCursorPos($savedcurpos_x, $savedcurpos_y-1); } #---- left if (($curpos_x == 0 && $curpos_y > $edges_miny && $curpos_y < $edges_maxy) || ($curpos_x == 0 && $curpos_y > $corners_maxy) || ($curpos_x == 0 && $curpos_y < $corners_miny)) { $SetSystemCursor->Call($CopyImage->Call($hcursor,2,0,0,0),$cursortypes{$_}) foreach (keys %cursortypes); my ($savedcurpos_x, $savedcurpos_y) = Win32::GUI::GetCursorPos; my ($centeredcurpos_x, $centeredcurpos_y) = ($desk_w/2,$desk_h/2); Win32::GUI::SetCursorPos($centeredcurpos_x, $centeredcurpos_y); my @tomove_windows = movable_windows(); while (1) { my ($newcurpos_x, $newcurpos_y) = Win32::GUI::GetCursorPos; Win32::GUI::SetCursorPos($centeredcurpos_x, $centeredcurpos_y); last if (($centeredcurpos_x-$newcurpos_x) < 0); Win32::GUI::Move($_,Win32::GUI::AbsLeft($_)+($centeredcurpos_x-$newcurpos_x),Win32::GUI::AbsTop($_)+($centeredcurpos_y-$newcurpos_y)) foreach (@tomove_windows); } $SetSystemCursor->Call($CopyImage->Call($prev_cursorhandles{$_},2,0,0,0),$cursortypes{$_}) foreach (keys %cursortypes); Win32::GUI::SetCursorPos($savedcurpos_x+1, $savedcurpos_y); } #---- right if (($curpos_x == $desk_w-1 && $curpos_y > $edges_miny && $curpos_y < $edges_maxy) || ($curpos_x == $desk_w-1 && $curpos_y > $corners_maxy) || ($curpos_x == $desk_w-1 && $curpos_y < $corners_miny)) { $SetSystemCursor->Call($CopyImage->Call($hcursor,2,0,0,0),$cursortypes{$_}) foreach (keys %cursortypes); my ($savedcurpos_x, $savedcurpos_y) = Win32::GUI::GetCursorPos; my ($centeredcurpos_x, $centeredcurpos_y) = ($desk_w/2,$desk_h/2); Win32::GUI::SetCursorPos($centeredcurpos_x, $centeredcurpos_y); my @tomove_windows = movable_windows(); while (1) { my ($newcurpos_x, $newcurpos_y) = Win32::GUI::GetCursorPos; Win32::GUI::SetCursorPos($centeredcurpos_x, $centeredcurpos_y); last if (($centeredcurpos_x-$newcurpos_x) > 0); Win32::GUI::Move($_,Win32::GUI::AbsLeft($_)+($centeredcurpos_x-$newcurpos_x),Win32::GUI::AbsTop($_)+($centeredcurpos_y-$newcurpos_y)) foreach (@tomove_windows); } $SetSystemCursor->Call($CopyImage->Call($prev_cursorhandles{$_},2,0,0,0),$cursortypes{$_}) foreach (keys %cursortypes); Win32::GUI::SetCursorPos($savedcurpos_x-1, $savedcurpos_y); } } if ($movetype[$confnr] == 1)#--------------------------Mouse (Scrolling on screen edges) { my $desk = Win32::GUI::GetDesktopWindow(); my $desk_w = Win32::GUI::Width($desk); my $desk_h = Win32::GUI::Height($desk); my $edges_minx = $desk_w/2-$desk_w/2/100*$scroll_edges; my $edges_maxx = $desk_w/2+$desk_w/2/100*$scroll_edges; my $edges_miny = $desk_h/2-$desk_h/2/100*$scroll_edges; my $edges_maxy = $desk_h/2+$desk_h/2/100*$scroll_edges; my $corners_minx = $desk_w/2/100*$scroll_corners; my $corners_maxx = $desk_w-$desk_w/2/100*$scroll_corners; my $corners_miny = $desk_h/2/100*$scroll_corners; my $corners_maxy = $desk_h-$desk_h/2/100*$scroll_corners; my ($curpos_x, $curpos_y) = Win32::GUI::GetCursorPos; #---- left top if (($curpos_x == 0 && $curpos_y < $corners_miny) || ($curpos_y == 0 && $curpos_x < $corners_minx)) { my @tomove_windows = movable_windows(); my $timeold = Time::HiRes::time; my (%absleft,%abstop); $absleft{$_} = Win32::GUI::AbsLeft($_) foreach (@tomove_windows); $abstop{$_} = Win32::GUI::AbsTop($_) foreach (@tomove_windows); while (($curpos_x == 0 && $curpos_y < $corners_miny) || ($curpos_y == 0 && $curpos_x < $corners_minx)) { my $timenow = Time::HiRes::time; my $stepsnow = ($timenow-$timeold)*$pixsteps[$confnr]; $timeold = $timenow; #Win32::GUI::Move($_,Win32::GUI::AbsLeft($_)+$stepsnow,Win32::GUI::AbsTop($_)) foreach (@tomove_windows); foreach (@tomove_windows) { $absleft{$_} += $stepsnow; $abstop{$_} += $stepsnow; Win32::GUI::Move($_,$absleft{$_},$abstop{$_}); } ($curpos_x, $curpos_y) = Win32::GUI::GetCursorPos; } } #---- right top if (($curpos_x == $desk_w-1 && $curpos_y < $corners_miny) || ($curpos_y == 0 && $curpos_x > $corners_maxx)) { my @tomove_windows = movable_windows(); my $timeold = Time::HiRes::time; my (%absleft,%abstop); $absleft{$_} = Win32::GUI::AbsLeft($_) foreach (@tomove_windows); $abstop{$_} = Win32::GUI::AbsTop($_) foreach (@tomove_windows); while (($curpos_x == $desk_w-1 && $curpos_y < $corners_miny) || ($curpos_y == 0 && $curpos_x > $corners_maxx)) { my $timenow = Time::HiRes::time; my $stepsnow = ($timenow-$timeold)*$pixsteps[$confnr]; $timeold = $timenow; #Win32::GUI::Move($_,Win32::GUI::AbsLeft($_)+$stepsnow,Win32::GUI::AbsTop($_)) foreach (@tomove_windows); foreach (@tomove_windows) { $absleft{$_} -= $stepsnow; $abstop{$_} += $stepsnow; Win32::GUI::Move($_,$absleft{$_},$abstop{$_}); } ($curpos_x, $curpos_y) = Win32::GUI::GetCursorPos; } } #---- left bottom if (($curpos_x == 0 && $curpos_y > $corners_maxy) || ($curpos_y == $desk_h-1 && $curpos_x < $corners_minx)) { my @tomove_windows = movable_windows(); my $timeold = Time::HiRes::time; my (%absleft,%abstop); $absleft{$_} = Win32::GUI::AbsLeft($_) foreach (@tomove_windows); $abstop{$_} = Win32::GUI::AbsTop($_) foreach (@tomove_windows); while (($curpos_x == 0 && $curpos_y > $corners_maxy) || ($curpos_y == $desk_h-1 && $curpos_x < $corners_minx)) { my $timenow = Time::HiRes::time; my $stepsnow = ($timenow-$timeold)*$pixsteps[$confnr]; $timeold = $timenow; #Win32::GUI::Move($_,Win32::GUI::AbsLeft($_)+$stepsnow,Win32::GUI::AbsTop($_)) foreach (@tomove_windows); foreach (@tomove_windows) { $absleft{$_} += $stepsnow; $abstop{$_} -= $stepsnow; Win32::GUI::Move($_,$absleft{$_},$abstop{$_}); } ($curpos_x, $curpos_y) = Win32::GUI::GetCursorPos; } } #---- right bottom if (($curpos_x == $desk_w-1 && $curpos_y > $corners_maxy) || ($curpos_y == $desk_h-1 && $curpos_x > $corners_maxx)) { my @tomove_windows = movable_windows(); my $timeold = Time::HiRes::time; my (%absleft,%abstop); $absleft{$_} = Win32::GUI::AbsLeft($_) foreach (@tomove_windows); $abstop{$_} = Win32::GUI::AbsTop($_) foreach (@tomove_windows); while (($curpos_x == $desk_w-1 && $curpos_y > $corners_maxy) || ($curpos_y == $desk_h-1 && $curpos_x > $corners_maxx)) { my $timenow = Time::HiRes::time; my $stepsnow = ($timenow-$timeold)*$pixsteps[$confnr]; $timeold = $timenow; #Win32::GUI::Move($_,Win32::GUI::AbsLeft($_)+$stepsnow,Win32::GUI::AbsTop($_)) foreach (@tomove_windows); foreach (@tomove_windows) { $absleft{$_} -= $stepsnow; $abstop{$_} -= $stepsnow; Win32::GUI::Move($_,$absleft{$_},$abstop{$_}); } ($curpos_x, $curpos_y) = Win32::GUI::GetCursorPos; } } #---- left right up down if ($curpos_x == 0 && $curpos_y > $edges_miny && $curpos_y < $edges_maxy) { my @tomove_windows = movable_windows(); my $timeold = Time::HiRes::time; my (%absleft,%abstop); $absleft{$_} = Win32::GUI::AbsLeft($_) foreach (@tomove_windows); $abstop{$_} = Win32::GUI::AbsTop($_) foreach (@tomove_windows); while ($curpos_x == 0 && $curpos_y > $edges_miny && $curpos_y < $edges_maxy) { my $timenow = Time::HiRes::time; my $stepsnow = ($timenow-$timeold)*$pixsteps[$confnr]; $timeold = $timenow; #Win32::GUI::Move($_,Win32::GUI::AbsLeft($_)+$stepsnow,Win32::GUI::AbsTop($_)) foreach (@tomove_windows); foreach (@tomove_windows) { $absleft{$_} += $stepsnow; Win32::GUI::Move($_,$absleft{$_},$abstop{$_}); } ($curpos_x, $curpos_y) = Win32::GUI::GetCursorPos; } } if ($curpos_x == $desk_w-1 && $curpos_y > $edges_miny && $curpos_y < $edges_maxy) { my @tomove_windows = movable_windows(); my $timeold = Time::HiRes::time; my (%absleft,%abstop); $absleft{$_} = Win32::GUI::AbsLeft($_) foreach (@tomove_windows); $abstop{$_} = Win32::GUI::AbsTop($_) foreach (@tomove_windows); while ($curpos_x == $desk_w-1 && $curpos_y > $edges_miny && $curpos_y < $edges_maxy) { my $timenow = Time::HiRes::time; my $stepsnow = ($timenow-$timeold)*$pixsteps[$confnr]; $timeold = $timenow; #Win32::GUI::Move($_,Win32::GUI::AbsLeft($_)-$stepsnow,Win32::GUI::AbsTop($_)) foreach (@tomove_windows); foreach (@tomove_windows) { $absleft{$_} -= $stepsnow; Win32::GUI::Move($_,$absleft{$_},$abstop{$_}); } ($curpos_x, $curpos_y) = Win32::GUI::GetCursorPos; } } if ($curpos_y == 0 && $curpos_x > $edges_minx && $curpos_x < $edges_maxx) { my @tomove_windows = movable_windows(); my $timeold = Time::HiRes::time; my (%absleft,%abstop); $absleft{$_} = Win32::GUI::AbsLeft($_) foreach (@tomove_windows); $abstop{$_} = Win32::GUI::AbsTop($_) foreach (@tomove_windows); while ($curpos_y == 0 && $curpos_x > $edges_minx && $curpos_x < $edges_maxx) { my $timenow = Time::HiRes::time; my $stepsnow = ($timenow-$timeold)*$pixsteps[$confnr]; $timeold = $timenow; #Win32::GUI::Move($_,Win32::GUI::AbsLeft($_),Win32::GUI::AbsTop($_)+$stepsnow) foreach (@tomove_windows); foreach (@tomove_windows) { $abstop{$_} += $stepsnow; Win32::GUI::Move($_,$absleft{$_},$abstop{$_}); } ($curpos_x, $curpos_y) = Win32::GUI::GetCursorPos; } } if ($curpos_y == $desk_h-1 && $curpos_x > $edges_minx && $curpos_x < $edges_maxx) { my @tomove_windows = movable_windows(); my $timeold = Time::HiRes::time; my (%absleft,%abstop); $absleft{$_} = Win32::GUI::AbsLeft($_) foreach (@tomove_windows); $abstop{$_} = Win32::GUI::AbsTop($_) foreach (@tomove_windows); while ($curpos_y == $desk_h-1 && $curpos_x > $edges_minx && $curpos_x < $edges_maxx) { my $timenow = Time::HiRes::time; my $stepsnow = ($timenow-$timeold)*$pixsteps[$confnr]; $timeold = $timenow; #Win32::GUI::Move($_,Win32::GUI::AbsLeft($_),Win32::GUI::AbsTop($_)-$stepsnow) foreach (@tomove_windows); foreach (@tomove_windows) { $abstop{$_} -= $stepsnow; Win32::GUI::Move($_,$absleft{$_},$abstop{$_}); } ($curpos_x, $curpos_y) = Win32::GUI::GetCursorPos; } } } elsif ($movetype[$confnr] == 2)#--------------------------Mouse (Dragging on mouse move) { if ($keychoose[$confnr] ne '') { my @tomove_windows = movable_windows(); #my ($curpos_x, $curpos_y) = Win32::GUI::GetCursorPos; my @keychoose_split = split(',',$keychoose[$confnr]); if($#{[grep((Win32::GUI::GetKeyState($_))[$keylock[$confnr]] == 1,@keychoose_split)]} == $#keychoose_split) { my ($newcurpos_x, $newcurpos_y); my ($oldcursorpos_x, $oldcursorpos_y); do { ($newcurpos_x, $newcurpos_y) = Win32::GUI::GetCursorPos; Win32::GUI::Move($_,Win32::GUI::AbsLeft($_)+($newcurpos_x-$cursorpos_x[$confnr]),Win32::GUI::AbsTop($_)+($newcurpos_y-$cursorpos_y[$confnr])) foreach (@tomove_windows); ($oldcursorpos_x, $oldcursorpos_y) = ($cursorpos_x[$confnr], $cursorpos_y[$confnr]); ($cursorpos_x[$confnr], $cursorpos_y[$confnr]) = ($newcurpos_x, $newcurpos_y); } while (($#{[grep((Win32::GUI::GetKeyState($_))[$keylock[$confnr]] == 1,@keychoose_split)]} == $#keychoose_split) && (($oldcursorpos_x-$newcurpos_x) != 0 || ($oldcursorpos_y-$newcurpos_y) != 0)); } } } elsif ($movetype[$confnr] == 3)#--------------------------Keyboard (Scrolling on Keypress) { if ((Win32::GUI::GetKeyState($key_left))[0]) { my @tomove_windows = movable_windows(); my $timeold = Time::HiRes::time; my (%absleft,%abstop); $absleft{$_} = Win32::GUI::AbsLeft($_) foreach (@tomove_windows); $abstop{$_} = Win32::GUI::AbsTop($_) foreach (@tomove_windows); while ((Win32::GUI::GetKeyState($key_left))[0]) { my $timenow = Time::HiRes::time; my $stepsnow = ($timenow-$timeold)*$pixsteps[$confnr]; $timeold = $timenow; foreach (@tomove_windows) { $absleft{$_} += $stepsnow; Win32::GUI::Move($_,$absleft{$_},$abstop{$_}); } } } if ((Win32::GUI::GetKeyState($key_right))[0]) { my @tomove_windows = movable_windows(); my $timeold = Time::HiRes::time; my (%absleft,%abstop); $absleft{$_} = Win32::GUI::AbsLeft($_) foreach (@tomove_windows); $abstop{$_} = Win32::GUI::AbsTop($_) foreach (@tomove_windows); while ((Win32::GUI::GetKeyState($key_right))[0]) { my $timenow = Time::HiRes::time; my $stepsnow = ($timenow-$timeold)*$pixsteps[$confnr]; $timeold = $timenow; foreach (@tomove_windows) { $absleft{$_} -= $stepsnow; Win32::GUI::Move($_,$absleft{$_},$abstop{$_}); } } } if ((Win32::GUI::GetKeyState($key_up))[0]) { my @tomove_windows = movable_windows(); my $timeold = Time::HiRes::time; my (%absleft,%abstop); $absleft{$_} = Win32::GUI::AbsLeft($_) foreach (@tomove_windows); $abstop{$_} = Win32::GUI::AbsTop($_) foreach (@tomove_windows); while ((Win32::GUI::GetKeyState($key_up))[0]) { my $timenow = Time::HiRes::time; my $stepsnow = ($timenow-$timeold)*$pixsteps[$confnr]; $timeold = $timenow; foreach (@tomove_windows) { $abstop{$_} += $stepsnow; Win32::GUI::Move($_,$absleft{$_},$abstop{$_}); } } } if ((Win32::GUI::GetKeyState($key_down))[0]) { my @tomove_windows = movable_windows(); my $timeold = Time::HiRes::time; my (%absleft,%abstop); $absleft{$_} = Win32::GUI::AbsLeft($_) foreach (@tomove_windows); $abstop{$_} = Win32::GUI::AbsTop($_) foreach (@tomove_windows); while ((Win32::GUI::GetKeyState($key_down))[0]) { my $timenow = Time::HiRes::time; my $stepsnow = ($timenow-$timeold)*$pixsteps[$confnr]; $timeold = $timenow; foreach (@tomove_windows) { $abstop{$_} -= $stepsnow; Win32::GUI::Move($_,$absleft{$_},$abstop{$_}); } } } } elsif ($movetype[$confnr] == 4)#Keyboard (Oneclick desktop moving) { if ((Win32::GUI::GetKeyState($key_left))[0]) { my @tomove_windows = movable_windows(); my (%absleft,%abstop); $absleft{$_} = Win32::GUI::AbsLeft($_) foreach (@tomove_windows); $abstop{$_} = Win32::GUI::AbsTop($_) foreach (@tomove_windows); foreach (@tomove_windows) { $absleft{$_} += $pixsteps[$confnr]; Win32::GUI::Move($_,$absleft{$_},$abstop{$_}); } while((Win32::GUI::GetKeyState($key_left))[0]) { Time::HiRes::sleep 0.05 } } if ((Win32::GUI::GetKeyState($key_right))[0]) { my @tomove_windows = movable_windows(); my (%absleft,%abstop); $absleft{$_} = Win32::GUI::AbsLeft($_) foreach (@tomove_windows); $abstop{$_} = Win32::GUI::AbsTop($_) foreach (@tomove_windows); foreach (@tomove_windows) { $absleft{$_} -= $pixsteps[$confnr]; Win32::GUI::Move($_,$absleft{$_},$abstop{$_}); } while((Win32::GUI::GetKeyState($key_right))[0]) { Time::HiRes::sleep 0.05 } } if ((Win32::GUI::GetKeyState($key_up))[0]) { my @tomove_windows = movable_windows(); my (%absleft,%abstop); $absleft{$_} = Win32::GUI::AbsLeft($_) foreach (@tomove_windows); $abstop{$_} = Win32::GUI::AbsTop($_) foreach (@tomove_windows); foreach (@tomove_windows) { $abstop{$_} += $pixsteps[$confnr]; Win32::GUI::Move($_,$absleft{$_},$abstop{$_}); } while((Win32::GUI::GetKeyState($key_up))[0]) { Time::HiRes::sleep 0.05 } } if ((Win32::GUI::GetKeyState($key_down))[0]) { my @tomove_windows = movable_windows(); my (%absleft,%abstop); $absleft{$_} = Win32::GUI::AbsLeft($_) foreach (@tomove_windows); $abstop{$_} = Win32::GUI::AbsTop($_) foreach (@tomove_windows); foreach (@tomove_windows) { $abstop{$_} -= $pixsteps[$confnr]; Win32::GUI::Move($_,$absleft{$_},$abstop{$_}); } while((Win32::GUI::GetKeyState($key_down))[0]) { Time::HiRes::sleep 0.05 } } } } } Time::HiRes::sleep 0.05; } } sub movable_windows() { my @windows = Win32::GuiTest::GetChildWindows(0); #---- removings (syswindows,minimizedwins,maximizedwins,invisibles) my @topwins = grep( #Win32::GuiTest::IsWindowVisible($_) && Win32::GUI::GetWindowLong($_,-16)&0x10000000 && not(Win32::GUI::GetWindowLong($_,-16)&0x01000000) && not(Win32::GUI::GetWindowLong($_,-16)&0x20000000) && Win32::GUI::GetClassName($_).'_'.Win32::GuiTest::GetWindowText($_) ne 'Button_Start' && Win32::GUI::GetClassName($_).'_'.Win32::GuiTest::GetWindowText($_) ne 'Shell_TrayWnd_' && Win32::GUI::GetClassName($_).'_'.Win32::GuiTest::GetWindowText($_) ne 'Progman_Program Manager',@windows); my @xwins; foreach my $win (@topwins) { push(@xwins,$win) if (grep('CN: '.Win32::GUI::GetClassName($win).' | WN: '.Win32::GuiTest::GetWindowText($win) eq $_,@windows_excluded) == 0); } return @xwins; } ######################################################## ########################################### TRAYICON ### #my $id = 1; my $hwnd = Win32::GUI::GetPerlWindow(); #Win32::GUI::Hide($hwnd); my $icon = new Win32::GUI::Icon('images/icon.ico'); my $main = Win32::GUI::Window->new( -name => 'Main', -text => 'Perl', -width => 200, -height => 200, -visible => 0, ); my $ni = $main->AddNotifyIcon( -name => "systray", #-id => $id, -icon => $icon, -tip => "-----------\nInfinite\nScreen\n-----------", ); my $systray_menu = Win32::GUI::Menu->new( "SystrayMenu Function" => "SystrayMenu", #"trayIcon", "> Options" => "Config", "> Info" => "SystrayInfo", "> Exit" => "SystrayExit", ); ############################################################## MW CREATE my $mw = MainWindow->new(); $mw->state('withdraw') if ((split(',',std::readfile('conf/startupconf.dat')))[1] eq 'noshowstart'); $mw->maxsize(0,0); ############################################################## Mainwindow OPTS $mw->protocol('WM_DELETE_WINDOW', \&ExitApplication); my $main_icon = $mw->Photo( -file => "images/icon.bmp" ); $mw->Icon( -image => $main_icon ); $mw->title( 'Infinite Screen'); #----------------------------------------------- NOTEBOOK my $nb = $mw->NoteBook(-focuscolor => 'black')->pack(-expand => 1,-fill => 'y'); my $page1 = $nb->add('PageID-1', -label => 'Main');#-bitmap => 'info'); my $page3 = $nb->add('PageID-3', -label => 'Windows',-raisecmd => \&show_windows); my $page2 = $nb->add('PageID-2', -label => 'About'); #----------------------------------------------- STATUSBAR my $Label_Statusbar = ""; $sb = $mw->StatusBar(); $sb->addLabel(#-background => 'blue', -relief => 'sunken', -textvariable => \$Label_Statusbar, ); #------------------------------------- Page-X Balloons my $b = $mw->Balloon(-initwait => 0); #================================================================== PAGE 3 my $labframe_exclude = $page3->LabFrame(-label => "Exclude Windows", -labelside => "acrosstop")->pack(-expand => 1,-fill => 'both'); my $excludeframe_availablewindows = $labframe_exclude->Frame(-borderwidth => 0)->pack(-expand => 1,-fill => 'both'); my $excludeframe_arrows = $labframe_exclude->Frame(-borderwidth => 0)->pack(-fill => 'x'); my $excludeframe_arrows_left = $excludeframe_arrows->Frame(-borderwidth => 0)->pack(-side => 'left',-expand => 1,-fill => 'x'); my $excludeframe_arrows_middle = $excludeframe_arrows->Frame(-borderwidth => 0)->pack(-side => 'left'); my $excludeframe_arrows_right = $excludeframe_arrows->Frame(-borderwidth => 0)->pack(-side => 'left',-expand => 1,-fill => 'x'); my $excludeframe_excludedwindows = $labframe_exclude->Frame(-borderwidth => 0)->pack(-expand => 1,-fill => 'both'); my $listbox_available = $excludeframe_availablewindows->Scrolled('Listbox',-scrollbars => 'e')->pack(-expand => 1,-fill => 'both'); $excludeframe_arrows_left->Label(-text => 'Available Windows')->pack(-side => 'left'); $excludeframe_arrows_left->Label(-image => $mw->Pixmap(-file => 'images/up.xpm'))->pack(-side => 'left'); my $button_include = $excludeframe_arrows_middle->Button(-image => $mw->Pixmap(-file => 'images/big_up.xpm'),-command => \&include_window)->pack(-side => 'left'); my $button_reload = $excludeframe_arrows_middle->Button(-image => $mw->Pixmap(-file => 'images/reload.xpm'),-command => \&show_windows)->pack(-side => 'left'); my $button_exclude = $excludeframe_arrows_middle->Button(-image => $mw->Pixmap(-file => 'images/big_down.xpm'),-command => \&exclude_window)->pack(-side => 'left'); $b->attach($button_include,-balloonmsg => "Include Window or Delete Window\nwhen it's actually closed."); $b->attach($button_reload,-balloonmsg => "Reload actual Top-Windows"); $b->attach($button_exclude,-balloonmsg => "Exclude Window"); $excludeframe_arrows_right->Label(-text => 'Excluded Windows')->pack(-side => 'right'); $excludeframe_arrows_right->Label(-image => $mw->Pixmap(-file => 'images/down.xpm'))->pack(-side => 'right'); my $listbox_excluded = $excludeframe_excludedwindows->Scrolled('Listbox',-scrollbars => 'e')->pack(-expand => 1,-fill => 'both'); sub show_windows() { $listbox_available->delete(0,'end'); my @wins = sort(map('CN: '.Win32::GUI::GetClassName($_).' | WN: '.Win32::GuiTest::GetWindowText($_),movable_windows)); #my @xwins; #foreach my $win (@wins) #{ # push(@xwins,$win) if (grep($win eq $_,@windows_excluded) == 0); #} $listbox_available->insert('end',@wins); $listbox_excluded->delete(0,'end'); $listbox_excluded->insert('end',@windows_excluded); } sub exclude_window() { if (my $selection = $listbox_available->curselection) { my $selection_string = $listbox_available->get($selection); push(@windows_excluded,$selection_string); @windows_excluded = sort(@windows_excluded); std::writefile('conf/windowconf.dat',join("\n",@windows_excluded)); $listbox_available->delete($selection); $listbox_excluded->insert('end',$selection_string); #show_windows(); } } sub include_window() { if (my $selection = $listbox_excluded->curselection) { my $selection_string = $listbox_excluded->get($selection); @windows_excluded = grep($_ ne $selection_string,@windows_excluded); std::writefile('conf/windowconf.dat',join("\n",@windows_excluded)); $listbox_excluded->delete($selection); $listbox_available->insert('end',$selection_string); #show_windows(); } } #================================================================== PAGE 2 my $page2_frame = $page2->Frame(-bg => 'white',-borderwidth => 0,-padx => 30,-pady => 10)->pack(-expand => 1,-anchor => 'center'); my $logo = $mw->Photo(-file => "./images/logo_weich.bmp"); $page2_frame->Label(-bg => 'white',-border => 0,-padx => 20,-pady => 0,-image => $logo)->pack(); $page2_frame->Label(-bg => 'white',-border => 0,-padx => 0,-pady => 0,-text => "Developed by Robert Xell.")->pack(); my $page2_mailframe = $page2_frame->Label(-bg => 'white',-border => 0,-padx => 0,-pady => 0)->pack(-anchor => 'center'); $page2_mailframe->Label(-bg => 'white',-border => 0,-padx => 0,-pady => 0,-text => "Email: ")->pack(-side => 'left'); my $label_mail = $page2_mailframe->Label(-cursor => 'trek',-bg => 'white',-border => 0,-padx => 0,-pady => 0,-font => [-underline => 1,-size => 8],-text => "xenolux\@gmail.com")->pack(-side => 'right'); $page2_frame->Label(-bg => 'white',-border => 0,-padx => 0,-pady => 0,-text => "\nTry out my other Tools such as\nthe Virtual Display Manager\nto work on remote applications.")->pack(); my $page2_urlframe = $page2_frame->Label(-bg => 'white',-border => 0,-padx => 0,-pady => 0)->pack(-anchor => 'center'); $page2_urlframe->Label(-bg => 'white',-border => 0,-padx => 0,-pady => 0,-font => [-underline => 0,-size => 8],-text => "Surf to: ")->pack(-side => 'left'); my $label_url = $page2_urlframe->Label(-cursor => 'hand2',-bg => 'white',-border => 0,-padx => 0,-pady => 0,-font => [-underline => 1,-size => 8],-text => "http://ynea.futureware.at")->pack(-side => 'right'); $mw->bind($label_mail, '', sub{system('start mailto:xenolux@gmail.com')}); $mw->bind($label_url , '', sub{system('start http://ynea.futureware.at')}); #================================================================== PAGE 1 #-------------------------------------- Connect my $labframe = $page1->LabFrame(-label => "Configuration Rules", #-background => 'white', -width => 400, -height => 200, -labelside => "acrosstop")->pack(); my $configtitle_frame = $labframe->Frame()->pack(-expand => 1,-fill => 'x'); $configtitle_frame->Frame(-width => 7,-height => 7)->pack(-side => 'left'); $configtitle_frame->Label(-text => "Scroll type")->pack(-side => 'left'); $configtitle_frame->Frame(-width => 156,-height => 7)->pack(-side => 'left'); $configtitle_frame->Label(-text => "Activation keys")->pack(-side => 'left'); $configtitle_frame->Frame(-width => 56,-height => 7)->pack(-side => 'left'); $configtitle_frame->Label(-text => "Key behavour")->pack(-side => 'left'); $configtitle_frame->Frame(-width => 45,-height => 7)->pack(-side => 'left'); $configtitle_frame->Label(-text => "Pixel")->pack(-side => 'left'); my @movetype; my @keychoose; my @keylock; my @pixsteps; my $confquantity = 6; foreach my $confnumber (0 .. ($confquantity-1)) { my $config_frame = $labframe->Frame()->pack(); $config_frame->Frame(-width => 7,-height => 7)->pack(-side => 'left'); my $movetype_var = 'Disabled'; my @movetype_list = ('Disabled','Mouse (Scrolling on screen edges)','Mouse (Moving on screen edges)','Mouse (Dragging on mouse move)','Keyboard (Scrolling on Keypress)','Keyboard (Oneclick desktop moving)'); $movetype[$confnumber] = $config_frame->BrowseEntry(-width => 30, -disabledbackground => 'white', -disabledforeground => 'black', -choices => \@movetype_list, -textvariable => \$movetype_var, -state => 'readonly', -listheight => 6, -buttontakefocus => 1, -browsecmd => [\&movetype_change,$confnumber], -highlightcolor => 'black', -highlightthickness => 1, -takefocus => 1 )->pack(-side => 'left'); $movetype[$confnumber]->Subwidget('arrow')->configure(-bg => 'lightgrey',-fg => 'black'); $b->attach($movetype[$confnumber],-balloonmsg => "Mouse (Scrolling on screen edges):\n". "Scrolling when mouse is on screen edges.\n\n". "Mouse (Moving on screen edges):\n". "Moving when mouse is on screen edges.\n\n". "Mouse (Dragging on mouse move):\n". "Dragging all Windows when mouse moves.\n". "This needs an activation key to work.\n\n". "Keyboard (Scrolling on Keypress):\n". "Scrolling while directionkeys are pressed.\n\n". "Keyboard (Oneclick desktop moving):\n". "Moving one step when directionkeys was pushed."); $config_frame->Frame(-width => 7,-height => 7)->pack(-side => 'left'); my $keychoose_var = 'No Keys'; $keychoose[$confnumber] = $config_frame->Entry(-width => 20, -disabledbackground => 'lightgray', -disabledforeground => 'gray30', -readonlybackground => 'white', -background => 'white', -foreground => 'black', -highlightcolor => 'black', -highlightthickness => 1, -takefocus => 1, -state => 'disabled', -textvariable => \$keychoose_var)->pack(-side => 'left'); $b->attach($keychoose[$confnumber],-balloonmsg => "Click into the field and then choose the keys\nwhich must be pressed to activate the desktop moving.\nYou can press it together or on after another.\nClicking in and out this field or pressing the\n\"Delete\" key deletes the choosen keys."); $mw->bind($keychoose[$confnumber], '', [\&keycheck, Ev('b'), Ev('K'), $confnumber]); $mw->bind($keychoose[$confnumber], '', [\&keywait, $confnumber]); $mw->bind($keychoose[$confnumber], '', [\&keyfocusout]); $config_frame->Frame(-width => 7,-height => 7)->pack(-side => 'left'); my $keylock_var = 'KeyHold (On)'; my @keylock_list = ('KeyHold (On)','KeyLock (On,Off)'); $keylock[$confnumber] = $config_frame->BrowseEntry(-width => 14, -disabledbackground => 'lightgray', -disabledforeground => 'gray30', #-readonlybackground => 'white', -background => 'white', -foreground => 'black', -choices => \@keylock_list, -textvariable => \$keylock_var, -state => 'disabled', -listwidth => 35, -listheight => 2, -highlightcolor => 'black', -highlightthickness => 1, -takefocus => 1, -buttontakefocus => 1)->pack(-side => 'left'); $keylock[$confnumber]->Subwidget('arrow')->configure(-bg => 'lightgrey',-fg => 'black'); $b->attach($keylock[$confnumber],-balloonmsg => "Defines the behavour of the Activation keys.\nKeyHold: Key must be pressed to enable scrolling.\nKeyLock: Keypress activates or deactivates scrolling."); $config_frame->Frame(-width => 7,-height => 7)->pack(-side => 'left'); my $pixsteps_var = 150; #my @pixsteps_list = (1 .. 500); $pixsteps[$confnumber] = $config_frame->Spinbox(-width => 5, -disabledbackground => 'lightgray', -disabledforeground => 'gray30', #-readonlybackground => 'white', -background => 'white', -foreground => 'black', #-choices => \@pixsteps_list, -textvariable => \$pixsteps_var, -state => 'disabled', #-listwidth => 17, #-listheight => 20, #-buttontakefocus => 1 -from => 1, -to => 2000, -highlightcolor => 'black', -highlightthickness => 1, -takefocus => 1)->pack(-side => 'left'); #$pixsteps[$confnumber]->Subwidget('arrow')->configure(-bg => 'lightgrey',-fg => 'black'); $b->attach($pixsteps[$confnumber],-balloonmsg => "Pixel stepsize per second when scrolling.\nPixel stepsize on Oneclick moving."); $config_frame->Frame(-width => 7,-height => 7)->pack(-side => 'left'); $labframe->Frame(-width => 7,-height => 5)->pack(); } my @conf_key; my @conf_keyname; sub keycheck(@) { my $entry_field = $_[0]; my $key = $_[1]; my $keyname = $_[2]; $keyname =~ s/_L$//; my $confnumber = $_[3]; if ($entry_field->cget('-state') ne 'disabled') { if ($keyname eq 'Delete') { $entry_field->configure(-textvariable => 'No Keys'); $keylock[$confnumber]->configure(-state => 'disabled',-disabledbackground => 'lightgray',-disabledforeground => 'gray30'); } else { push(@{$conf_key[$confnumber]},$key); push(@{$conf_keyname[$confnumber]},$keyname); $entry_field->configure(-text => join(' + ',@{$conf_keyname[$confnumber]})); $keylock[$confnumber]->configure(-state => 'readonly',-disabledbackground => 'white',-disabledforeground => 'black'); print "key: $key,$keyname\n"; #$entry_field->break; } } } sub keywait(@) { my $entry_field = $_[0]; my $confnumber = $_[1]; if ($entry_field->cget('-state') ne 'disabled') { $conf_key[$confnumber] = (); $conf_keyname[$confnumber] = (); $entry_field->configure(-text => 'Press Keys ..'); } } sub keyfocusout(@) { my $entry_field = $_[0]; if ($entry_field->cget('-text') eq 'Press Keys ..') { $entry_field->configure(-text => 'No Keys'); } } sub movetype_change(@) { my $confnumber = $_[0]; if($_[2] eq 'Disabled') { $keychoose[$confnumber]->configure(-state => 'disabled'); $pixsteps[$confnumber]->configure(-state => 'disabled'); $keylock[$confnumber]->configure(-state => 'disabled',-disabledbackground => 'lightgray',-disabledforeground => 'gray30'); } else { $keychoose[$confnumber]->configure(-state => 'normal'); ($_[2] ne 'Mouse (Dragging on mouse move)' && $_[2] ne 'Mouse (Moving on screen edges)')? $pixsteps[$confnumber]->configure(-state => 'normal'): $pixsteps[$confnumber]->configure(-state => 'disabled'); $keylock[$confnumber]->configure(-state => 'readonly',-disabledbackground => 'white',-disabledforeground => 'black') if (${$keychoose[$confnumber]->cget('-textvariable')} ne 'No Keys'); } } #========================================================== Mouse Scroll Config my $config2_frame = $page1->Frame()->pack(-fill => 'x'); my $mouseconf_labframe = $config2_frame->LabFrame(-label => "Mouse Scroll Area", -padx => 7, -pady => 5, -width => 300, -height => 100, -labelside => "acrosstop")->pack(-side => 'left',-anchor => 'w'); my $keyboardconf_labframe = $config2_frame->LabFrame(-label => "Keyboard Scroll Keys", -padx => 7, -pady => 5, -width => 100, -height => 100, -labelside => "acrosstop")->pack(-side => 'right',-anchor => 'ne'); my $startupconf_labframe = $config2_frame->LabFrame(-label => "Startup Options", -padx => 7, -pady => 5, -width => 100, -height => 100, -labelside => "acrosstop")->pack(-expand => 1,-fill => 'x',-side => 'left',-anchor => 'ne'); $page1->Frame()->pack(-expand => 1,-fill => 'both'); my $canvasframe = $mouseconf_labframe->Frame(-bg => 'white',-borderwidth => 2,-relief => 'raised')->pack(-side => 'left'); my $canvas = $canvasframe->Canvas(-width => 120, -height => 100, -xscrollincrement => 5, -yscrollincrement => 5, -bg => 'gray90', -borderwidth => 0)->pack(-side => 'left'); my $scale_edges = $mouseconf_labframe->Scale(-orient => 'vertical', -command => [\&canvasdraw,1], -activebackground => 'green', -sliderlength => 15, -width => 10, -length => 100, -from => 0, -to => 100, -tickinterval => 0)->pack(-side => 'left'); my $scale_corners = $mouseconf_labframe->Scale(-orient => 'vertical', -command => [\&canvasdraw,2], -activebackground => 'red', -sliderlength => 15, -width => 10, -length => 100, -from => 0, -to => 100, -tickinterval => 0)->pack(-side => 'left'); $mw->bind($scale_edges, '', sub{my $w = $_[0]; $w->focus;}); $mw->bind($scale_corners, '', sub{my $w = $_[0]; $w->focus;}); $b->attach($scale_edges,-balloonmsg => "Percent of the sensitive edges size.\nTo adjust the slider value in smallest steps\nuse up and down Keys on Keyboard.\n(0 = Disabled)"); $b->attach($scale_corners,-balloonmsg => "Percent of the sensitive corners size.\nTo adjust the slider value in smallest steps\nuse up and down Keys on Keyboard.\n(0 = Disabled)"); $scale_edges ->set(90); $scale_corners->set(10); sub canvasdraw() { $scale_corners->set((100-$scale_edges->get())) if ($_[0] == 1 && (100-$scale_edges->get()) < $scale_corners->get()); $scale_edges->set((100-$scale_corners->get())) if ($_[0] == 2 && (100-$scale_corners->get()) < $scale_edges->get()); my $canvasx = $canvas->cget(-width)-1; my $canvasy = $canvas->cget(-height)-1; #my $scale_edges_size = $scale_edges->get(); #my $scale_corners_size = $scale_corners->get(); my $scale_edges_pixsizeX = $canvasx/100*$scale_edges->get(); my $scale_edges_pixsizeY = $canvasy/100*$scale_edges->get(); my $scale_corners_pixsizeX = $canvasx/100*$scale_corners->get()/2; my $scale_corners_pixsizeY = $canvasy/100*$scale_corners->get()/2; $canvas->delete('all'); $canvas->createLine(($canvasx-$scale_edges_pixsizeX)/2,0,($canvasx-$scale_edges_pixsizeX)/2+$scale_edges_pixsizeX,0, -fill => 'green', -width => 10); $canvas->createLine(($canvasx-$scale_edges_pixsizeX)/2,$canvasy,($canvasx-$scale_edges_pixsizeX)/2+$scale_edges_pixsizeX,$canvasy, -fill => 'green', -width => 10); $canvas->createLine(0,($canvasy-$scale_edges_pixsizeY)/2,0,($canvasy-$scale_edges_pixsizeY)/2+$scale_edges_pixsizeY, -fill => 'green', -width => 10); $canvas->createLine($canvasx,($canvasy-$scale_edges_pixsizeY)/2,$canvasx,($canvasy-$scale_edges_pixsizeY)/2+$scale_edges_pixsizeY, -fill => 'green', -width => 10); $canvas->createLine(0,$scale_corners_pixsizeY,0,0,$scale_corners_pixsizeX,0, -fill => 'red', -width => 10, -arrow => 'both'); $canvas->createLine(0,$canvasy-$scale_corners_pixsizeY,0,$canvasy,$scale_corners_pixsizeX,$canvasy, -fill => 'red', -width => 10, -arrow => 'both'); $canvas->createLine($canvasx,$scale_corners_pixsizeY,$canvasx,0,$canvasx-$scale_corners_pixsizeX,0, -fill => 'red', -width => 10, -arrow => 'both'); $canvas->createLine($canvasx,$canvasy-$scale_corners_pixsizeY,$canvasx,$canvasy,$canvasx-$scale_corners_pixsizeX,$canvasy, -fill => 'red', -width => 10, -arrow => 'both'); } #========================================================== Startup Config my $startupconf_auto_frame = $startupconf_labframe->Frame()->pack(-fill => 'x'); my $startupconf_show_frame = $startupconf_labframe->Frame()->pack(-fill => 'x'); my $startup_auto_variable = 'autostart'; my $startup_auto_checkbutton = $startupconf_auto_frame->Checkbutton(-variable => \$startup_auto_variable, -onvalue => 'autostart', -offvalue => 'noautostart')->pack(-side => 'left'); $startupconf_auto_frame->Label(-text => 'Autostart at Boot')->pack(-side => 'left'); $b->attach($startup_auto_checkbutton, -balloonmsg => "Start this tool when windows starts up."); my $startup_show_variable = 'showstart'; my $startup_show_checkbutton = $startupconf_show_frame->Checkbutton(-variable => \$startup_show_variable, -onvalue => 'showstart', -offvalue => 'noshowstart')->pack(-side => 'left'); $startupconf_show_frame->Label(-text => 'Show window at Start')->pack(-side => 'left'); $b->attach($startup_show_checkbutton, -balloonmsg => "Show this configuration window on app start.\nYou can open it everytime through 'rightclick-options' on trayicon."); #=============================================== Keyboard Scroll Config my $frame_leftkey = $keyboardconf_labframe->Frame()->pack(); my $frame_rightkey = $keyboardconf_labframe->Frame()->pack(); my $frame_upkey = $keyboardconf_labframe->Frame()->pack(); my $frame_downkey = $keyboardconf_labframe->Frame()->pack(); $frame_leftkey ->Label(-text => 'Left', -width => 6)->pack(-side => 'left'); $frame_rightkey->Label(-text => 'Right',-width => 6)->pack(-side => 'left'); $frame_upkey ->Label(-text => 'Up', -width => 6)->pack(-side => 'left'); $frame_downkey ->Label(-text => 'Down', -width => 6)->pack(-side => 'left'); my $entry_left = $frame_leftkey ->Entry(-text => 'Left', -width => 7)->pack(-side => 'left'); my $entry_right = $frame_rightkey->Entry(-text => 'Right',-width => 7)->pack(-side => 'left'); my $entry_up = $frame_upkey ->Entry(-text => 'Up', -width => 7)->pack(-side => 'left'); my $entry_down = $frame_downkey ->Entry(-text => 'Down', -width => 7)->pack(-side => 'left'); $b->attach($entry_left, -balloonmsg => "Click in and press Key."); $b->attach($entry_right,-balloonmsg => "Click in and press Key."); $b->attach($entry_up, -balloonmsg => "Click in and press Key."); $b->attach($entry_down, -balloonmsg => "Click in and press Key."); $mw->bind($entry_left, '', [\&keyselect, Ev('b'), Ev('K'), 'left']); $mw->bind($entry_right, '', [\&keyselect, Ev('b'), Ev('K'), 'right']); $mw->bind($entry_up, '', [\&keyselect, Ev('b'), Ev('K'), 'up']); $mw->bind($entry_down, '', [\&keyselect, Ev('b'), Ev('K'), 'down']); $frame_leftkey ->Label(-width => 1)->pack(-side => 'left'); $frame_rightkey->Label(-width => 1)->pack(-side => 'left'); $frame_upkey ->Label(-width => 1)->pack(-side => 'left'); $frame_downkey ->Label(-width => 1)->pack(-side => 'left'); my %scrollkey = (left => 37,right => 39,up => 38,down => 40); sub keyselect() { my $entry = $_[0]; my $keynr = $_[1]; my $key = $_[2]; my $direction = $_[3]; $entry->configure(-text => $key); $scrollkey{$direction} = $keynr; print "key: $keynr,$key\n"; } #=============================================================== Ok,Cancel,Apply Buttons my $button_masterframe = $page1->Frame()->pack(-fill => 'x',-side => 'bottom'); $button_masterframe->Frame(-height => 5,-bg => 'gray60')->pack(-expand => 1,-fill => 'x'); my $button_frame = $button_masterframe->Frame()->pack(-expand => 1,-fill => 'x'); $button_masterframe->Frame(-height => 2,-bg => 'gray60')->pack(-expand => 1,-fill => 'x'); $button_frame->Frame(-width => 5,-bg => 'gray60')->pack(-side => 'left',-fill => 'y'); $button_frame->Button(-command => sub{$movetype[0]->focus; &saveconfig(); $mw->state('icon');},-text => 'Ok')->pack(-side => 'left',-expand => 1,-fill => 'x'); $button_frame->Frame(-width => 5,-bg => 'gray60')->pack(-side => 'left',-fill => 'y'); $button_frame->Button(-command => sub{$movetype[0]->focus; &loadconfig(); $mw->state('icon');},-text => 'Cancel')->pack(-side => 'left',-expand => 1,-fill => 'x'); $button_frame->Frame(-width => 5,-bg => 'gray60')->pack(-side => 'left',-fill => 'y'); $button_frame->Button(-command => sub{$movetype[0]->focus; &saveconfig();},-text => 'Apply')->pack(-side => 'left',-expand => 1,-fill => 'x'); $button_frame->Frame(-width => 5,-bg => 'gray60')->pack(-side => 'left',-fill => 'y'); $button_frame->Button(-command => sub{$movetype[0]->focus; $ni->Remove; $mw->destroy();},-text => 'Exit Completely')->pack(-side => 'left',-expand => 1,-fill => 'x'); $button_frame->Frame(-width => 2,-bg => 'gray60')->pack(-side => 'left',-fill => 'y'); #----------------- saveconfig my %definition_movetype = ('Disabled' => 0,'Mouse (Moving on screen edges)' => 5,'Mouse (Scrolling on screen edges)' => 1,'Mouse (Dragging on mouse move)' => 2,'Keyboard (Scrolling on Keypress)' => 3,'Keyboard (Oneclick desktop moving)' => 4); my %definition_keylock = ('KeyHold (On)' => 0,'KeyLock (On,Off)' => 1); sub saveconfig() { #print ${$movetype[1]->cget('-textvariable')}."-ok\n"; #print join(',',@{$conf_key[1]})."-ok\n"; my @sammelconfig; foreach my $confnumber (0 .. ($confquantity-1)) { my $movetype = $definition_movetype{${$movetype[$confnumber]->cget(-textvariable)}}; #if ($movetype) #{ my $keychoose = join(',',@{$conf_key[$confnumber]}); my $keychoose_names = join(',',@{$conf_keyname[$confnumber]}); my $keylock = $definition_keylock{${$keylock[$confnumber]->cget(-textvariable)}}; my $pixsteps = $pixsteps[$confnumber]->get; $sammelconfig[$confnumber] = join('~',($movetype,$keychoose,$keylock,$pixsteps,$keychoose_names)); #} } my $stdconfig = join("\n",@sammelconfig); my $advconfig = join(',',$scale_edges->get(), $scale_corners->get(), $scrollkey{'left'}, $scrollkey{'right'}, $scrollkey{'up'}, $scrollkey{'down'}, $entry_left->cget(-textvariable), $entry_right->cget(-textvariable), $entry_up->cget(-textvariable), $entry_down->cget(-textvariable)); my $theconfig = join("\n---\n",($stdconfig,$advconfig)); $configsender = $theconfig; std::writefile('conf/conf.dat',$theconfig); #---- save startupconf std::writefile('conf/startupconf.dat',join(',',(${$startup_auto_checkbutton->cget(-variable)},${$startup_show_checkbutton->cget(-variable)}))); #---- set registry (${$startup_auto_checkbutton->cget(-variable)} eq 'autostart')? $regruns->SetValueEx('Infinite_Screen',1,1,$mycwd.'\perl\bin\infinite_screen.exe -x'.$mycwd.' '.$mycwd.'\screen'): $regruns->DeleteValue('Infinite_Screen'); } #----------------- loadconfig my %undefinition_movetype = (0 => 'Disabled',5 => 'Mouse (Moving on screen edges)',1 => 'Mouse (Scrolling on screen edges)',2 => 'Mouse (Dragging on mouse move)',3 => 'Keyboard (Scrolling on Keypress)',4 => 'Keyboard (Oneclick desktop moving)'); my %undefinition_keylock = (0 => 'KeyHold (On)',1 => 'KeyLock (On,Off)'); sub loadconfig() { my $theconfig = std::readfile('conf/conf.dat'); $configsender = $theconfig; if(my ($stdconfig,$advconfig) = split("\n---\n",$theconfig)) { my @stdconfig_split = split("\n",$stdconfig); my $configcount = 0; foreach my $configline (@stdconfig_split) { my ($movetype,$keychoose,$keylock,$pixsteps,$keychoose_names) = split('~',$configline); my $movetype_scalar = $undefinition_movetype{$movetype}; my $keylock_scalar = $undefinition_keylock{$keylock}; $movetype[$configcount] ->configure(-text => \$movetype_scalar); $keychoose[$configcount]->configure(-text => (join(' + ',split(',',$keychoose_names)) || 'No Keys')); $keylock[$configcount] ->configure(-text => \$keylock_scalar); $pixsteps[$configcount] ->configure(-text => $pixsteps); @{$conf_key[$configcount]} = split(',',$keychoose); @{$conf_keyname[$configcount]} = split(',',$keychoose_names); if ($movetype != 0)#if not disabled { $keychoose[$configcount]->configure(-state => 'normal'); $pixsteps[$configcount] ->configure(-state => 'normal') if ($movetype != 2 && $movetype != 5); $keylock[$configcount] ->configure(-state => 'normal') if ($keychoose ne ''); } $configcount++; } my ($var_scale_edges, $var_scale_corners, $var_scrollkey_left, $var_scrollkey_right, $var_scrollkey_up, $var_scrollkey_down, $var_entry_left, $var_entry_right, $var_entry_up, $var_entry_down) = split(',',$advconfig); $scale_edges ->set($var_scale_edges); $scale_corners->set($var_scale_corners); $entry_left ->configure(-text => $var_entry_left); $entry_right ->configure(-text => $var_entry_right); $entry_up ->configure(-text => $var_entry_up); $entry_down ->configure(-text => $var_entry_down); $scrollkey{'left'} = $var_scrollkey_left; $scrollkey{'right'} = $var_scrollkey_right; $scrollkey{'up'} = $var_scrollkey_up; $scrollkey{'down'} = $var_scrollkey_down; } #---- load startupconf if (my ($startupconf_auto,$startupconf_show) = split(',',std::readfile('conf/startupconf.dat'))) { $startup_auto_checkbutton->configure(-variable => \$startupconf_auto); $startup_show_checkbutton->configure(-variable => \$startupconf_show); } } loadconfig; ###################################################### ######################################## Tray SUBS ### sub systray_RightClick { my($x, $y) = Win32::GUI::GetCursorPos(); $main->TrackPopupMenu($systray_menu->{SystrayMenu}, $x, $y); } sub systray_Click { $mw->state('normal'); $mw->deiconify();#this is the real - bring on top #$mw->attributes(-topmost => 1); #$mw->attributes(-topmost => 0); $mw->bell(); } #sub Main_Terminate { # Win32::GUI::NotifyIcon::Delete( $ni, -id => $id ); # return -1; #} sub SystrayInfo_Click { $nb->raise('PageID-2'); $mw->state('normal'); $mw->deiconify();#this is the real - bring on top } sub SystrayExit_Click { $mw->state('normal'); # Prepare dialog yes|no #my $dialog = $mw->Dialog(-text => 'Do you really want to quit?', # -bitmap => 'question', # -font => '{arial} 8', # -title => 'Virtual Display Manager', # -default_button => 'Yes', # -buttons => [qw/Yes No/], # ); #$main_icon = $mw->Photo( -file => "icon4.ico" ); #$dialog->Icon( -image => $main_icon ); #my $answer = $dialog->Show(); # and display dialog my $answer = $mw->messageBox(-title => 'Infinite Screen', -message => 'Do you really want to quit?', -type => 'YesNo', -icon => 'question', -default => 'yes'); if ($answer =~ /y/i){ # maybe do some cleaning up and #Win32::GUI::NofityIcon::Remove($ni); #Win32::GUI::NotifyIcon::Delete( $ni, -id => $id ); $ni->Remove; $mw->destroy(); #return -1; } else { # continue } } #----------------------------------- Config Click sub Config_Click { $nb->raise('PageID-1'); $mw->state('normal'); $mw->deiconify();#this is the real - bring on top #$mw->attributes(-topmost => 1); #$mw->attributes(-topmost => 0); } #----------------------------------- X-Button SUB sub ExitApplication { $mw->state('withdraw'); return; # Prepare dialog yes|no my $dialog = $mw->Dialog(-text => "Das Programm komplett schliessen ?\n'Nein' drücken um es zu verkleinern.", -bitmap => 'question', -title => 'Quit?', -font => '{courier} 8', -default_button => 'Yes', -buttons => [qw/Yes No/], ); my $answer = $dialog->Show(); # and display dialog if ($answer =~ /y/i){ # maybe do some cleaning up and #exit; $mw->destroy(); } else { # continue #$mw->state('withdraw'); $mw->state('icon'); #$mw->state('zoomed'); } } ################################################################################### ######################################################################## Mainloop # ################################################################################### MainLoop(); __END__