AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Odd/Even Numbers ?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Dra_Gon



Joined: 25 May 2007
Posts: 314

PostPosted: Sat Sep 13, 2008 7:33 pm    Post subject: Odd/Even Numbers ? Reply with quote

Anyone know of a simple way to get a script to recognize odd or even numbers? I'm using a little trick of simulating Gui buttons {from Skan's "Tips N Tricks"} and need the script to distinguish between the doubled pictures for the ToolTips.
The "upper" pictures show the tooltips just fine, but when the click hides that, the tooltip then changes to show the previous "button's" tooltip instead of the proper one.
I figure if I can get it to recognize ONLY the 2nd picture of each "button" then the tooltip would only show before the picture is clicked. {Geez, I hope that's clearer than it actually looks Confused .} Thanks in advance!

Ciao,
Dra'Gon
_________________

For a good laugh {hopefully} >> megamatts.50megs.com

My WritersCafe profile>>
http://www.writerscafe.org/writers/BlueDragonFire/
Back to top
View user's profile Send private message Send e-mail
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Sat Sep 13, 2008 7:38 pm    Post subject: Reply with quote

(x & 1) is 1 (true) for odd x values, 0 (false) for even values.
Back to top
View user's profile Send private message
Trikster



Joined: 15 Jul 2007
Posts: 1224
Location: Enterprise, Alabama

PostPosted: Sat Sep 13, 2008 7:40 pm    Post subject: Reply with quote

Code:
Gui, Add, Button, w50 h20 gAdd, +
Gui, Add, Text, w100 h20 +Center vNum
Gui, Show
Return

Add:
GuiControl,, Num, % Mod(++Num, 2) ? "Odd" : "Even"
Return


Not tested, but it should work. If it doesn't, I'm sure you'll understand the concept.

Edit: Laszlo beat me to it =\
_________________
ScriptPad | ~dieom | dieom | izwian2k7 | Ian | God
Back to top
View user's profile Send private message
Dra_Gon



Joined: 25 May 2007
Posts: 314

PostPosted: Sun Sep 14, 2008 7:38 pm    Post subject: Reply with quote

I can't seem to make this mod() thing work. Let me put a bit of my code up to show what I'm trying to accomplish {It'll - hopefully - be an IDE someday Rolling Eyes }.

This is where the "buttons" are put in:
Code:
  loop, %nCtrls%
  {
    IniRead, ctrl_%a_Index%, %guicBtns%, BtnCtrls, btn_%a_Index%_Name   ; User can choose either normal buttons or image "buttons" and this gets that choice.
    IfEqual, ynPcTxt, Pic
      {
      Gui, Add, picture, x%iX% y%iY% w26 h26 E0x200 Icon%a_Index% glblControlAdd, %guicIcons%   ; This will be the bottom pic of the image "button".
      iX = p+0
      iY = p+0
      Gui, Add, picture, x%iX% y%iY% w28 h28 Border vbtnControl%a_Index% Icon%a_Index% glblControlAdd, %guicIcons%   ; This will be the top pic of the image "button".
    }
    Else
      Gui, Add, Button, x%iX% y%iY% w80 vbtnControl%a_Index% glblControlAdd, % ctrl_%a_Index%

    ifEqual i, 12
      {
        iX = +10
        iY = 10
        i = 1
      }
    Else
      {
        iX = p+0
        iY = +10
        i += 1
      }
    }

  Gui, Show, Center AutoSize, Gui Creator - Main (by Dra'Gon)


And for the ToolTips:
Code:
CtrlTipMain:
  MouseGetPos, msX, msY, mgpId, mgpControl
  WinGetTitle, wgtTitle, ahk_id %mgpId%
  StringReplace, nTmp, mgpControl, static,
 
  msX += 25
  msY -= 25
  ntmp -= 1   ; This is the "button" number and is what needs to be changed to show the correct ToolTip

  IfInString, wgtTitle, - Main
    IfInString, mgpControl, static
      ToolTip, % "Place - " ctrl_%nTmp%, %msX%, %msY%
    Else
      {
        GuiControl,, %mgpControl%, *Icon%nTmp% *w23 *h23 %guicIcons%
        ToolTip
      }

  GetKeyState, msLeft, LButton, P
 
  IfEqual, msLeft, U
    IfEqual, iMs, 1
    {
      GuiControl,, %mgpControl%, *Icon%nTmp% *w23 *h23 %guicIcons%
      iMs = 0
    }

Return


Now if the user chooses Text buttons then the ToolTips would behave normally with each button {I should be able to get the differing behaviors done myself} but with the picture "buttons" I need for the ToolTips to be the same for the top and bottom pics. I'm going to keep trying stuff to see what I can come up with, but would appreciate any nudging in the right direction here. Thanks for the replies!

Ciao,
Dra'Gon
_________________

For a good laugh {hopefully} >> megamatts.50megs.com

My WritersCafe profile>>
http://www.writerscafe.org/writers/BlueDragonFire/
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group