read from ini

Get help with using AutoHotkey and its commands and hotkeys
asad41163
Posts: 203
Joined: 29 Jul 2014, 14:31

read from ini

24 Apr 2018, 04:37

Hi everyone

Code: [Select all] [Download] GeSHi © Codebox Plus

CapsLock::
QuickToggle:=!QuickToggle
If (QuickToggle)
WinActivate Google Chrome
Else
WinActivate word
Return


I want to compail the code, and take it the name of the 2 window from the .ini file
Is this possible?
I mean: Can the script read "WinActivate" from the INI file?
If someone could show me how to do this, I would be very grateful!
Guest

Re: read from ini

24 Apr 2018, 04:58

- https://www.autohotkey.com/docs/commands/IniRead.htm twice for window1 and window2 variable
- replace "Google Chrome" and "word" with %window1% and %window2%

post code if you get stuck, confirm/test that window1 and 2 have the correct information using a MsgBox %window1% after the IniRead command(s) so you know it worked.
asad41163
Posts: 203
Joined: 29 Jul 2014, 14:31

Re: read from ini

24 Apr 2018, 07:50

Hi, everyone,
welcome, Mr. Guest

What is the problem please?
WinToggle.ahk

Code: [Select all] [Download] GeSHi © Codebox Plus

CapsLock::
QuickToggle:=!QuickToggle
If (QuickToggle)
WinActivate %window1%
Else
WinActivate %window2%
Return

#Include WinToggle.ini



WinToggle.ini

Code: [Select all] [Download] GeSHi © Codebox Plus

[WinActivate]
window1=Google Chrome
window2=word



thanks in advance.
User avatar
gregster
Posts: 1379
Joined: 30 Sep 2013, 06:48

Re: read from ini

24 Apr 2018, 08:27

Use IniRead instead of #include to read values from an ini-file, like Guest already suggested.
asad41163
Posts: 203
Joined: 29 Jul 2014, 14:31

Re: read from ini

24 Apr 2018, 08:36

I have no experience
Teach me how it is done, please
Guest

Re: read from ini

24 Apr 2018, 08:49

Just look at the Example https://autohotkey.com/docs/commands/In ... tm#Example and replace the values as you need them to be.

So OutputVar in the example is Window1 in your case, myfile.ini should be WinToggle.ini (no full path required) section2 is WinActivate and key is Window1 as well. So basically I used more time and words to describe it than it would for you to try it :-)
asad41163
Posts: 203
Joined: 29 Jul 2014, 14:31

Re: read from ini

24 Apr 2018, 09:12

Why does not it work?

WinToggle.ahk

Code: [Select all] [Download] GeSHi © Codebox Plus

IniRead, var, E:\Programs\WinToggle.ini, Section, window
CapsLock::
QuickToggle:=!QuickToggle
If (QuickToggle)
WinActivate %window1%
Else
WinActivate %window2%
Return


WinToggle.ini

Code: [Select all] [Download] GeSHi © Codebox Plus

[window]
window1=Google Chrome
window2=word
asad41163
Posts: 203
Joined: 29 Jul 2014, 14:31

Re: read from ini

24 Apr 2018, 09:50

Please, anybody do it for me.
Guest

Re: read from ini

24 Apr 2018, 10:18

Code: [Select all] [Download] GeSHi © Codebox Plus

IniRead, window1, WinToggle.ini, Window, window1
MsgBox %window1%
repeat for window2
swagfag
Posts: 1084
Joined: 11 Jan 2017, 17:59

Re: read from ini

24 Apr 2018, 10:25

Code: [Select all] [Download] GeSHi © Codebox Plus

IniRead, var1, E:\Programs\WinToggle.ini, window, window1
IniRead, var2, E:\Programs\WinToggle.ini, window, window2
CapsLock::
QuickToggle:=!QuickToggle
If (QuickToggle)
WinActivate %var1%
Else
WinActivate %var2%
Return


gl understanding that with variable names as cool as these
asad41163
Posts: 203
Joined: 29 Jul 2014, 14:31

Re: read from ini

24 Apr 2018, 11:22

welcome Mr. swagfag
thank you very much
For the file (WinToggle.ini)
Is this right?

Code: [Select all] [Download] GeSHi © Codebox Plus

[Window]
window1=Google Chrome
window2=word
asad41163
Posts: 203
Joined: 29 Jul 2014, 14:31

Re: read from ini

25 Apr 2018, 05:24

Unfortunately, it does not work
I do not know where the problem is?
swagfag
Posts: 1084
Joined: 11 Jan 2017, 17:59

Re: read from ini

25 Apr 2018, 06:08

Code: [Select all] [Download] GeSHi © Codebox Plus

IniRead, chrome, E:\Programs\WinToggle.ini, WindowNames, windowChrome
IniRead, word, E:\Programs\WinToggle.ini, WindowNames, windowWord
MsgBox, % "Chrome: " . chrome
. "`r`n" . "Word: " . word


Code: [Select all] [Download] GeSHi © Codebox Plus

[WindowNames]
windowChrome=Google Chrome
windowWord=word
Last edited by swagfag on 25 Apr 2018, 13:58, edited 1 time in total.
asad41163
Posts: 203
Joined: 29 Jul 2014, 14:31

Re: read from ini

25 Apr 2018, 06:29

Please check it out
Unfortunately, it does not work
I am a new user and do not know where the problem is.
User avatar
gregster
Posts: 1379
Joined: 30 Sep 2013, 06:48

Re: read from ini

25 Apr 2018, 08:32

What does not work? Reading from the ini-file? Replace the msgbox-line(s) with
MsgBox, % "Chrome: " . chrome . "`r`n" . "Word: " . word or

Code: [Select all] [Download] GeSHi © Codebox Plus

MsgBox, % "Chrome: " . chrome 
. "`r`n" . "Word: " . word

(swagfag forgot a . in the continuation section)

If there was another problem - why didn't you describe it? "It does not work" doesn't help anyone!

By the way, you joined here 4 years ago and have made 170 posts. You should know by now that detailed information - also about the error messages you get - is much more valuable for debugging than begging. Like this, it will generally take more time to get the right help...
asad41163
Posts: 203
Joined: 29 Jul 2014, 14:31

Re: read from ini

25 Apr 2018, 13:48

The error is:
When you press the Capslock key
Switching between the two frames does not occur,
- Google Chrome Frame
- Word Frame
 This is the code:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Code: [Select all] [Download] GeSHi © Codebox Plus

[WindowNames]
windowChrome=Google Chrome
windowWord=word
swagfag
Posts: 1084
Joined: 11 Jan 2017, 17:59

Re: read from ini

25 Apr 2018, 14:02

youre right, i did, thanks @gregster, now fixed.

as to the question at hand, read the docs on IniRead please, youre using the wrong variable in your script, next check your TitleMatchMode, and finally check your window titles if youve typed them correctly
asad41163
Posts: 203
Joined: 29 Jul 2014, 14:31

Re: read from ini

25 Apr 2018, 14:37

I am very sorry
I will read the documents, always rely on them, God willing
I repeat my apology

Return to “Ask For Help”

Who is online

Users browsing this forum: art, FidoGooL, kirby, scriptors and 60 guests