AutoHotkey Community

It is currently May 27th, 2012, 2:52 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: November 27th, 2009, 10:57 am 
with the below code i am able to read the contents of the ini file after the = sign...now what i want is to read the contents of the ini file before the sign and use this content for my next step like opening a file

my test.ini file is like this:-

[Production]
C:\Programfiles\Mywork\=Hello
C:\Programfiles\Exwork\=Welcome



Code:
loop, read, C:\Documents and Settings\Devil\Desktop\test.ini
   {
      if a_loopreadline contains =
      {
         StringSplit, buttonname, a_loopreadline, =
         Gui, Add, Button,w200 h50, %buttonname2%
      }
   }
   gui show


so from the above code i am able to display hello and welcome on gui but i am not getting any idea of extracting the content before the = sign in the test.ini file like C:\Programfiles\Mywork


Report this post
Top
  
Reply with quote  
PostPosted: November 27th, 2009, 11:08 am 
Offline

Joined: August 13th, 2006, 6:45 am
Posts: 355
Location: Germany
after the StringSplit, you will find it in buttonname1

Hubert


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 11:15 am 
sorry to say but i didnt got want you mean to say i am still confused can tell me where to make changes so tht i will get both the contents (C:\Programfiles\Mywork & C:\Programfiles\Exwork) displayed after the GUI displays Hello and Welcome


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 11:17 am 
thanks a lot for the reply....but sorry to say that i didnt got want you mean to say i am still confused can tell me where to make changes so tht i will get both the contents (C:\Programfiles\Mywork & C:\Programfiles\Exwork) displayed after the GUI displays Hello and Welcome

as one of our ahk member helped me with this read function so i am bit confused with button1,2.....and why it is mentioned as %buttonname2%


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 11:21 am 
sorry to disturb again but by putting buttonname1 i got for the first button as C:\Programfiles\Mywork but for the next button i got Welcome why not C:\Programfiles\Exwork ???


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 11:35 am 
Offline

Joined: August 13th, 2006, 6:45 am
Posts: 355
Location: Germany
please show your changed script, so that we can help

Hubert


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 11:40 am 
hey cool its working now i mean all before the = sign.....thanks a lot man

so the for now the script is like this

Code:
Loop, read, C:\Documentsand settings\Devil\Desktop\test.ini
   {
      if a_loopreadline contains =
      {
         StringSplit, buttonname, a_loopreadline, =
         Gui, Add, Button,buttonname w200 h50, %buttonname1%
      }
   }
gui show
Return

Button%buttonname1%:
run notepad.exe




so is it possible to define actions for this button like if i press first button it should run notepad.exe and if i press second it should run calc.exe ???

because in the above code i added this but it didnt worked and i dont know how to identity the button 1 is pressed or 2???


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 11:54 am 
Offline

Joined: August 13th, 2006, 6:45 am
Posts: 355
Location: Germany
here is my solution. hava a look at the parts marked in red:

Code:
Loop, read, C:\Documentsand settings\Devil\Desktop\test.ini
   {
      if a_loopreadline contains =
      {
         ind++
         StringSplit, buttonname, a_loopreadline, =
         Gui, Add, Button, gbuttonname%ind% w200 h50, %buttonname1%
      }
   }
gui show
Return

buttonname1:
run notepad.exe
return

buttonname2:
run calc.exe
return


Hubert


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 11:59 am 
ok i will try to explain it more clearly

I want to create my project more generic so that anyone who wants to make changes then he has to do it only in .ini file not in the autohotkey script....
so what i am doing is if i make a ini file with two buttons as Paint and Notepad...if the user clicks paint it should open paint and also when he clicks Notepad it should open notepad....i know we can do it in a simple way as:-

Code:
Gui, Add, Button, w186 h49,Paint
Gui, Add, Button, w186 h49,Notepad
Gui,show
Return

ButtonPaint:
run mspaint.exe
return

ButtonNotepad:
run notepad.exe
return


but as i said i want to do it at runtime that is when the user makes changes in the .ini file and adds one more button as Word the gui should show this update(and with all your help i am able to do this) but how to execute the function related to that button i.e. word.exe that is their should be some loop like

Code:
Button%button%: ; paint,word,calculator
run ..... ; this should know that which button is pressed and for that button what action is defined in .ini file.....
 that is if he press paint then mspaint.exe should run or if word is pressed then word.exe should run

Sorry for irritating but i am in desperate need of it

Thanks a lot for reading and your concerns


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 12:07 pm 
well brother its giving error at

Gui, Add, Button, gbuttonname%ind% w200 h50, %buttonname1%

specifically the error is at:-gbuttonname1


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 12:25 pm 
Offline

Joined: August 13th, 2006, 6:45 am
Posts: 355
Location: Germany
Anonymous wrote:
well brother its giving error


well brother, but sorry again, please show your changed script and the given error message, so that we can help
we are no clairvoyants (in german: Hellseher)

Hubert


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 12:31 pm 
ok no problem here is the script
Code:
Loop, read, C:\Documents and Settings\Devil\Desktop\test.ini
   {
      if a_loopreadline contains =
      {
         ind++
         StringSplit, buttonname, a_loopreadline, =
      Gui, Add, Button,gbuttonname%ind% w200 h50, %buttonname1%
      }

}
gui show
Return

buttonname1:
run notepad.exe



and the error is

Specifically: gbuttonname1
008: Gui, Add, Button,gbuttonname%ind% w200 h50, %buttonname1%


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 12:45 pm 
Offline

Joined: August 13th, 2006, 6:45 am
Posts: 355
Location: Germany
sorry, but when I use your code mentioned above, I get:
Code:
  Error: Target label does not exist.  The current thread will exit.

  Specifically: gbuttonname2
and that is totally understandable, as you create 2 buttons and therefor you must have 2 labels too.

Hubert


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 12:53 pm 
ya thats right because with one button it runs successfully but two posting before you can see what i expect like if there are two buttons like paint and word and if the user press button 1 then it should execute the information mentioned in the ini file
for example:-

test.ini
[Production]
Paint=run paint.exe
Word=run word.exe

on gui it displays Paint and Word but how to append the action related to each button or in other case to display paint.exe or word.exe if i press paint and word respectively


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 1:10 pm 
well if you see the test runs successfully with one entry in the ini and one button display on the Gui and i can send the information related to that button which is mentioned in the inifile but when i want to add one more button on the gui and want to follow the same procedure then do i have to write the code twice or their is some way of settingup a variable which will montior which button and then append the action....i think this is the last step and then i will succeed

Code:
Run Notepad.exe
WinWaitActive Untitled - Notepad

Loop, read, C:\Documents and Settings\Devil\Desktop\test.ini
   {
      if a_loopreadline contains =
      {
         ind++
         StringSplit, buttonname, a_loopreadline, =
         Gui, Add, Button,gbuttonname%ind% w200 h50, %buttonname1%
       
      }

}
gui show
Return


buttonname1:
run notepad.exe
 Untitled - Notepad
sleep 500
Loop, read, C:\Documents and Settings\Devil\Desktop\test.ini
   {
      if a_loopreadline contains =
      {
         ind++
         StringSplit, buttonname, a_loopreadline, =
         Send %buttonname2% 
       
      }

}
sleep 500

Return


test.ini
[Production]
Notepad=Hi how are you

and if i add one more
test.ini
[Production]
Notepad=Hi how are you
Word=Welcome

then do i have to write a separatecode for this button???


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: rbrtryn and 21 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group