Jump to content

jennico

Active Members
  • Posts

    843
  • Joined

  • Last visited

Profile Information

  • Location
    Gamma Solaris

Recent Profile Visitors

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

jennico's Achievements

Universalist

Universalist (7/7)

5

Reputation

  1. updated first post with new version 1.1. changes: added new option for corner buttons, code optimized, minor bugfixes, reduced flickering. the only way to reduce flickering effectively is the consequent use of the "control" functions (ControlSetText,ControlMove,ControlEnable,ControlDisable) instead of "guictrlset...". i did not find a way to exchange the "...set(bk)color" commands, though. the use of @SW_LOCK prevents flickering while updating the gui, but it causes in exchange a "big flicker" on sending @SW_UNLOCK. there seems no way to improve the flickering even more. j.
  2. fixed a bug in script above. sorry.
  3. good to know that it's working fine. quite addicting little game, isn't it ? no, the beams i just added to illustrate the rules.
  4. small addition: the screenshots (use F10) serve as savegames. load them with F5. don't change their names.
  5. my last script of the year 2010. in my long gone youth (pre-pc time) i owned a fascinating board game called black box. the only disadvantage was that it needed a second player to set and check the configuration. somehow it came back to my mind and i thought: wow, this is made for computers and just waiting to get scripted by me. ok, the rules in short: you have a black box with "atoms" inside. you can't see them but from the sides you can shoot laser beams inside and detect their exit from the box. 1.) normal case (deflection): you get a pair of equally colored entry and exit. when you miss the atoms, the laser beam will exit opposide from entry. if you hit an atom (but not frontally), the beam will get deflected (always 90°) by the atom and leave the box through a different exit. 2.) absorption: you hit an atom frontally and the beam will not exit. the entry will be colored red. 3.) reflection: the laser beam hits two atoms at the same time (in between) and will be reflected back to the entry. in this case, the entry will be colored white. the same occurs, when the beam is prevented from entering the box by an atom right beside the entry. judging by the coloration you have to puzzle out the position of the atoms. of course, multiple deflections are possible and make it tricky. the fun rises with the number of atoms, but with more than 4 you will occasionally find non solvable configurations. the (more expanded) rules on wikipedia a happy new year j. #cs ;#=#Title#==================================================# ;# Name ..........: BlackBox.au3 # ;# Description....: Windows Solitary Game # ;# Author ........: jennico (jennicoattminusonlinedotde) # ;# Version .......: 1.1 # ;# History .......: 1.0 v. 31.12.2010 # ;# Date ..........: 3.1.2011 # ;#==========================================================# #ce #NoTrayIcon Opt("WinWaitDelay",0) Global Const $Script=" Black Box v 1.1 © 2010 - 2011 by jennico ",$Title="Select Black Box Screenshot" If $CmdLine[0] Then If $CmdLine[1]=$Title Then WinWaitActive($Title,'',10) ControlFocus($Title,'','ToolbarWindow321') ControlSend($Title,'','ToolbarWindow321','{RIGHT 2}{SPACE}n') ControlHide($Title,'','ToolbarWindow321') ControlHide($Title,'','ToolbarWindow322') ControlHide($Title,'','ComboBox1') ControlHide($Title,'','Static1') ControlFocus($Title,'','Edit1') Local $pos=WinGetPos($Title),$win=WinGetPos($Script) WinMove($Title,"",$win[0]+($win[2]-$pos[2])/2,Default) Exit EndIf EndIf #include <ScreenCapture.au3> Opt("TrayMenuMode",1) Opt("GUIOnEventMode",1) Opt("TrayOnEventMode",1) If WinExists($Script) Then Exit WinActivate($Script) FileChangeDir(@ScriptDir) TraySetClick(8) TraySetIcon("pifmgr.dll",-37);27 TraySetOnEvent(-7,"_Activate") TrayItemSetOnEvent(TrayCreateItem("Exit"),"_Exit") TraySetToolTip($Script) _Menu() _New(1) GUISetState() HotKeySet("{F10}","_Capture") _Main() Func _Main() While Sleep(20) If $Solved=0 And $Manual=0 Then Global $Zeit=TimerDiff($Timer)/1000,$Time=Int($Zeit) $Zeit-=$Time If $Time>=60 Then $Time=Int($Time/60)&" min "&Mod($Time,60) ControlSetText($GUI,"",$4+7," Time: "&$Time&" sec") If ($Breite+2)*($Size+2)<280 Then GUICtrlSetTip($4+7,GUICtrlRead($4+7)&" ") EndIf If WinActive($GUI) Then HotKeySet("{F1}",$Func[0]) HotKeySet("{F2}",$Func[1]) HotKeySet("{F3}",$Func[3]) HotKeySet("{F4}",$Func[2]) HotKeySet("{F5}","_Laden") HotKeySet("{ESC}","_Exit") HotKeySet("{+}","_SizeH") HotKeySet("{#}","_SizeH") HotKeySet("-","_SizeH") Else _Unset() While WinActive($Second) If GUICtrlRead($Group+3)<3 Then _Sleep(3,3) If GUICtrlRead($Group+3)>$bMax Then _Sleep(3,$bMax) If GUICtrlRead($Group+7)<3 Then _Sleep(7,3) If GUICtrlRead($Group+7)>$hMax Then _Sleep(7,$hMax) If GUICtrlRead($Group+11)<1 Then _Sleep(11,1) Local $p=GUICtrlRead($Group+3)*GUICtrlRead($Group+7)/2 If GUICtrlRead($Group+11)>$p Then _Sleep(11,$p) WEnd EndIf WEnd EndFunc Func _Sleep($x,$y) Sleep(1000) If $y<4 And GUICtrlRead($Group+$x)<$y Then ControlSetText($Second,"",$Group+$x,$y) If $y>3 And GUICtrlRead($Group+$x)>$y Then ControlSetText($Second,"",$Group+$x,$y) EndFunc Func _Click() ToolTip("") Local $t=@GUI_CtrlId-$Grid[0][0],$x=Int($t/($Hoehe+2)),$y=Mod($t,$Hoehe+2) If $x>0 And $x<$Breite+1 And $y>0 And $y<$Hoehe+1 Then If GUICtrlRead($4-5)=65 Then GUICtrlSetColor($Grid[$x][$y],0xE8E8E8-0xB2B2B2*$Lsg[$x][$y]) Else GUICtrlSetBkColor($Grid[$x][$y],0xE8E8E8-0xB2B2B2*$Lsg[$x][$y]);0xFF0000) ControlSetText($GUI,"",$Grid[$x][$y],StringTrimLeft("O",$Lsg[$x][$y])) EndIf $Atoms+=1-2*$Lsg[$x][$y] $Lsg[$x][$y]=Not $Lsg[$x][$y] ControlSetText($GUI,"",$4+4," Atoms: "&$Atoms&"/"&$Kugeln) If $Manual Then Return _Ecke(1,$Atoms=$Kugeln) Return _Ecke(3,$Atoms=$Kugeln,2,$Atoms<>$Kugeln) EndIf $Rays+=_Score() ControlSetText($GUI,"",$4+5," Rays: "&$Rays) _Ecke(1,1) ControlDisable($GUI,"",@GUI_CtrlId) Local $ret=_Laser($x,$y,($x=0)-($x=$Breite+1),($y=0)-($y=$Hoehe+1),0) If $ret=$t Then Return GUICtrlSetBkColor(@GUI_CtrlId,0xFFFFFF) If $ret=0 Then Return GUICtrlSetBkColor(@GUI_CtrlId,0xFF0000) $Beams+=_Score() Local $col=Random(0,0xFFFFFF,1) ControlDisable($GUI,"",$ret+$Grid[0][0]) GUICtrlSetBkColor($ret+$Grid[0][0],$col) GUICtrlSetBkColor(@GUI_CtrlId,$col) If GUICtrlRead($3+1)=68 Then Return ControlSetText($GUI,"",$ret+$Grid[0][0],$Beams) ControlSetText($GUI,"",@GUI_CtrlId,$Beams) EndFunc Func _Laser($x,$y,$xdir,$ydir,$t=1) If $t And ($x=0 Or $x=$Breite+1 Or $y=0 Or $y=$Hoehe+1) Then Return $x*($Hoehe+2)+$y If $Ball[$x+$xdir][$y+$ydir] Then Return; -1;absorption If $xdir Then If $Ball[$x+$xdir][$y-1] Then Return _Laser($x,$y,0,1) If $Ball[$x+$xdir][$y+1] Then Return _Laser($x,$y,0,-1) Else If $Ball[$x-1][$y+$ydir] Then Return _Laser($x,$y,1,0) If $Ball[$x+1][$y+$ydir] Then Return _Laser($x,$y,-1,0) EndIf Return _Laser($x+$xdir,$y+$ydir,$xdir,$ydir) EndFunc Func _Aufgabe() _Loesen(_Ecke(1,1),1) EndFunc Func _LoesenX() If $Atoms=$Kugeln Then _Loesen(1) EndFunc Func _Loesen($t=0,$s=0) If $Solved And $s<2 Then Return ;GUICtrlSetState($1-1,64) ControlEnable($GUI,"",$1-1) ControlEnable($GUI,"",$1-2) Local $cnt=_Ecke(2,0,3,0) If $s=1 Then GUICtrlSetState($1+5,129) For $j=1 To $Hoehe For $i=1 To $Breite If $Ball[$i][$j] Then;grün, sonst gelb ControlSetText($GUI,"",$Grid[$i][$j],"O") GUICtrlSetColor($Grid[$i][$j],0xFF0000) GUICtrlSetBkColor($Grid[$i][$j],0xFFFF00-0xC9C8CA*(GUICtrlRead($4-5)=65));0xFF0000) If $Lsg[$i][$j] Then; Or $t=0 $cnt+=1 If GUICtrlRead($4-4)=65 Then ControlSetText($GUI,"",$Grid[$i][$j],$cnt) Else GUICtrlSetColor($Grid[$i][$j],0x00FF00);grüner kreis EndIf Else If $t Then _Score($Wert) If GUICtrlRead($4-4)=65 Then ControlSetText($GUI,"",$Grid[$i][$j],"X");roter kreis EndIf EndIf Next Next If $s=2 Then Return ControlSetText($GUI,"",$4+4," Atoms: "&$cnt*$t&"/"&$Kugeln) If $t Then ControlSetText($GUI,"",$4+7," Time: "&$Time&StringMid(Round($Zeit,2),2)&" sec") If ($Breite+2)*($Size+2)<280 Then GUICtrlSetTip($4+7,GUICtrlRead($4+7)&" ") If $t=0 Then _Score($Wert*$Kugeln) DllCall($U32,$INT,"RedrawWindow",$HWN,$GUI,"ptr",0,$INT,0,$INT,5) $Solved=1 ;_ToolTip("Congratulations","Detected: "&$cnt&" Atoms out of "&$Kugeln&@CRLF&"Your Score: "&$Score&@CRLF&"Your"&GUICtrlRead($4+7),1) EndFunc Func _Score($t=1) $Score+=$t ControlSetText($GUI,"",$4+6," Score: "&$Score) Return $t EndFunc Func _Atoms() GUICtrlSetState($4-4-(@GUI_CtrlId=$4-4),4) GUICtrlSetState(@GUI_CtrlId,1) For $x=0 To $Breite For $y=0 To $Hoehe If $Lsg[$x][$y] Then GUICtrlSetColor($Grid[$x][$y],0xE8E8E8-0xB2B2B2*(GUICtrlRead($4-4)=65)) GUICtrlSetBkColor($Grid[$x][$y],0x363636+0xB2B2B2*(GUICtrlRead($4-4)=65)) EndIf Next Next If $Solved Then _Loesen(0,2) EndFunc Func _Custom() Local $pos=WinGetPos($GUI) WinMove($Second,"",$pos[0]+($pos[2]-138)/2,$pos[1]+($pos[3]-103)/2-41) GUICtrlSetData($Group+3,$Breite) GUICtrlSetData($Group+7,$Hoehe) GUICtrlSetData($Group+11,$Kugeln) GUISetState(@SW_DISABLE,$GUI) GUISetState(@SW_SHOW,$Second) EndFunc Func _UpDown() Local $s=@GUI_CtrlId-$Group,$t=(Mod($s,4)=2)-(Mod($s,4)=0) ControlSetText($Second,"",@GUI_CtrlId+$t,GUICtrlRead(@GUI_CtrlId+$t)-$t) EndFunc Func _Apply() GUISetState(@SW_HIDE,$Second) GUISetState(@SW_ENABLE,$GUI) WinActivate($GUI) If @GUI_CtrlId=$Group+13 Then _Settings(GUICtrlRead($Group+11),GUICtrlRead($Group+3),GUICtrlRead($Group+7)) EndFunc Func _Move() Local $k=StringTrimRight(GUICtrlRead(@GUI_CtrlId,1),6) For $h=12 To 5 Step -1 If @GUI_CtrlId>$Menu[$h-5] Then ExitLoop Next _Settings($k,$h,$h) EndFunc Func _Laden() _Unset() Run('"'&@AutoItExe&'" '&StringLeft(@ScriptFullPath,StringLen(@ScriptFullPath)*(@Compiled=0))&' "'&$Title&'"') Local $file=FileOpenDialog($Title,@ScriptDir,"("&$BB&"*.jpg)",3,"",$GUI) If @error Then Return FileChangeDir(@ScriptDir) $file=StringMid($file,StringInStr($file,"\",1,-1)+1) If StringInStr($file,$BB)<>1 Or StringRight($file,4)<>".jpg" Then Return _ToolTip() $file=StringTrimRight(StringReplace($file,$BB,""),5) Local $t=((StringLeft($file,2)="00")+1)*2,$k=StringLen($file)/$t-2,$b=Dec(StringLeft($file,$t)),$error=@error,$h=Dec(StringMid($file,$t+1,$t)) If @error Or $error Or $k<1 Or $b<3 Or $h<3 Or IsInt($k)=0 Then Return _ToolTip() Local $l[$b+2][$h+2] For $i=1 To $k $a=Dec(StringMid($file,$t*($i+1)+1,$t)) If @error Or $a>($b+2)*($h+2)-1 Then Return _ToolTip() Local $x=Int($a/($h+2)),$y=Mod($a,$h+2) If $x=0 Or $y=0 Or $x=$b+1 Or $y=$h+1 Or $l[$x][$y] Then Return _ToolTip() $l[$x][$y]=1 Next Dim $Ball=$l,$l=0 GUICtrlSetState($4-1,1) _Settings($k,$b,$h,0) EndFunc Func _Settings($k,$b,$h,$q=1) If $q=0 And $Kugeln=$k And $Breite=$b And $Hoehe=$h Then Return _Restart();1 If $q And ($Breite<>$b Or $Hoehe<>$h) Then GUISetState(@SW_LOCK,$GUI);? For $i=$2 To $Menu[8]-1 GUICtrlSetState($i,4) Next GUICtrlSetState($3-1,1) If $b=$h And $h>4 And $h<13 Then For $i=$Menu[$h-5]+1 To $Menu[$h-4]-1 If GUICtrlRead($i,1)=$k&" Atoms" Then GUICtrlSetState($Menu[$h-5],1) GUICtrlSetState($3-1,4) GUICtrlSetState($i,1) ExitLoop EndIf Next EndIf Global $Kugeln=$k If $q=0 And $Breite=$b And $Hoehe=$h Then Return _Restart();1 If ($b+2)*($Size+2)+20+$xBorder>@DesktopWidth Then Global $Size=Int((@DesktopWidth-20-$xBorder)/($b+2)-2) If ($h+2)*($Size+2)+38+$yBorder>@DesktopHeight Then Global $Size=Int((@DesktopHeight-38-$yBorder)/($h+2)-2) _New(1,$q,$b,$h) EndFunc Func _SizeH() $Size+=((@HotKeyPressed="{+}")-(@HotKeyPressed="-"))*2 If @HotKeyPressed="{#}" Then $Size=32 _Size() EndFunc Func _SizeX() $Size+=(@GUI_CtrlId-$3-13)*2 If @GUI_CtrlId=$3+14 Then $Size=32 _Size() EndFunc Func _Size() GUISetState(@SW_LOCK,$GUI) GUICtrlSetState($3+14,4) If $Size<14 Then $Size=14 If $Size=32 Then GUICtrlSetState($3+14,1) _Window() For $i=0 To $Breite+1 For $j=0 To $Hoehe+1 ControlMove($GUI,"",$Grid[$i][$j],9+2*($i>0)+2*($i=$Breite+1)+$i*($Size+2),9+2*($j>0)+2*($j=$Hoehe+1)+$j*($Size+2),$Size,$Size) Next Next GUISetState(@SW_UNLOCK,$GUI) EndFunc Func _Manual() _Restart() GUICtrlSetState($2,128) _ToolTip("Set the Atoms in Black Box","Set "&$Kugeln&" Atoms and Choose 'Restart' to Start Game."&@CRLF&"Choose 'New' to Abort.",1) For $i=1 To $Breite GUICtrlSetState($Grid[$i][0],128) GUICtrlSetState($Grid[$i][$Hoehe+1],128) Next For $i=1 To $Hoehe GUICtrlSetState($Grid[0][$i],128) GUICtrlSetState($Grid[$Breite+1][$i],128) Next _Ecke(2,0) GUICtrlSetState($1+5,132);oder alte belassen GUICtrlSetState($1+7,129) GUICtrlSetState($4-1,128) Global $Manual=1 EndFunc Func _Restart() If $Manual Then Global $Ball=$Lsg ;oder kugeln da !!! or $Atoms oder aufgegeben If $Rays Or $Manual Or $Solved Then Return _New(0,0);Or GUICtrlRead($1+5)=129 ControlSetText($GUI,"",$4+7," Time:") Global $Timer=TimerInit() EndFunc Func _NewX() _New() EndFunc Func _New($t=0,$s=1,$b=0,$h=0) ToolTip("") GUISetState(@SW_LOCK,$GUI) If $b Or $h Then For $i=0 To $Breite+1 For $j=0 To $Hoehe+1 GUICtrlDelete($Grid[$i][$j]) Next Next Global $Breite=$b,$Hoehe=$h _Window() EndIf Global $Lsg[$Breite+2][$Hoehe+2],$Atoms=0,$Rays=0,$Score=0,$Solved=0,$Beams=0,$Manual=0 If $t Then Global $Grid[$Breite+2][$Hoehe+2] For $i=0 To $Breite+1 For $j=0 To $Hoehe+1 If $t Then $Grid[$i][$j]=GUICtrlCreateLabel("",9+2*($i>0)+2*($i=$Breite+1)+$i*($Size+2),9+2*($j>0)+2*($j=$Hoehe+1)+$j*($Size+2),$Size,$Size,513) GUICtrlSetOnEvent(-1,"_Click") GUICtrlSetCursor(-1,0) EndIf If $i=0 Or $j=0 Or $i=$Breite+1 Or $j=$Hoehe+1 Then GUICtrlSetBkColor($Grid[$i][$j],0xC0C0C0);0xE8E8E8);0xFFFFFF) ControlSetText($GUI,"",$Grid[$i][$j],"") Else GUICtrlSetBkColor($Grid[$i][$j],0x363636);0x1C1C1C);0x696969) GUICtrlSetColor($Grid[$i][$j],0x0363636);xFF0000);FFFF) GUICtrlSetFont($Grid[$i][$j],26,1000);20 ControlSetText($GUI,"",$Grid[$i][$j],"O");"•";O EndIf ControlEnable($GUI,"",$Grid[$i][$j]) Next Next If $t Then Global $Ecke[4]=[$Grid[0][0],$Grid[$Breite+1][0],$Grid[0][$Hoehe+1],$Grid[$Breite+1][$Hoehe+1]] For $i=0 To 3 GUICtrlSetOnEvent($Ecke[$i],$Func[$i]) GUICtrlSetColor($Ecke[$i],0xFFFFFF) GUICtrlSetFont($Ecke[$i],7) Next EndIf For $i=0 To 3 GUICtrlSetBkColor($Ecke[$i],0x363636) _Ecke($i,Mod($i+1,2)) Next ControlDisable($GUI,"",$1-1) ControlDisable($GUI,"",$1-2) GUICtrlSetState($1+5,64+$s*4) GUICtrlSetState($1+7,68) GUICtrlSetState($4-1,64) GUICtrlSetState($2,64) If $s Then GUICtrlSetState($4-1,4) ;GUICtrlSetState($1+7,68) Global $Ball[$Breite+2][$Hoehe+2] For $i=1 To $Kugeln Do Local $xt=Random(1,$Breite,1),$yt=Random(1,$Hoehe,1) Until $Ball[$xt][$yt]=0 $Ball[$xt][$yt]=1 Next EndIf ControlSetText($GUI,"",$4+4," Atoms: 0/"&$Kugeln) ControlSetText($GUI,"",$4+5," Rays: 0") ControlSetText($GUI,"",$4+6," Score: 0") ControlSetText($GUI,"",$4+7," Time:") GUISetState(@SW_UNLOCK,$GUI) Global $Timer=TimerInit() EndFunc Func _Window() Local $pos=WinGetPos($GUI),$x=($Breite+2)*($Size+2)+20+$xBorder,$y=($Hoehe+2)*($Size+2)+38+$yBorder,$a=$pos[0]+($pos[2]-$x)/2,$b=$pos[1]+($pos[3]-$y)/2 WinMove($GUI,"",$a,$b*($b>-1),$x,$y) ControlMove($GUI,"",$1-3,0,0,($Breite+2)*($Size+2)+20,$Size+10) ControlMove($GUI,"",$1-2,11+$Size,0,$Breite*($Size+2)+2,$Size+10) ControlMove($GUI,"",$1-1,0,10+$Size,($Breite+2)*($Size+2)+20,($Hoehe+1)*($Size+2)+12) EndFunc Func _Menu() Global Const $BB="BlackBoxScreenshot",$U32="user32.dll",$INT="int",$HWN="hwnd",$SM__CYMENU=DllCall("User32.dll",$INT,"GetSystemMetrics",$INT,15),$Name[4]=["New","Restart","GiveUp","Solve"],$Func[4]=["_NewX","_Restart","_Aufgabe","_LoesenX"];,$Laenge[4]=[3,7,6,5] Global $Breite=8,$Hoehe=8,$Kugeln=5,$Size=32,$Wert=10,$GUI=GUICreate($Script,($Breite+2)*($Size+2)+20,($Hoehe+2)*($Size+2)+38+$SM__CYMENU[0]) GUICtrlSetBkColor(GUICtrlCreateLabel("",0,0,($Breite+2)*($Size+2)+20,$Size+10),0) GUICtrlSetState(-1,128) GUICtrlSetBkColor(GUICtrlCreateLabel("",11+$Size,0,$Breite*($Size+2)+2,$Size+10),0) GUICtrlSetBkColor(GUICtrlCreateLabel("",0,10+$Size,($Breite+2)*($Size+2)+20,($Hoehe+1)*($Size+2)+12),0) GUISetIcon("pifmgr.dll",-37) ;2. gui als client area ? lässt sich besser deleten Global $Menu[9],$1=GUICtrlCreateMenu("&Game") GUICtrlSetOnEvent(GUICtrlCreateMenuItem($Name[0]&@TAB&"F1",$1),$Func[0]) GUICtrlCreateMenuItem("",$1) GUICtrlSetOnEvent(GUICtrlCreateMenuItem($Name[1]&@TAB&"F2",$1),$Func[1]) GUICtrlSetOnEvent(GUICtrlCreateMenuItem($Name[3]&@TAB&"F3",$1),$Func[3]) GUICtrlSetOnEvent(GUICtrlCreateMenuItem("Give up"&@TAB&"F4",$1),$Func[2]) GUICtrlCreateMenuItem("",$1) GUICtrlSetOnEvent(GUICtrlCreateMenuItem("Set Atoms",$1),"_Manual") GUICtrlCreateMenuItem("",$1) GUICtrlSetOnEvent(GUICtrlCreateMenuItem("Exit"&@TAB&"ESC",$1),"_Exit") Global $2=GUICtrlCreateMenu("&Settings") _Items(0,2,4) _Items(1,2,5) _Items(2,3,6) _Items(3,3,6) GUICtrlSetState($Menu[3],1) GUICtrlSetState($Menu[3]+3,1) GUICtrlSetState(GUICtrlCreateMenuItem("3 - 5 Atoms",$Menu[3]),128) _Items(4,4,9) _Items(5,4,10) _Items(6,4,11) _Items(7,4,12) $Menu[8]=GUICtrlCreateMenuItem("",$2) GUICtrlSetOnEvent(GUICtrlCreateMenuItem("Custom",$2),"_Custom") Global $3=GUICtrlCreateMenu("&Options") GUICtrlSetOnEvent(GUICtrlCreateMenuItem("Show Beam Numbers",$3),"_Numbers") GUICtrlSetState(-1,1) GUICtrlSetOnEvent(GUICtrlCreateMenuItem("Enable Corner Buttons",$3),"_Corner") GUICtrlSetState(-1,1) GUICtrlCreateMenuItem("",$3) Local $5=GUICtrlCreateMenu("Misdetection Penalty",$3) For $i=5 To 10 GUICtrlSetOnEvent(GUICtrlCreateMenuItem($i,$5),"_Penalty") Next GUICtrlSetState(-1,1) GUICtrlCreateMenuItem("",$3) Local $6=GUICtrlCreateMenu("Square Size",$3) GUICtrlSetOnEvent(GUICtrlCreateMenuItem("Decrease"&@TAB&" –",$6),"_SizeX") GUICtrlSetOnEvent(GUICtrlCreateMenuItem("Standard"&@TAB&" #",$6),"_SizeX") GUICtrlSetState(-1,1) GUICtrlSetOnEvent(GUICtrlCreateMenuItem("Increase"&@TAB&" +",$6),"_SizeX") Local $7=GUICtrlCreateMenu("Atom Depiction",$3) GUICtrlSetOnEvent(GUICtrlCreateMenuItem("Circle",$7),"_Atoms") GUICtrlSetState(-1,1) GUICtrlSetOnEvent(GUICtrlCreateMenuItem("Square",$7),"_Atoms") GUICtrlCreateMenuItem("",$3) GUICtrlSetOnEvent(GUICtrlCreateMenuItem("Screen Capture"&@TAB&"F10",$3),"_Hotkey") GUICtrlSetState(-1,1) GUICtrlSetOnEvent(GUICtrlCreateMenuItem("Load Configuration"&@TAB&"F5",$3),"_Laden") Global $4=GUICtrlCreateMenu("?") GUICtrlSetOnEvent(GUICtrlCreateMenuItem("About",$4),"_About") GUICtrlSetOnEvent(GUICtrlCreateMenuItem("Rules",$4),"_Rules") GUICtrlSetOnEvent(GUICtrlCreateMenuItem("Support",$4),"_Support") GUICtrlSetResizing(GUICtrlCreateLabel("",0,$Hoehe*45+2,72,16,512+11+4096),834);BitOR($SS_SIMPLE,$SS_SUNKEN)) GUICtrlSetResizing(GUICtrlCreateLabel("",73,$Hoehe*45+2,58,16,512+11+4096),834) GUICtrlSetResizing(GUICtrlCreateLabel("",132,$Hoehe*45+2,60,16,512+11+4096),834) GUICtrlSetResizing(GUICtrlCreateLabel("",193,$Hoehe*45+2,($Breite+2)*($Size+2)-173,16,512+11+4096),582) GUISetOnEvent(-3,"_Exit") Local $client=WinGetClientSize($GUI),$pos=WinGetPos($GUI),$t[3]=["Width:","Height:","Atoms:"],$s[2]=["Apply","Cancel"] Global Const $Second=GUICreate("",138,103,Default,Default,2147483648,-1,$GUI),$Group=GUICtrlCreateGroup("",5,0,128,80),$xBorder=$pos[2]-$client[0],$yBorder=$pos[3]-$client[1],$Control[4]=[$1+1,$1+3,$1+5,$1+4] Global $bMax=Int((@DesktopWidth-20-$xBorder)/16-2),$hMax=Int((@DesktopHeight-38-$yBorder)/16-2) GUISetBkColor(0) For $i=0 To 2 GUICtrlSetColor(GUICtrlCreateLabel($t[$i],15,11+23*$i-($i=2),35,20,512),0xFFFFFF) GUICtrlSetOnEvent(GUICtrlCreateIcon("progman.exe",-45,56,11+23*$i,16,20),"_UpDown") GUICtrlSetStyle(-1,256+3) GUICtrlSetCursor(-1,0) GUICtrlSetFont(GUICtrlCreateInput("",75,11+23*$i,30,17,0x2001),-1,600) GUICtrlSetCursor(-1,0) GUICtrlSetOnEvent(GUICtrlCreateIcon("progman.exe",-48,108,11+23*$i,16,20),"_UpDown") GUICtrlSetStyle(-1,256+3) GUICtrlSetCursor(-1,0) Next For $i=0 To 1 GUICtrlSetOnEvent(GUICtrlCreateLabel($s[$i],59+38*$i,81,30+$i*5,20,512),"_Apply") GUICtrlSetColor(-1,0xFFFFFF) GUICtrlSetFont(-1,-1,-1,4) GUICtrlSetCursor(-1,0) Next GUICtrlSetStyle(GUICtrlCreateIcon("pifmgr.dll",-37,8,83,16,16),3) GUISetOnEvent(-7,"_Drag") Local $t=0,$s=0 GUISwitch($GUI) EndFunc Func _Items($x,$y,$z) $Menu[$x]=GUICtrlCreateMenu($x+5&"x"&$x+5,$2) For $i=$y To $z GUICtrlSetOnEvent(GUICtrlCreateMenuItem($i&" Atoms",$Menu[$x]),"_Move") Next GUICtrlCreateMenuItem("",$Menu[$x]);"- – —" GUICtrlSetState(GUICtrlCreateMenuItem($y&" - "&$z&" Atoms",$Menu[$x]),128) EndFunc Func _Ecke($a,$b,$c=-1,$d=-1) GUICtrlSetState($Control[$a],128-64*$b) If GUICtrlRead($3+2)=65 Then If $b Then ControlSetText($GUI,"",$Ecke[$a],$Name[$a]) ControlEnable($GUI,"",$Ecke[$a]) Else ControlSetText($GUI,"",$Ecke[$a],"") ControlDisable($GUI,"",$Ecke[$a]) EndIf EndIf If $c>-1 Then _Ecke($c,$d) EndFunc Func _Corner() _Numbers() For $i=0 To 3 If GUICtrlRead(@GUI_CtrlId)=65 And GUICtrlGetState($Control[$i])<65 Then ControlSetText($GUI,"",$Ecke[$i],$Name[$i]) ControlEnable($GUI,"",$Ecke[$i]) Else ControlDisable($GUI,"",$Ecke[$i]) ControlSetText($GUI,"",$Ecke[$i],"") EndIf Next EndFunc Func _Hotkey() If GUICtrlRead(@GUI_CtrlId)=68 Then Return GUICtrlSetState(@GUI_CtrlId,HotKeySet("{F10}","_Capture")) GUICtrlSetState(@GUI_CtrlId,4*HotKeySet("{F10}")) EndFunc Func _Capture() Local $n=($Breite+2)*($Hoehe+2)-1,$j=2*(($n>255)+1),$file=$BB&Hex($Breite,$j)&Hex($Hoehe,$j),$cnt=0 For $i=0 To $n If $Ball[Int($i/($Hoehe+2))][Mod($i,$Hoehe+2)] Then $file&=Hex($i,$j) Next While FileExists($file&Hex($cnt,1)&".jpg") $cnt+=1 WEnd WinActivate($GUI) Local $pos=WinGetPos($GUI),$save=$file&Hex($cnt,1)&".jpg" _ScreenCapture_Capture($save,$pos[0],$pos[1],$pos[2]+$pos[0],$pos[3]+$pos[1],0) DllCall($U32,$INT,"FlashWindow",$HWN,$GUI,$INT,1) FileSetAttrib($save,"+R") EndFunc Func _ToolTip($titel="Black Box Screenshot",$text="The chosen Screenshot File is invalid.",$icon=3);,$style=5 Local $pos=WinGetPos($GUI) ToolTip($text,$pos[0]+$Size+18+$xBorder/2,$pos[1]+$Size+15+$yBorder,$titel,$icon,4);7 ist gut für Lösung 5 gut für fehler ? Local $hToolTip=WinGetHandle("[TITLE:"&$text&"; CLASS:tooltips_class32]"),$t=DllCall($U32,$INT,"GetWindowLong",$HWN,$hToolTip,$INT,0xFFFFFFF0);$GWL_STYLE = 0xFFFFFFF0 DllCall($U32,$INT,"SetWindowLong",$HWN,$hToolTip,$INT,0xFFFFFFF0,$INT,BitOR($t[0],128));$TTS_CLOSE = 128 DllCall($U32,$INT,"SendMessage",$HWN,$hToolTip,$INT,1044,$INT,0x8BECFF,$INT,0);$TTM_SETTIPTEXTCOLOR = 1044;0xFFFFFF DllCall($U32,$INT,"SendMessage",$HWN,$hToolTip,$INT,1043,$INT,0x748B45,$INT,0);$TTM_SETTIPBKCOLOR = 1043;0x985428 DllCall($U32,$INT,"SendMessage",$HWN,$hToolTip,$INT,1053,$INT,0,$INT,0);$TTM_UPDATE = 1053 EndFunc Func _Unset() HotKeySet("{F1}") HotKeySet("{F2}") HotKeySet("{F3}") HotKeySet("{F4}") HotKeySet("{F5}") HotKeySet("{ESC}") HotKeySet("{+}") HotKeySet("{#}") HotKeySet("-") EndFunc Func _Penalty() GUICtrlSetState($3+$Wert,4) GUICtrlSetState(@GUI_CtrlId,1) Global $Wert=GUICtrlRead(@GUI_CtrlId,1) EndFunc Func _Numbers() GUICtrlSetState(@GUI_CtrlId,Abs(GUICtrlRead(@GUI_CtrlId)-69)) EndFunc Func _About() _ToolTip("About Black Box",$Script,1) EndFunc Func _Rules() ShellExecute("http://en.wikipedia.org/wiki/Black_Box_%28game%29") EndFunc Func _Support() ShellExecute("http://www.autoitscript.com/forum/topic/123798-black-box-game/") EndFunc Func _Activate() WinActivate($GUI) EndFunc Func _Drag() If WinActive($Second) Then DllCall($U32,$INT,"SendMessage",$HWN,@GUI_WinHandle,$INT,274,$INT,0xF012,$INT,0) EndFunc Func _Exit() Exit EndFunc Edit: new version 1.1
  6. the advantage is, for self-autoit-made controls, that there is no need to detect the style, because you can look it up in helpfile. the "long and complicated" way (not my words) is well suitable for "alien" windows.
  7. well, there's an easier and more understandable way to get rid of the "forced styles" : GUICtrlSetStyle. don't forget to add the styles you need, because otherwise you will lose notification and other necessary things, so look it up in helpfile. some examples: ;Example For Button ;================== GUICtrlCreateButton(.......) GUICtrlSetStyle(-1,$BS_NOTIFY) ;Example for Icon ;================ GUICtrlCreateIcon(........) GUICtrlSetStyle(-1,BitOR($SS_NOTIFY,$SS_ICON)) ;Example for Checkbox ;==================== GUICtrlCreateCheckbox(........) GUICtrlSetStyle(-1,$BS_AUTOCHECKBOX) cheers j.
  8. oops you're right.... i didn't know that. i was definitely thinking the underline should always be showing. maybe it can be set by windows somewhere.... thx a lot j.
  9. hi there and merry christmas ! from helpfile: #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $defaultstatus, $status, $filemenu, $fileitem, $helpmenu, $saveitem Local $infoitem, $exititem, $recentfilesmenu, $separator1, $viewmenu Local $viewstatusitem, $okbutton, $cancelbutton, $statuslabel, $msg, $file GUICreate("My GUI menu", 300, 200) Global $defaultstatus = "Ready" Global $status $filemenu = GUICtrlCreateMenu("&File") $fileitem = GUICtrlCreateMenuItem("Open", $filemenu) GUICtrlSetState(-1, $GUI_DEFBUTTON) $helpmenu = GUICtrlCreateMenu("?") $saveitem = GUICtrlCreateMenuItem("Save", $filemenu) GUICtrlSetState(-1, $GUI_DISABLE) $infoitem = GUICtrlCreateMenuItem("Info", $helpmenu) $exititem = GUICtrlCreateMenuItem("Exit", $filemenu) $recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu, 1) $separator1 = GUICtrlCreateMenuItem("", $filemenu, 2) ; create a separator line $viewmenu = GUICtrlCreateMenu("View", -1, 1) ; is created before "?" menu $viewstatusitem = GUICtrlCreateMenuItem("Statusbar", $viewmenu) GUICtrlSetState(-1, $GUI_CHECKED) $okbutton = GUICtrlCreateButton("OK", 50, 130, 70, 20) GUICtrlSetState(-1, $GUI_FOCUS) $cancelbutton = GUICtrlCreateButton("Cancel", 180, 130, 70, 20) $statuslabel = GUICtrlCreateLabel($defaultstatus, 0, 165, 300, 16, BitOR($SS_SIMPLE, $SS_SUNKEN)) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $fileitem Then $file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)") If @error <> 1 Then GUICtrlCreateMenuItem($file, $recentfilesmenu) EndIf If $msg = $viewstatusitem Then If BitAND(GUICtrlRead($viewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($viewstatusitem, $GUI_UNCHECKED) GUICtrlSetState($statuslabel, $GUI_HIDE) Else GUICtrlSetState($viewstatusitem, $GUI_CHECKED) GUICtrlSetState($statuslabel, $GUI_SHOW) EndIf EndIf If $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton Or $msg = $exititem Then ExitLoop If $msg = $infoitem Then MsgBox(0, "Info", "Only a test...") WEnd GUIDelete() EndFunc ;==>Examplethe ampersand should show "File" on the menu, but it doesn't on my computer, neither in my scripts. can anyone make a suggestion, while the underline does not show ? the ampersand itself doesn't show either, the menu text is just "File". what can i do, please ? thx j.
  10. Hi Martin this is exactly same problem as mine. i use win xp sp3, same as you. i use the (newest) DLL version 2.55, $sUDFVersion = 'PrintMG.au3 V2.64' i do not have v 2.54. Func _PrintSelectPrinter($hDll, $PrinterName) $vDllAns = DllCall($hDll, 'int', 'SelectPrinter', 'str', $PrinterName) If @error = 0 Then Return $vDllAns[0] Else Return -1 EndIf EndFunc ;==>_PrintSelectPrinter there is no second param, that's why it crashes ? cheers j.
  11. did you check 'SelectPrinter' ? can you reproduce the bug ? i can work around the default printer problem, but the crashing is annoying. j.
  12. you find the document settings in the registry: RegRead("HKCU\Printers\DevModePerUser",$sPrinter) it's a binary string and depends on the printer, so it is not possible to decrypt it. but by changing the settings and reading the reg string you can detect the needed setting and regwrite it. you can save the default setting and restore it afterwards. cheers j.
  13. well, i don't think it's what you need, but you find the document settings in the registry: it's a binary string and depends on the printer, so it is not possible to decrypt it. but by changing the settings and checking the reg string you can detect the needed setting and regwrite it. but, this is just a method to change the document settings, not what you need. regards j.
  14. hi martin ! i downloaded the latest version (printmg.dll 2.55) and 'SelectPrinter' does not work anymore. it causes an autoit crash (with drwatson). i use xp sp3. luckily i have an old version, 2.48, which works fine, but 'SelectPrinter' changes the default printer. maybe you can offer the last stable version of your dll (with working 'SelectPrinter'), or maybe a selection of all versions, so that at least the new downloaders will have the chance to use you fantastic udf ? thank you ! j. edit: i just noticed you uploaded this version in october 2010, so i might be the first to encounter this problem.
×
×
  • Create New...